Skip to content

feat(segcache): add is_deleted tombstone flag and ItemGuard trait#20

Merged
brayniac merged 14 commits into
pelikan-io:mainfrom
brayniac:brayniac/port-item-design
Jun 11, 2026
Merged

feat(segcache): add is_deleted tombstone flag and ItemGuard trait#20
brayniac merged 14 commits into
pelikan-io:mainfrom
brayniac:brayniac/port-item-design

Conversation

@brayniac

@brayniac brayniac commented May 26, 2026

Copy link
Copy Markdown
Contributor

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 by delete(). There was also no trait boundary for cache lookup results, making it hard to build concurrent access on top.

What changed

  • Added is_deleted flag (bit 6 of the flags byte) to ItemHeader, with is_deleted() / set_deleted() accessors surfaced on ItemHeader, RawItem, and Item
  • Wired set_deleted(true) into Segcache::delete() so the item is tombstoned in segment memory immediately after hashtable removal
  • Added is_deleted() fast-path to Segment::prune() so tombstoned items skip the hashtable lookup entirely during merge/compaction scans
  • Added ItemGuard<'a>: Send trait to keyvalue as the interface contract for cache lookup results (concrete BasicItemGuard impl deferred until ref-counted segment guard work lands)

Result

Segcache::delete() now leaves a tombstone that prune() uses to skip redundant hashtable probes on already-dead items. ItemGuard establishes a stable trait boundary for future concurrent access work.

@brayniac brayniac changed the title Port crucible item design: rename BasicHeader, add is_deleted, clear Twitter copyright Port crucible item design: rename BasicHeader, add is_deleted May 26, 2026
brayniac and others added 2 commits May 26, 2026 16:38
…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]>
@brayniac brayniac requested a review from thinkingfish May 27, 2026 04:54
@brayniac brayniac changed the title Port crucible item design: rename BasicHeader, add is_deleted refactor: ItemHeader gains tombstone and groundwork for refcounted ItemGuard May 27, 2026
@brayniac brayniac changed the title refactor: ItemHeader gains tombstone and groundwork for refcounted ItemGuard add is_deleted tombstone and ItemGuard; rewrite item files copyright-clean May 28, 2026
@brayniac brayniac changed the title add is_deleted tombstone and ItemGuard; rewrite item files copyright-clean add is_deleted tombstone flag and ItemGuard trait May 28, 2026
@brayniac brayniac changed the title add is_deleted tombstone flag and ItemGuard trait feat(segcache): add is_deleted tombstone flag and ItemGuard trait May 28, 2026
…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]>
@brayniac brayniac merged commit 58ebb77 into pelikan-io:main Jun 11, 2026
4 checks passed
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.

1 participant