Repository navigation
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
Merged
Conversation
…er has checked it, so that the posting cache no longer holds a table nothing reads Since Issue #1854, `skip_to` gallops over the decoded doc ids and no longer reads a posting list's multi-level skip table. The decoder still kept the table in `DecodedPostingList::skip_levels`, the posting cache counted it, and a segment with deletions or a v1 segment had it rebuilt. The decoder now reads the table only to check it against the doc ids, as before (Issue #1224), and drops it. The table is no longer rebuilt after deletion filtering, for v1 segments, or by `from_posting_list` and `InvertedIndexPostingIterator::new`. The writer still writes the v3 table, which an older laurus checks. BREAKING CHANGE: `DecodedPostingList::skip_levels` is removed.
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1858
Since Issue #1854,
skip_togallops over the decoded doc ids and no longer reads a posting list's multi-level skip table, yet the decoder kept the table in every decoded list, the posting cache counted it, and segments with deletions or in the v1 format had it rebuilt. The decoder now checks the table against the doc ids as before (Issue #1224) and drops it. On the #588 Phase 0 probe (MS MARCO, the first 1,000,000 passages), the posting cache holds 4.2 to 4.3% fewer bytes for the same lists, with the same hits, scores and totals. The writer still writes the v3 table, which an older laurus checks.DecodedPostingList::skip_levels, a public field, is removed, hence the!.Changes
laurus/src/lexical/index/inverted/core/posting.rs:decode_doc_idsstill reads the table into a localVec<Vec<u32>>and checks it withskip_levels_match; it then drops it instead of handing it on.DecodedPostingList::skip_levels,DecodedDocIds::skip_levels, the v1 rebuild indecode_soa_inner, and the build inDecodedPostingList::from_posting_list.laurus/src/lexical/index/inverted/reader.rs:InvertedIndexPostingIterator::newandSegmentReader::filter_deleted_soano longer build a table; comments follow.laurus/src/lexical/index/inverted/posting_cache.rs:estimated_bytesno longer adds the table.laurus/benches/posting_skip_to_bench.rs: its list helper no longer builds a table; the bench timesskip_to, which does not read it.concepts/indexing/lexical_indexing.md, "Multi-Level Skip Table": the decoder reads the table only to check it, then drops it, and the posting cache holds none; v1 segments are read without one.concepts/search/lexical_search.md: the posting cache's decode no longer lists the skip table.Not as planned
The plan had the decoder check only the levels' lengths and seek past the entries. The adversarial review showed two things, and with the user's approval the decoder checks every entry as before, still without keeping the table:
.postchecksum, and its term would match other documents meanwhile.LAURUS_NO_MMAP=1, a compound file's handle window),seekdiscards the reader's buffer at every level.The tests changed accordingly:
Tests
a_decoded_list_is_estimated_without_a_skip_table(posting_cache.rs)mainthe table adds to it, so it fails there.every_written_skip_table_matches_its_doc_ids(posting.rs, changed)encode_v3writes, read from the bytes, equals the reference table, and the decoder accepts the list with the same doc ids. It used the decoded field before.test_round_trip_v2_writes_the_skip_table(posting.rs, changed)build_skip_levelsbuilds (at least two levels).test_v1_decodes_without_a_skip_table(posting.rs, changed)a_skip_level_of_the_wrong_length_is_rejected(posting.rs, new)The existing corruption tests (a level longer than the file, too many levels, a table on an empty list, a wrong entry, a wrong entry when the doc ids are read alone) pass unchanged.
RED. Each element was put back to a wrong form, the posting and posting-cache tests run, and the source restored and compared with
cmp:Checks
The CI's checks, run locally on Linux x86_64 (evo-x2) with stable 1.100.1 on
1b59f23d(this change rebased on9730730e):cargo fmt --all -- --check--all-targets --features embeddings-all -- -D warningslaurus-wasmclippy forwasm32-unknown-unknown,--testsscripts/check-rustdoc.pyscripts/check-ci-filters.py,check-job-timeouts.pyand their testsscripts/check-binding-snippets.pylaurustests (embeddings-all,pq-fastscan)laurus-server,laurus-mcp,laurus-clitests (embeddings-all)posting_skip_to_bench, once in test modeCI
Run 47352740901 on
1b59f23d: all 29 jobs passed, Binding Snippets included (the docs changed). The five new and changed tests passed in theTest laurusjobs on Linux x86_64, Linux aarch64 and Windows, which passed 4,262, 4,229 and 4,230 tests with none failed.Measurements
Instructions
The #588 Phase 0 probe (not committed) builds indexes of the first 1,000,000 MS MARCO passages,
one(one segment) anddefault(100 segments), shared by both sides as the format does not change. Hooks added to the exported trees only report the posting caches' bytes and skip-table bytes.enable_posting_cache: false), so that everypostings()decodes,reader.postings()alone for one-term queries (postings) and a top-10 search (none). Each run made 21 repetitions; the tables give medians over 6 runs per side (ABBA, 3 rounds).main's binary, to show this host's spread.The posting cache
mainbytesonedefaultThe rest of the difference is the field's own
Vecheader in each cached list.The decode
main(µs)onepostingsonepostingsonepostingsonenoneonenoneonenoneonenoneonenonedefaultpostingsdefaultpostingsdefaultpostingsdefaultnonedefaultnonedefaultnonedefaultnonedefaultnoneOn the
oneindex the change's runs were 0.5 to 3.8% slower; between the two copies ofmain's binary, the same order gave +0.3 to +2.1% there, and −7.9 to +2.1% over all the cells. The largest list (one, 112,650 postings) was 3.6 to 3.8% slower on both indexes, so its decode alone was measured again over 5 rounds of 51 repetitions (10 runs per side): +0.3% ononeand +0.9% ondefault, with overlapping ranges, against +0.0% and +0.4% between the two copies ofmain's binary. The change does strictly less work there: the same reads and the same check, without keeping the table.Not done