perf(store): single-allocation blob entry - collapse the 2.4x memory gap to parity (round 3)#263
Merged
Conversation
…gap (round 3) The big lever. Replace the per-shard HashMap<Box<[u8]>, KvObj> (3 allocations per key + a duplicated key + an 80 B slot) with hashbrown::HashTable<Entry> (the low-level explicit-hash API, no key duplication) where Entry is a SINGLE allocation: Str(Box<[u8]>) packing [type|enc|flags|ttl?|key_len|key|value] for strings, or Coll(Box<CollEntry>) for collections. One allocation per string key; table slot 80 -> 16. Confined to ironcache-store internals; the ironcache-storage Store waist (read/upsert/delete/rmw, ValueRef, RmwEntry, the collection side-traits) is unchanged, so no other crate changes. SCAN keeps the deterministic scan_hash band-aligned cursor; TTL lives in the blob header; eviction/accounting/WATCH unchanged. SAFE: no unsafe (the crate stays #![forbid(unsafe_code)]); the blob is parsed with bounds-checked slicing + from_le_bytes. Measured vs redis 8.8.0 (head-to-head, 300k keys): bytes-per-key 386.85 -> 221.5 for 128B values (gap 1.77x -> 1.01x, NEAR PARITY), and 291 -> 121 for 32B values (2.88x -> 1.20x). memmodel table slack 125.8 -> 26.2 B/key. Whole-workspace tests green (840 passed); qps within the prior round's noise band. See docs/bench/OPTIMIZATION_LOG.md round 3. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Zeke <ezequiel.lares@outlook.com>
perf-gate (A5)Same-runner ratchet of HEAD against the merge-base (both rebuilt and measured in this job).
Overall: PASS
|
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.
The big memory lever. Replace the per-shard
HashMap<Box<[u8]>, KvObj>(3 allocations/key + a duplicated key + an 80 B slot) withhashbrown::HashTable<Entry>(low-level explicit-hash API, no key duplication) whereEntryis a SINGLE allocation:Str(Box<[u8]>)packing[type|enc|flags|ttl?|key_len|key|value], orColl(Box<CollEntry>). One allocation per string key; table slot 80 -> 16 B.Measured vs redis 8.8.0 (head-to-head, 300k keys): bytes-per-key 386.85 -> 221.5 for 128B (gap 1.77x -> 1.01x, parity), 291 -> 121 for 32B (2.88x -> 1.20x). memmodel table slack 125.8 -> 26.2. Memory went from 2.4x behind to dead-even with the latest Redis.
Confined to
ironcache-storeinternals; the Store waist + ValueRef/RmwEntry/side-traits unchanged (no other crate changes). SCAN keeps the deterministicscan_hashcursor; TTL in the blob header; eviction/accounting/WATCH preserved. Zerounsafe(bounds-checked blob slicing). All 840 workspace tests green; a 4-lens adversarial review (blob-parse, table/rmw, SCAN/TTL/accounting, encoding/determinism) found 0 issues.Next to clearly win memory: a thin pointer (slot 16->8 + cached hash). The perf-gate runs on this PR and will show the memory drop (and adjudicate qps, which is within the prior round's noise band).
🤖 Generated with Claude Code