Skip to content

Fix index lookups of the randstrobe with the smallest hash - #661

Merged
marcelm merged 1 commit into
mainfrom
fix-bucket-starts
Oct 15, 2026
Merged

marcelm merged 1 commit into
mainfrom
fix-bucket-starts

Conversation

@ksahlin

@ksahlin ksahlin commented Oct 15, 2026

Copy link
Copy Markdown
Owner

When bucket 0 is empty (roughly 2–13% of indexes, including phiX), make_index set bucket_starts for the buckets up to and including the first randstrobe's bucket to the position of the second distinct hash. As a result, the randstrobe with the smallest hash could never be found.

The fix fills those entries with 0 instead. A new test checks that every hash in the phiX index can be looked up; it fails on main. The .sti format version is bumped because existing index files contain the incorrect values.

Mapping output is unchanged on phiX, chrY, fruit fly, maize and Mo17.

bucket_starts[x] is supposed to be the index of the first randstrobe
whose bucket (the top bits of its hash) is x or greater. When building it,
we pushed a single 0 for the first randstrobe and then, for each new
distinct hash, padded the vector up to that hash's bucket with the current
position.

If the first randstrobe is not in bucket 0 (that is, bucket 0 is empty),
the entries from 1 up to the bucket of the first randstrobe were therefore
set to the position of the *second* distinct hash. A lookup of the
smallest hash then searches a range that starts after it and never finds
it. With the default number of bits, there are between two and four
randstrobes per bucket on average, so this happens for roughly 2-13% of
indexes, including the one for phiX.

Fix this by filling bucket_starts with 0 up to and including the bucket of
the first randstrobe.

Existing .sti files contain the incorrect bucket_starts, so the file
format version is bumped to force re-generating them.
Comment thread CHANGES.md
Comment on lines +6 to +8
* #661: Fix a bug in index construction that, for some references, made the
randstrobe with the smallest hash value impossible to find.
Pre-generated index files (`.sti` files) need to be re-generated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I would probably not write a changelog entry for this. The changelog to me is for users to read about changes relevant to them, and it is very likely that no user has ever been affected by this. If anyone wants to know every change, they can read the Git history.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll go through the changelog anyway before making the next release. I’ll maybe remove that bullet point then, but let’s leave it in for now.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that makes sense!

@marcelm
marcelm merged commit fda1593 into main Oct 15, 2026
7 checks passed
@marcelm
marcelm deleted the fix-bucket-starts branch October 15, 2026 11:14
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