Repository navigation
perf: reuse L1 allocations and avoid contention-driven flushes - #66
Merged
Merged
Conversation
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.
Summary
Foreground staging no longer treats lock collisions as buffer pressure. Retain Region capacity requests through the final write, including when staging is full and its next flush requires alignment padding, so one capacity rejection is enough to trigger flush and rotation. A staging record-count limit only rotates when the next record cannot fit; duplicate wakes leave the new Region idle.
Reuse detached, exclusively owned L1 allocations of the exact size and skip eviction-counter updates when no eviction occurred. Caller-held values remain immutable and retain their memory charge. Count
CacheSnapshot::served_bytesfrom the final returned value after L2 promotion, including when a concurrent publication supplies a newer L1 value of a different size.Regression coverage includes CLOCK/S3-FIFO ownership and accounting, concurrent publication and final-owner drops, full buffers, automatic rotation, fixed routing after reclaim, and warm reopen. Permanent boundary tests cover 1,152 alignment/rotation combinations, 12 staging exact-fit/overflow cases, and 16 promotion/retained-charge cases, including empty values and statistics on/off.
Validation
cargo x checkcargo x test: 369 Rust tests, including extended tests and doctestscargo test --workspace --release --all-features: 367 testscargo x lint: all checks pass, including dependency advisories with main's Tokio 1.54.1 update (chore: bump tokio to 1.54.1 for security fixes #65)git diff --check579c1dd, including Linux/macOS on Rust 1.98.0 and stable, AddressSanitizer, ThreadSanitizer, and the Required gateTargets current
maindirectly. Benchmark harness and comparison tooling are in #67.