perf(storage): add shared RocksDB block cache and row cache#6195
perf(storage): add shared RocksDB block cache and row cache#6195azteca1998 wants to merge 1 commit intomainfrom
Conversation
Add a shared 512 MB LRU block cache across all column families and a 128 MB row cache on the DB options. Previously each CF used RocksDB's default 8 MB per-CF cache, meaning the system relied almost entirely on the OS page cache for read performance. A single shared block cache allows hot data from any CF to benefit from the full cache budget, which is the single most impactful RocksDB tuning knob for read-heavy workloads. The row cache adds an additional layer that caches entire key-value pairs, avoiding block decompression overhead for frequently accessed entries. No resync required — this is a runtime configuration change.
🤖 Kimi Code ReviewReview SummaryThis PR adds RocksDB caching optimizations to improve performance. While the changes are generally good, there are a few issues to address: Critical Issues
Performance Concerns
Code Quality Issues
Suggested Fixes// In RocksDBBackend struct
pub struct RocksDBBackend {
db: DBWithThreadMode<MultiThreaded>,
block_cache: Cache,
row_cache: Cache,
}
// In open method
let block_cache = Cache::new_lru_cache(512 * 1024 * 1024)
.ok_or(StoreError::Custom("Failed to create block cache".to_string()))?;
let row_cache = Cache::new_lru_cache(128 * 1024 * 1024)
.ok_or(StoreError::Custom("Failed to create row cache".to_string()))?;
opts.set_row_cache(&row_cache);
// Store caches in the struct
Ok(Self {
db,
block_cache,
row_cache,
})The caching strategy itself looks appropriate for an Ethereum client, with different configurations for different column families based on their access patterns. Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewFindings (ordered by severity)
Rust / correctness / Ethereum-specific If you can confirm the cache lifetime semantics in rocksdb, I’m happy to re-review with that context. Automated review by OpenAI Codex · custom prompt |
Lines of code reportTotal lines added: Detailed view |
🤖 Claude Code ReviewNow let me review the PR and provide my findings in markdown format. PR Review: Add Shared RocksDB Block Cache and Row CacheOverviewThis PR adds a shared 512 MB LRU block cache and 128 MB row cache to improve read performance for the RocksDB storage backend. The changes are runtime configuration only and don't require a resync. ✅ Positive Findings
|
Add a shared 512 MB LRU block cache across all column families and a 128 MB row cache on the DB options.
Previously each CF used RocksDB's default 8 MB per-CF cache, meaning the system relied almost entirely on the OS page cache for read performance. A single shared block cache allows hot data from any CF to benefit from the full cache budget, which is the single most impactful RocksDB tuning knob for read-heavy workloads.
The row cache adds an additional layer that caches entire key-value pairs, avoiding block decompression overhead for frequently accessed entries.
No resync required — this is a runtime configuration change.
Motivation
Description
Checklist
STORE_SCHEMA_VERSION(crates/storage/lib.rs) if the PR includes breaking changes to theStorerequiring a re-sync.