Skip to content

Layout 15: positions bit-packed per block, disjunction directories read in order - #106

Merged
bweis merged 1 commit into
mainfrom
pr/perf-integrate15
Oct 16, 2026
Merged

bweis merged 1 commit into
mainfrom
pr/perf-integrate15

Conversation

@bweis

@bweis bweis commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Layout 15, from tinshape/perf-integrate15 (3a79ba2). Indexes built at layout 14 need a REINDEX, or tnsreencode --from 14 (also from 13, 12, 11, 10, 9, 8 and 6).

Positions bit-packed per block of 32 entries (page layout 15).

  • Packed the way TIN packs its position deltas: entry counts as bit planes, then first positions, then gaps, each block at its own widths.
  • A phrase finds a candidate's positions with a few population counts and reads only those. Before, it decoded up to 31 entries of varints.
  • At 150M rows, positions take 8.2% less space and the index 4.0% less. Phrases read 23–25% fewer positions pages.
  • Measured against the same code reading layout 14 (4 rounds, one Sapphire Rapids host): phrases −3.1% cycles, full_score phrases −2.1%. Conjunctions and disjunctions ran the same instructions over the same pages; their cycles stayed within the host's drift.

Disjunctions read group directories in order.

  • The presence's next bit, then the row after the one before, with no seek per entry.
  • A candidate holding fewer than four scoring terms reads its length class after its buckets.
  • Fixes the layout-14 score-disjunction regression (+1.2% cycles, +12% pages): score disj −6.0% cycles and −9.3% pages against a908527.

A directory frontier's decoder keeps its state in registers.

  • Its rare long varint is read from a copy of the position.
  • 0.8–1.9% fewer instructions in every style.

Kind lookup.

  • A directory entry's expected length and largest group are looked up by its kind. Before, x86-64 compiled this as a three-way branch.
  • Small: mean of six slices −0.4%, worst +0.3%.

Tooling.

  • tnsreplay --plan replays several slices after one load and counts cycles and branch misses in-process on Linux.
  • devbox.sh gains DEVBOX_DUMP_PREFIX.

PGO retrained on layout 15 for aarch64 (d07348e) and x86_64 (b6cef80), both 40/40.

Answers. Scores are bit-identical over the 150M trace (1228 / 1253 / 1252 equal, 0 different; --full byte-identical in all 3 styles). Ranked oracle 3762/3762. Conformance against TIN 1.0.3 and 1.0.4 is unchanged, 0 FAIL. Re-encoding the 150M dump 14 → 15 verifies 14/14 segments, each equal to its own merge.

150M database: index 36.28 GB (layout 14: 37.76, −3.9%), 13 segments.

x86 replay, Sapphire Rapids (m7i.4xlarge), against a908527 (layout 14). 4 rotated rounds, outputs identical. Median cycles / instructions:

score full_score
conj −4.9% / −2.3% −2.5% / −2.4%
phrase −6.4% / −2.8% −2.0% / −2.0%
disj −9.1% / −5.2% −4.8% / −4.7%

Local M4 campaign (new layout-15 database, run with the CI runners idle). QPS score / full_score, change against layout 14 (48fc9a7):

QPS change
conj 1252 / 826 −2.1% / +2.1%
disj 339 / 136 +8.3% / +7.9%
phrase 958 / 666 +6.9% / +8.1%
mixed 627 / 295 +8.9% / +7.7%

Verified locally: script/test-all full green, x86 tests under Rosetta (scalar and AVX2), engine and segment tests on Sapphire Rapids (AVX2 + AVX-512, scalar), PGO 40/40 on aarch64 and x86_64.

@bweis
bweis merged commit 07e12dd into main Oct 16, 2026
12 checks passed
@bweis
bweis deleted the pr/perf-integrate15 branch October 16, 2026 17:46
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