Skip to content

Length codes on records of at most a twentieth (page layout 19), counting before weighing in disjunction groups - #110

Merged
bweis merged 1 commit into
mainfrom
pr/perf-integrate19
Oct 19, 2026
Merged

bweis merged 1 commit into
mainfrom
pr/perf-integrate19

Conversation

@bweis

@bweis bweis commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

From tinshape/perf-integrate19 (58a5158). Page layout 19: indexes of an earlier layout must be rebuilt (REINDEX). Layout 19 is layout 18 plus length codes on records of at most a twentieth of the documents.

Length codes on rare records (loop/lencode2 3219f95).

  • A record of at most a twentieth of its segment's documents (postings::CODE_SHARE 20) carries a 2-bit length-class code per posting in its TF tail (FORM_CODES 0x20). A ranked walk scoring such a term reads its candidates' length classes from the tail it already reads, not from the document-length pages.
  • I18's trial coded records up to a tenth (+1.48%, NOISE). The census picked a twentieth: the 5–10% records cost 0.5 pt of index and only lengthen TF tails.
  • Index +2.58% at 150M rows (37.97 vs 37.01 GB).
  • x86 server pair (lencode2's, both arms on the same database rewritten each way, no PGO): +2.56%, score disj +4.64%.
  • Here, on two fresh builds (i19 vs i19 minus lencode2, no PGO): +1.38% KEEP (target). Score disj was +3.79% in every round (+2.8 / +6.4 / +2.2), full disj +1.83%, and L2 misses fell 16–17% in both.

Count before weighing in disjunction groups (loop/atleast e1f0f74).

  • A disjunction group whose candidate mask holds at least 64 documents first counts how many of its heavier terms each candidate holds, and keeps only the candidates that can reach the bar. The bounds of the lightest terms, chosen per group, serve as slack. The count is at_least::<M>, M ≤ 4, bit-sliced four words at a time.
  • Only then does it weigh the survivors. This is exact by construction: the kept set is a superset of what weighing keeps.
  • atleast's server pair: +4.06%, score disj +9.76%, full disj +9.59%.

Disjunction container reads without a division (loop/maskload 630c864, added by the coordinator).

  • LazyBlob::page_of finds the page by a multiply with ⌈2⁶⁴/n⌉.
  • or_load takes the slot count from Group::slots() rather than the group's starts.
  • maskload's server pair: +1.07% KEEP (target), score disj +2.71%, full disj +2.84%.

PGO, retrained on this tree:

  • x86_64 and x86_64-v4 (1804cb4), trained over the layout-19 database. Training answers are identical to i18's trainings, score and full_score, at both levels.
  • aarch64 (afaa401).
  • PGO coverage is 40 of 40 for x86-64 and for x86-64-v4 in the strict default (loader) image, and 40 of 40 on aarch64.

Answers.

  • The ranked oracle matched on 3762/3762 queries on the new 150M database, with both the plain image and the strict PGO image.
  • M4 tnsreplay --mmap on a fresh dump: 1228 / 1253 / 1252 equal, 0 different. --full is byte-identical to f0962a8 in all 3 styles.
  • x86 (v4 + replay PGO): --expect 0 different, and --full byte-identical to the same M4 references.
  • In the server pair, i19's answers matched main's on all 4642 list queries (ids and scores), and also matched i18's reference file.
  • Conformance against TIN 1.0.3 and 1.0.4 is unchanged: 13 DIFF, 10 GAP, 219 PASS, 0 FAIL.

x86 replay, Sapphire Rapids (m7i.4xlarge), paired-core gate, 3 rounds, each arm with its own replay PGO (x86-64-v4) and its own fresh dump. i19 vs i18 (main):

paired tail-25 cycles
conj +1.79% −1.6%
phrase +0.98% −2.6%
disj +19.38% −39.2%
full conj +1.14% −1.6%
full phrase +2.09% −0.8%
full disj +22.06% −24.6%
geomean +7.54% (rounds +9.6/+7.0/+6.6), KEEP, TAIL-KEEP

On the fixed tail sets, score disj +64.5% and full disj +32.6%.

Server pair, Sapphire Rapids, WITH PGO on both arms (PG 18.6 PGDG on two hyperthreads of one core, 2 clients, fixed seeded passes, 3 rounds AB BA AB). Both arms are loader builds with --pgo strict, 40/40 at both levels, and v4 was picked. i19 ran on its fresh layout-19 database and main on its layout-18 database. Throughput, i19 vs main:

mean rounds instructions L2 misses
conj +3.07% +3.07 / +3.08 / +3.05 −1.0% −5.9%
phrase +2.03% +2.48 / +2.04 / +1.57 +0.8% −3.5%
disj +20.09% +20.38 / +19.89 / +19.99 −16.9% −37.6%
full conj +0.79% +0.72 / +0.89 / +0.78 +0.3% −2.8%
full phrase +0.94% +0.59 / +1.39 / +0.84 +0.3% −2.3%
full disj +21.01% +20.97 / +20.91 / +21.14 −19.5% −30.1%
geomean +7.63% KEEP +7.67 / +7.69 / +7.53

The coordinator required conjunction and phrase to be at least −0.5% under PGO. That condition is met: the worst style is +0.79%.

EXPLAIN MiB/query vs i18: score −6.2 / −15.9 / −7.1% and full −4.4 / −9.6 / −5.0% (conj / disj / phrase).

Local M4 campaign (new layout-19 database, strict aarch64 PGO image, runner CPU 0% in every kept run). The full mixed run was rerun alone twice because another repository's CI ran beside it. QPS score / full_score, change against i18 (824bb83, layout-18 database):

QPS change p99 ms (vs i18)
conj 1466 / 979 +3.1% / +3.5% 25.7 / 56.9 (26.9 / 58.7)
disj 525 / 206 +49.9% / +46.0% 49.2 / 171.0 (103.9 / 247.3)
phrase 1082 / 763 +1.0% / +3.5% 49.4 / 92.4 (49.6 / 95.0)
mixed 830 / 412 +26.1% / +30.8% 48.7 / 137.6 (89.0 / 196.1)

150M database (local, mock-build v2): import 21.4 min and index build 178.0 min, both on a busy Mac. There are 4 segments, holding the same documents as layout 18. Index 37.97 GB.

Verified locally:

  • script/test-all full green, with pgrx 228 passed and conformance unchanged.
  • clippy pg17/pg18 and fmt clean.
  • engine 78 + segment 164 tests on aarch64.
  • x86 tests under Rosetta: no AVX, AVX scalar, AVX2.

@bweis
bweis merged commit 7573fc4 into main Oct 19, 2026
13 checks passed
@bweis
bweis deleted the pr/perf-integrate19 branch October 19, 2026 16:43
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