Skip to content

Pin path remembers buffers; led walks read bucket runs, inline grid counts, class bounds from tables - #108

Merged
bweis merged 1 commit into
mainfrom
pr/perf-integrate17
Oct 17, 2026
Merged

bweis merged 1 commit into
mainfrom
pr/perf-integrate17

Conversation

@bweis

@bweis bweis commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

From tinshape/perf-integrate17 (887c5e8). Page layout 16 is unchanged, so layout-16 indexes need no REINDEX.

Run pages are pinned by arithmetic and remembered buffers (loop/pinpath).

  • A run page's data is found by arithmetic: its header and link, a chain's capacity per page, and the run's length on its last page. Its header and special area are checked once per backend, on its first pin.
  • Each run page's page-table entry remembers the shared buffer it was last pinned in. The next pin tries that buffer before the shared hint table, so a repeat pin costs the page-table line and the buffer's own state, without a hint bucket's miss as well.
  • The hint stays a hint. The buffer's tag is checked, and a refused buffer falls through to the shared table and ReadBuffer. Debug builds check every page and compare.
  • Page tables take 8 bytes per run page per backend: about 36 MB at 150M rows, within the reader cache's budget.
  • With PostgreSQL on one Sapphire Rapids core's two hyperthreads: 2.1% more queries per cycle, every style at least 1.3%, same answers.

Led walks, grid members and class bounds (loop/survivors T, B, C).

  • T: a ranked walk led by one word reads a candidate's score buckets from the group's run of term frequencies (TfRun). The run is taken at the group's first read, so the walk no longer finds each of its pages again.
  • B: a grid member a few words on is ranked by counting those words inline.
  • C: a candidate's class bound sums its terms' scores at the four class floors from per-term tables, with no division. OR's late class check does the same.
  • Dropped: E, the joint sieve (dbd0508), and its test a0356e2. On Sapphire Rapids, with each arm built with its own replay profile, it gained on full_score and lost on score: nothing net. TBCE scored −0.82% vs the base, and in clean round 3 conj was −0.7%, below the −0.5 floor. TBC scored +1.05% KEEP.

Tooling: tnsreplay --once (one timed pass per query, starting from the previous query's caches) and multiplexed hardware counts scaled by time enabled over time running.

PGO retrained on this tree: x86_64 and x86_64-v4 (2af7c16), and aarch64 (887c5e8). Score answers differ from pg-ranked in 0 cases, and full_score answers match integrate16's trainings. PGO coverage is 40 of 40 for x86-64 and for x86-64-v4 in the strict default (loader) image, the first time the loader image has been checked, and in both install-release --pgo 1 server builds. aarch64 is also 40 of 40 in the strict image.

Answers. Scores are bit-identical over the whole 150M trace on aarch64. The final code was replayed with tnsreplay --mmap on dump-v16: 1228 / 1253 / 1252 equal, 0 different, and --full is byte-identical to f0962a8 in all 3 styles. The x86 --expect (TBCE, v4 + replay PGO) also gave 0 different. The ranked oracle matched on 3762/3762 queries. In the server pair, all 4642 list queries gave identical ids and scores. Conformance against TIN 1.0.3 and 1.0.4 is unchanged, 0 FAIL.

x86 replay, Sapphire Rapids (m7i.4xlarge), paired-core gate, 3 rounds, each arm built with its own replay PGO profile (x86-64-v4). Queries per core cycle:

i17 vs i16 TBC vs i16-plus-pinpath
conj −0.39% −0.17%
phrase +0.70% +0.97%
disj +0.95% +1.39%
full conj +0.67% +0.98%
full phrase +2.88% +2.99%
full disj −0.33% +0.19%
geomean +0.74% (rounds +0.6/+0.7/+0.8) +1.05%

The control (same engine, i16 vs i16-plus-pinpath) came in at −0.28%. The replay barely charges for a pin, so pinpath's gain shows in the server, not here.

Server pair, Sapphire Rapids (PG 18.6 PGDG on two hyperthreads of one core, loader builds with PGO on both sides, 2 rounds). Cycles per query, i17 vs i16:

rounds throughput
conj +0.54 / −4.23% +1.91%
phrase −0.77 / −2.30% +1.56%
disj −0.78 / −2.55% +1.69%
full conj −2.93 / −3.15% +3.13%
full phrase −4.25 / −4.17% +4.39%
full disj −1.10 / −1.25% +1.19%
geomean +2.31% (rounds +1.58/+3.03)

L2 misses fell 10–20% in every style. Instructions: full phrase −5.4%, full conj −3.5 to −4.2%, full disj +1.2 to +1.7%.

Local M4 campaign (layout-16 database, strict aarch64 PGO image). QPS score / full_score, change against i16 (7ad38b4):

QPS change
conj 1409 / 887 +3.3% / +4.1%
disj 342 / 133 +1.7% / +1.7%
phrase 1055 / 716 +5.8% / +5.9%
mixed 650 / 299 +4.1% / +5.3%

The first phrase and mixed runs overlapped another repo's CI runner on the Mac, so those two were rerun with the runner idle (mean 0%). Read volume per query is the same as i16's to within 0.01 MiB (EXPLAIN).

Open items

  • The server pair ran 2 rounds, not 3: the session cap cut the third. A later x86 session should add it.
  • B (inline grid counts) may be droppable. On x86 with replay PGO, dropping B scored +0.63% vs TBCE, with no style below +0.09%. Without PGO, dropping B cost the M4 22% more conj cycles. A "TC" arm needs an M4 check with aarch64 PGO first.
  • The dense-tail p99 (full disj 133 vs i15's 136, −2.0%; i16 was −3.5%) is caused by the 4-segment layout, not by code (TAIL25). The 100.7M-document segment is walked first, and the candidate-rich new region delays theta. Balancing the build makes conj/phrase tails worse, and segment orders are neutral on this layout. The leads are theta seeding for dense conj/phrase, or a dense sub-range frontier.

Verified locally: script/test-all full green (pgrx 228 passed), clippy pg17/pg18 and fmt clean, x86 tests under Rosetta (no AVX, AVX scalar, AVX2), PGO 40/40 on aarch64.

…ounts, class bounds from tables (perf-integrate17)
@bweis
bweis merged commit bba395d into main Oct 17, 2026
13 checks passed
@bweis
bweis deleted the pr/perf-integrate17 branch October 17, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant