Build inverted lists without per-centroid hash sets - #2
Merged
Merged
Conversation
anirudhlakhotia
marked this pull request as ready for review
August 25, 2026 05:56
Use a two-pass count-and-write construction for inverted lists instead of accumulating per-centroid FxHashSets. Inverted-list membership is unchanged; build time and transient memory both drop.
anirudhlakhotia
force-pushed
the
two-pass-posting-lists
branch
from
August 25, 2026 06:02
f9d5002 to
ae92af2
Compare
Contributor
|
Thanks for the contribution Anirudh! Merged. |
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.
In
Tachiom::from_parts, inverted lists are currently built by inserting document IDs into oneFxHashSetper centroid and then flattening the sets into the final flat array. With millions of centroids, inserts turn into scattered memory accesses, and flattening keeps both representations alive at once.We now build the lists in two passes: deduplicate centroid IDs per document, count each inverted list, then write document IDs straight into their final slots. At 266M tokens and 2.1M centroids, this is about 2.1–2.5x faster on native hardware and uses roughly 2.6 GiB less transient memory
Per-centroid document membership is unchanged. Inverted lists now come out ordered by document ID rather than hash iteration order. Search behaviour is unchanged, but the serialized inverted-list order differs from indexes built with the old implementation.
There's a small regression test covering dedup, ordering, an empty document, and empty inverted lists.