Skip to content

Build inverted lists without per-centroid hash sets - #2

Merged
SilvioM97 merged 1 commit into
TusKANNy:mainfrom
anirudhlakhotia:two-pass-posting-lists
Sep 4, 2026
Merged

SilvioM97 merged 1 commit into
TusKANNy:mainfrom
anirudhlakhotia:two-pass-posting-lists

Conversation

@anirudhlakhotia

@anirudhlakhotia anirudhlakhotia commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

In Tachiom::from_parts, inverted lists are currently built by inserting document IDs into one FxHashSet per 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.

@anirudhlakhotia
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 anirudhlakhotia changed the title Build postings without per-centroid hash sets Build inverted lists without per-centroid hash sets Aug 25, 2026
@SilvioM97
SilvioM97 merged commit 230b983 into TusKANNy:main Sep 4, 2026
@SilvioM97

Copy link
Copy Markdown
Contributor

Thanks for the contribution Anirudh! Merged.

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.

2 participants