Repository navigation
Fix: Rehash slot_lookup_ tombstones to stop ghost entries under churn - #769
Merged
Merged
Conversation
`remove` marks a slot deleted but leaves it populated, so probes walk past it. The resize decision only counted live entries, and under `remove`+`add` churn the live count stays flat, so the table never grew and never rehashed. Tombstones accumulated until no empty slot remained; probes could then no longer terminate, `equal_range` returned `end()` for a key that was still live, and `remove` took the empty-range branch reporting nothing removed. The entry became a ghost: `contains` kept finding it, `remove` silently no-oped, and `size()` drifted above the true live count. Count tombstones toward the load factor so churn triggers a rehash, which reclaims them in place when the live count does not warrant growth. The copy constructor and copy assignment had the same defect from the other side. They re-placed live entries at their original slot indices and dropped tombstones, which silently breaks probe chains: an entry displaced past a tombstone becomes unreachable once that slot reads empty. Both now share one `rehash_into` helper with `try_reserve`, so entries are always re-probed from their hash into a zeroed table and chains are rebuilt rather than reproduced. That is the only way entries move between tables now. `test_slot_lookup_churn` covers both paths and fails against the previous code.
ashvardanian
force-pushed
the
feat/ghost_repro
branch
from
July 10, 2026 14:52
4f97393 to
7bb4803
Compare
Member
|
Thank you, @desertfury! Sorry it took a bit of time. I'm finalising new NumKong/StringZilla/ForkUnion releases to feed into USearch v3 🤗 |
ashvardanian
pushed a commit
that referenced
this pull request
Jul 10, 2026
### Minor - Add: Expose `stats()` in Rust SDK (#768) (3713af9) - Add: Rust compact binding (#771) (749d03b) ### Patch - Make: Modernize CI toolchains, pin cibuildwheel (017fad3) - Fix: Reclaim `slot_lookup_` tombstones under churn (#769) (c6d634c) - Fix: Mix integer key hashes with SplitMix64 (#773) (9fc3500) - Make: Build JavaScript Windows x64 prebuilds (#774) (7240652) - Make: Bundle NumKong runtime with C# native artifacts (9c0ed29)
titusz
pushed a commit
to iscc/usearch
that referenced
this pull request
Aug 3, 2026
`remove` marks a slot deleted but leaves it populated, so probes walk past it. The resize decision only counted live entries, and under `remove`+`add` churn the live count stays flat, so the table never grew and never rehashed. Tombstones accumulated until no empty slot remained; probes could then no longer terminate, `equal_range` returned `end()` for a key that was still live, and `remove` took the empty-range branch reporting nothing removed. The entry became a ghost: `contains` kept finding it, `remove` silently no-oped, and `size()` drifted above the true live count. Closes unum-cloud#753 Co-Authored-By: Misha Chichvarin <[email protected]> Co-Authored-By: Ash Vardanian <[email protected]> (cherry picked from commit c6d634c)
titusz
added a commit
to iscc/usearch
that referenced
this pull request
Aug 3, 2026
…() fixes Cherry-picks from upstream unum-cloud/usearch: - Mix integer key hashes with SplitMix64 (unum-cloud#773) - Bounded probe in equal_iterator_gt::operator++ - Preserve hash lookup capacity across thread reserves (unum-cloud#765) - Keep vectors_lookup_ capacity after clear() (unum-cloud#759) - Reclaim slot_lookup_ tombstones under churn (unum-cloud#769) Fork fixes: - Rebuild key lookups after compact(), preserve the nodes buffer capacity, and abort cleanly on progress cancellation (#9)
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.
Problem
b779c47 (#753) bounded the saturated probe but left tombstones unreclaimed, turning the CPU-spin hang into silent ghost keys.
Fix
Track tombstones and rehash to reclaim them before saturation, so live keys stay findable under churn.
Tests
cpp/ghost_repro.cppnow asserts zero ghosts; previously it leaked 1616 at a tight reserve.