feat(segcache): add is_deleted tombstone flag and ItemGuard trait#20
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Adds DELETE_MASK (0b0100_0000), is_deleted()/set_deleted() methods to BasicHeader, forwards them on RawItem, updates Debug impl, and adds 3 unit tests covering roundtrip, flag independence, and non-interference. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… ItemGuard impl Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…er ItemGuard impl
…tions Reverts ItemHeader→BasicHeader, ITEM_HDR_SIZE→BASIC_HDR_SIZE, and the method renames (klen→key_len, vlen→value_len, olen→optional_len). These renames inflated the diff across 10 files without clearing any copyright; they can land separately when the full crucible item architecture is ported. The is_deleted flag, DELETE_MASK, and ItemGuard trait additions are kept. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Local Claude Code settings are machine-specific and should not be committed to the repository. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…n loops compact(), copy_into(), s3fifo_promote_from(), s3fifo_ghost_remaining(), and check_integrity() all iterated items by calling get_item_frequency() to detect dead items. Add is_deleted() short-circuit before the hashtable lookup in each loop. Also fixes a double get_item_frequency() call in s3fifo_promote_from() that was querying the hashtable twice for the same item. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Motivation
Segment::prune()had no fast-path for explicitly-deleted items — every item required a hashtable lookup during merge/compaction scans, even items already removed from the hashtable bydelete(). There was also no trait boundary for cache lookup results, making it hard to build concurrent access on top.What changed
is_deletedflag (bit 6 of the flags byte) toItemHeader, withis_deleted()/set_deleted()accessors surfaced onItemHeader,RawItem, andItemset_deleted(true)intoSegcache::delete()so the item is tombstoned in segment memory immediately after hashtable removalis_deleted()fast-path toSegment::prune()so tombstoned items skip the hashtable lookup entirely during merge/compaction scansItemGuard<'a>: Sendtrait tokeyvalueas the interface contract for cache lookup results (concreteBasicItemGuardimpl deferred until ref-counted segment guard work lands)Result
Segcache::delete()now leaves a tombstone thatprune()uses to skip redundant hashtable probes on already-dead items.ItemGuardestablishes a stable trait boundary for future concurrent access work.