Repository navigation
Conversation
table_erase_kernel reset only score word 0 of the erased slot. On a
two-word {TIMESTAMP, LFU} (LruLfu) table the reclaimed slot kept the
erased key's frequency in word 1. reduce_ranked() ranks reclaimed slots
by (frequency, timestamp) like live keys, so a stale high frequency made
the free slot lose to live low-frequency keys: the next insert into the
bucket evicted a live key while the free slot stayed unused and the
bucket size counter stayed one short.
Clear the whole AoS-contiguous score block, the same loop insert()
already runs on its Reclaim and Evict branches. Single-word tables are
unaffected: word 0 is the only word and ScoreType() is the global
minimum, so the reclaimed slot was always picked first.
Test: fill one bucket at frequency 1, raise key 1 to frequency 5, erase
it, insert one new key with insert_and_evict; assert no eviction, size
back to capacity, every other original key still present, and the new
key's block is [fresh timestamp, 1]. Fails before the fix (a live key is
evicted) and passes after, on an H100.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Jingping Yuan <[email protected]>
Contributor
Author
|
Test results, from-source build of this branch (
Not run: the 7 |
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR clears every score word when erasing a key, so a reclaimed
Reviews (1) · Last reviewed commit: "fix(dynamicemb): clear every score word ..." · Reviewed by Greptile |
jiashuy
self-requested a review
October 29, 2026 07:40
Collaborator
|
resolve conflicts in #523 and merged |
3 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.
Description
table_erase_kernelresets only score word 0 of the erased slot. On a two-word{TIMESTAMP, LFU}(LruLfu) table the reclaimed slot keeps the erased key's frequency in word 1.reduce_ranked()ranks reclaimed slots by(frequency, timestamp)exactly like live keys, so a stale high frequency makes the free slot rank worse than live low-frequency keys. The next insert into that bucket evicts a live key while the free slot stays unused, and the bucket's size counter stays one short.Single-word tables (LFU, LRU, STEP, CUSTOMIZED) are unaffected: word 0 is the only word and
ScoreType()is the global minimum, so the reclaimed slot is always picked first.Fix: clear the whole AoS-contiguous score block in
table_erase_kernel, the same loopinsert()already runs on its Reclaim and Evict branches. No Python change.Test:
test_lru_lfu_erase_reclaimed_slot_is_reused_before_evicting_live_keysfills one 128-slot bucket at frequency 1, raises key 1 to frequency 5 via anLRU_LFUlookup, erases it, then inserts one new key withinsert_and_evict, and asserts no eviction, size back to 128, every other original key still present, and the new key's score block is[fresh timestamp, 1].The existing
test_lru_lfu_insert_after_erase_no_phantom_frequencydid not catch this because its stale frequency equals every live key's frequency, so the reclaimed slot won on the timestamp tie-break. Its docstring is updated to describe what it covers (the Reclaim clear ininsert()), and it is kept.Test results (before/after on an H100) will be posted in a follow-up comment.
Related: #508 (ranked evictor on every insert path for LruLfu tables) is the sibling LruLfu fix; this PR is independent of it.
Checklist
🤖 Generated with Claude Code