Repository navigation
Done
Labels
enhancementNew feature or request
Description
Background
Since #1854, InvertedIndexPostingIterator::skip_to gallops over a posting list's decoded doc ids and no longer reads the multi-level skip table (DecodedPostingList::skip_levels, #503). The table is still part of the v2/v3 posting format, and at query time it now only costs:
- Memory. Every decoded posting list keeps it: about one
u32per 7 postings (n/8 + n/64 + …), some 14% of the doc-id array. The posting cache counts it (laurus/src/lexical/index/inverted/posting_cache.rs:43). - Load time.
- The decoder checks a stored table against the doc ids in full on every decode (fix(lexical): return corruption errors instead of panicking in the posting and dictionary decoders #1224).
- Some paths rebuild it from the doc ids:
InvertedIndexPostingIterator::new(reader.rs:171), a cache miss in a segment with deletions (reader.rs:1363), and a v1 segment (core/posting.rs).
Goal
Decide, with measurements, what to do with the table now that no reader uses it:
- keep it in memory as today;
- skip its bytes on decode and keep no copy, still checking its shape, or the whole of it;
- stop writing it in a new format version.
Acceptance criteria
- The memory and the decode time the table costs are measured on the perf(lexical/search): no
BulkScorerinterface for dense AND/OR fast path #588 Phase 0 probe (MS MARCO 1,000,000 passages): the posting cache's size, and a search after the cache is cleared. - The chosen option is implemented, or this Issue is closed with the measurements if the cost is not worth a change.
- Segments of every existing format version stay readable, with the decoder's corruption checks no weaker than the measurements justify.
References
- perf(lexical/index): advance a posting iterator from its current position when the target is near, not from the top of the skip table #1854 (galloping
skip_to), perf(lexical/postings): multi-level skip list for O(log N) posting-list seek #503 (the skip table), fix(lexical): return corruption errors instead of panicking in the posting and dictionary decoders #1224 (the decoder's check), fix(lexical): reject inconsistent on-disk data that the dictionary and posting decoders silently accept #1235 (the ascending check) laurus/src/lexical/index/inverted/core/posting.rs(build_skip_levels,skip_levels_match,DecodedPostingList)laurus/src/lexical/index/inverted/reader.rs,laurus/src/lexical/index/inverted/posting_cache.rslaurus/src/lexical/index/structures/dictionary.rs(the format version in.dict)
Tasks
- Investigation (comment) (perf(lexical/index): decide what to do with the posting skip table now that skip_to does not read it #1858 (comment))
- Plan (comment): the option, and what the decoder still checks (perf(lexical/index): decide what to do with the posting skip table now that skip_to does not read it #1858 (comment))
- Tests that fail on
mainfor the chosen option, and the same results and corruption errors otherwise - The chosen option
- The posting cache's size and the decode time against
mainon the perf(lexical/search): noBulkScorerinterface for dense AND/OR fast path #588 Phase 0 probe, and the CI-equivalent checks - Implementation PR (perf(lexical/index)!: drop a posting list's skip table once the decoder has checked it, so that the posting cache no longer holds a table nothing reads #1897)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
mosuka commentedon Dec 4, 2026
Investigation
Read on
mainat73768e6e, and measured on the #588 Phase 0 probe (MS MARCO, the first 1,000,000 passages) with a prototype of option 2. Nothing reads the skip table at query time. It holds about 4% of the posting cache's bytes and 9.3% of the.postfile. Skipping it on decode freed that 4% and left the decode time within the noise (−3.3% to +0.6% forpostings()alone), with the same hits, scores and totals.What the table still costs
Written for every posting list in the v2 and v3 formats (production always writes v3). The encoder copies the doc ids into a
u32array and builds the table from it (laurus/src/lexical/index/inverted/core/posting.rs:864-892). Its size is about n/7u32s, about 14% of the doc-id array.Read on every decode, which is every posting-cache miss (
posting.rs:1262-1284):Vec<u32>;skip_levels_match,posting.rs:95-107, throughcheck_skip_levels,posting.rs:1221-1235, Issue fix(lexical): return corruption errors instead of panicking in the posting and dictionary decoders #1224);DecodedPostingList::skip_levels(posting.rs:376), and the posting cache counts it (laurus/src/lexical/index/inverted/posting_cache.rs:43-45).Rebuilt from the doc ids:
SegmentReader::filter_deleted_soa,laurus/src/lexical/index/inverted/reader.rs:1379-1380);posting.rs:1485-1489);InvertedIndexPostingIterator::new(reader.rs:177-178) andDecodedPostingList::from_posting_list(posting.rs:442), which build lists from postings in memory.Not read anywhere else:
InvertedIndexPostingIterator::skip_togallops over the doc ids (reader.rs:359-403, Issue perf(lexical/index): advance a posting iterator from its current position when the target is near, not from the top of the skip table #1854);MergedPostingIterator::skip_tocalls its children's;writer.rs:1894-1920).What
skip_torelies on is that the doc ids strictly ascend, whichcheck_ascending_doc_idschecks (Issue fix(lexical): reject inconsistent on-disk data that the dictionary and posting decoders silently accept #1235) apart from the table.What it costs on MS MARCO
The probe built the
one(1 segment) anddefault(100 segments) indexes in 52 s and 42 s, on CPUs 0-7 of an AMD Ryzen AI MAX+ 395 (evo-x2). Measuring hooks were added to the exported trees only (not committed): the bytes the encoder wrote for skip tables, and the posting caches' bytes and skip-table bytes.On disk (the
oneindex, rebuilt withLAURUS_NO_COMPOUND=1to see the.postfile):.postIn the posting cache, after every query of the probe (12 queries, a top-10 search and a count each), with the cache on:
onedefaultThe cache's estimate counts the lists' positions too, which this index stores, so the share of a list without positions is larger.
The decode time. These runs had the posting cache off (
enable_posting_cache: false), so everypostings()decodes:reader.postings()alone for one-term queries (postings), and a top-10 search (none). Each probe run made 21 repetitions; the table gives medians over 6 runs per side (ABBA, 3 rounds), at a load average of 3.10 to 3.65.main(µs)oneone(df 112,650)postingsonepeople(df 50,663)postingsoneamerican(df 19,475)postingsoneonenoneoneonepeoplenoneonealsomayusednonedefaultonepostingsdefaultpeoplepostingsdefaultamericanpostingsdefaultamericannonedefaultonepeoplenoneEvery difference is within this host's noise floor (±3 to 9%), so the table's reading and checking do not show against the rest of the decode.
The results. For the 12 queries on both indexes, the top-10 hits with their scores' bits (with no total, and with an exact one), the exact totals and the counts were the same on both sides.
Not measured: the write-side cost (the copy and the build per posting list at flush and merge time). Option 3 is the only one that removes it.
The options
.poston diskOpen points for the plan
.postand the write-side work, but it is a format change: an older laurus could not read the segments it writes.skip_to, which does not read it.DecodedPostingList::skip_levelsis a public field of a public type. Removing it is a breaking change; leaving it always empty is not, but keeps a field that means nothing.mosuka commentedon Dec 4, 2026
Plan
Per the investigation, option 2: the decoder skips the skip table and keeps no copy of it, and the writer keeps writing it. The posting cache frees about 4% of its bytes (MS MARCO); the decode time did not change measurably in the prototype.
Scale L, on evo-x2 (Linux). Windows and aarch64 Linux are left to the CI's
Test laurusjobs.Decisions
seek, not compared.DecodedPostingList::skip_levelsis removed, a breaking change to a public type, so the title carries a!.The shape
skip_level_shape(n), bound what is skipped. The entries are not used, so they are not checked: a damaged entry cannot change a result. Whatskip_torelies on, strictly ascending doc ids, stays checked (Issue fix(lexical): reject inconsistent on-disk data that the dictionary and posting decoders silently accept #1235).StructReader::seekends the reader's running checksum, but a segment's checksums are verified per file, through a separate read (verify_file_checksum), so a seek inside a decode does not weaken them.Changes
laurus/src/lexical/index/inverted/core/posting.rs:decode_doc_idsreads the level count and each level's length, bounded by the bytes left withchecked_capacity_u64as now, and seeks past the entries. Once the doc ids are decoded, a sequence of lengths other thanskip_level_shape(n)is the same "segment is corrupted" error as now.DecodedPostingList::skip_levels,DecodedDocIds::skip_levels,skip_levels_match,check_skip_levels, the v1 rebuild indecode_soa_inner, and the build inDecodedPostingList::from_posting_list.build_skip_levelsandskip_level_shape, which the writer and the shape check use.laurus/src/lexical/index/inverted/reader.rs:InvertedIndexPostingIterator::newandSegmentReader::filter_deleted_soano longer build a table; the test helper drops the field.laurus/src/lexical/index/inverted/posting_cache.rs:estimated_bytesno longer adds the table; its doc and test follow.laurus/benches/posting_skip_to_bench.rs: its list helper drops the table. The bench timesskip_to, which does not read it.concepts/indexing/lexical_indexing.md, "Multi-Level Skip Table": the decoder checks the levels' lengths, skips the entries and keeps no table (Issue perf(lexical/index): decide what to do with the posting skip table now that skip_to does not read it #1858); v1 segments no longer have one rebuilt.concepts/search/lexical_search.md, the posting cache: the decode no longer includes the skip table.Tests, written first
posting_cache.rs): for a list written as v3 and decoded,estimated_bytesis the sum of the doc ids, frequencies, positions, term and struct, with no table. Onmainthe table adds to it, so it fails.posting.rs): a v3 list with one table entry changed decodes to the same doc ids, frequencies and positions as before. Onmainit is rejected ("does not match").posting.rs; the existing tests stay):posting.rs):every_written_skip_table_matches_its_doc_idsreads the written table from the encoded bytes through a test helper instead of the decoded field. For every n from 0 to 4,200, it still equalsbuild_skip_levels.cmp. cargo is stopped with its whole process group on a time limit.estimated_bytescounts the level lengths; the exact form is fixed with the test.Verification
--all-targets --features embeddings-all, and the wasm clippy;embeddings-all,pq-fastscan), the server, MCP and the CLI;check-rustdoc.py;check-ci-filters.py,check-job-timeouts.pyand their tests;check-binding-snippets.py;posting_skip_to_benchbuilds and runs (cargo bench --no-run, and one short run).mainagainst the change, as ABBA over 3 rounds on CPUs 0-7, with the load average recorded, on the investigation's probe and indexes (the format is the same on both sides):postings(), cache off) and a top-10 search, on theoneanddefaultindexes. Expected: no difference.Out of scope