perf(storage): Reduce block recovery index overhead - #1296
Open
leiysky wants to merge 3 commits into
Open
Conversation
leiysky
force-pushed
the
dev/optimize-block-recovery
branch
from
May 24, 2026 12:24
9a40c0e to
aa42eac
Compare
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
leiysky
force-pushed
the
dev/optimize-block-recovery
branch
from
May 24, 2026 12:44
aa42eac to
f3c6f7b
Compare
leiysky
marked this pull request as ready for review
May 24, 2026 12:45
There was a problem hiding this comment.
Pull request overview
This PR optimizes block-engine recovery by eliminating a recovery-local global dedup table and instead streaming recovered entries directly into the in-memory indexer, relying on the indexer’s existing sequence-based deduplication. It also improves indexer batch insertion efficiency and introduces a custom hasher for indexer shards.
Changes:
- Remove recovery-local
HashMapdedup and insert recovered entries into theIndexerincrementally during scanning. - Apply recovered tombstones via a batched
Indexer::remove_batchcall after entry insertion. - Optimize
Indexer::insert_batchsharding/batching and switch shard maps toModHasher.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
foyer-storage/src/engine/block/recover.rs |
Streams recovered entries into the indexer per block and batches tombstone removals; adjusts recovery logging. |
foyer-storage/src/engine/block/indexer.rs |
Changes shard map hasher to ModHasher and rewrites insert_batch to pre-bucket by shard and reserve capacity per shard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: leiysky <leiysky@outlook.com>
leiysky
force-pushed
the
dev/optimize-block-recovery
branch
from
July 26, 2026 12:15
f3c6f7b to
83dd4cc
Compare
Signed-off-by: leiysky <leiysky@outlook.com>
leiysky
force-pushed
the
dev/optimize-block-recovery
branch
from
July 26, 2026 12:16
83dd4cc to
7d97e68
Compare
Signed-off-by: leiysky <leiysky@outlook.com>
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
HashMapand install recovered entries directly into the block indexer.ModHasher, tombstone prefiltering, and post-dedup compaction.buffer_unordered, then restore their original order before error aggregation and index installation.RecoverMode::Nonewithout scanning block contents.Semantics and Compatibility
This change is internal to recovery: it does not change the public API or the on-disk format.
The upstream recovery behavior is preserved:
sequence >= current.sequence()rule.unwrap()behavior.Performance
Benchmarks used temporary local harnesses; no benchmark-only code is included in this PR.
End-to-end recovery
Workload: 300,000 forced on-disk entries, 512-byte values, 30 reopens with
RecoverMode::Quiet; the first reopen verifies representative keys.9c24c8d)33.652 msf3c6f7b)19.664 ms1.71xfaster than that main snapshotf3c6f7b)19.609 ms~9.80 ms~2.0xfaster than the previous PR head100M-entry scaling
The original synthetic index-installation benchmark plateaued at approximately
3.3 sfrom concurrency 4 onward, showing that allocation, hash-table insertion, and memory bandwidth dominate beyond that point.After adding bounded batching, a temporary 8-worker sanity run installed 100 million streamed unique entries in
1.41 s(entry generation included; device scanning and final compaction excluded). This is not an apples-to-apples comparison with the original harness because the input-retention strategy differs; it is only a regression check for the new batching path.Memory and Tradeoffs
64 MiBin total instead of scaling with the entire recovered-entry set.recover_concurrency.scanned entriesfrom compactedlive entries.Review Follow-ups
ModHasherinside each shard.Validation
cargo fmt --all -- --checkgit diff --checkcargo check -p foyer-storage --libcargo test -p foyer-storage— 24 passedcargo clippy -p foyer-storage --all-targets -- -D warnings -A dead-code