Skip to content

Commit 412d770

Browse files
committed
tune rocksdb block cache default to 12GiB
1 parent 6e3af68 commit 412d770

2 files changed

Lines changed: 19 additions & 42 deletions

File tree

cmd/ethrex/cli.rs

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,43 +101,20 @@ pub struct Options {
101101
long = "rocksdb.block-cache-size",
102102
value_name = "BYTES",
103103
default_value_t = ethrex_storage::DEFAULT_ROCKSDB_BLOCK_CACHE_SIZE_BYTES,
104-
help = "RocksDB shared block cache size in bytes (default 20 GiB). \
105-
Lowering this degrades block-import throughput; see --help for details.",
106-
long_help = "RocksDB shared block cache size in bytes. This single bounded LRU cache \
107-
holds both data blocks AND the per-SST index and bloom-filter blocks \
108-
needed to look them up. Because ethrex enables cache_index_and_filter_blocks, \
109-
this value is the effective upper bound on RocksDB's resident memory footprint.\n\
104+
help = "RocksDB shared block cache size in bytes (default 12 GiB). \
105+
Bounds RocksDB resident memory; lower only on memory-constrained hosts.",
106+
long_help = "RocksDB shared block cache size in bytes. With cache_index_and_filter_blocks \
107+
enabled it holds data blocks plus the per-SST index and bloom-filter blocks, \
108+
so it is the effective ceiling on RocksDB's resident memory.\n\
110109
\n\
111-
Default: 21474836480 bytes (20 GiB). Sized generously on purpose, to comfortably \
112-
hold the filter and index working set on a fully-synced mainnet node (~5 GiB) \
113-
plus the EVM's hot data set during block execution. Total ethrex process \
114-
resident memory at this default is roughly 25-28 GiB on a fully-synced mainnet \
115-
node (cache + memtables + per-block working memory).\n\
110+
Default 12 GiB keeps the filter/index working set resident plus hot EVM state. \
111+
A sweep on a synced mainnet node (32 GiB cap) found 8-16 GiB all keep up with \
112+
head-following (filters resident, disk near-idle, no slow blocks); larger gives \
113+
no gain because the OS page cache backstops the uncompressed state CFs, and \
114+
~8 GiB is the floor where the filter set starts to thrash.\n\
116115
\n\
117-
LOWERING THIS VALUE WILL DEGRADE BLOCK-IMPORT PERFORMANCE. The filter and \
118-
index working set is essentially fixed; when the cache cannot hold it plus a \
119-
useful amount of hot data, EVM state reads spill to disk on every miss and \
120-
block execution slows down sharply. Measured on a synced mainnet node:\n\
121-
- 4 GiB cache : ~76% slower than the unbounded baseline (filters monopolize \
122-
the cache, data is constantly evicted)\n\
123-
- 20 GiB cache: at parity with the unbounded baseline (filters + working \
124-
set both fit comfortably; this is the default)\n\
125-
\n\
126-
When to keep or raise the default:\n\
127-
- Production mainnet validators and any node where block-import throughput \
128-
matters should keep the default. Spare RAM is otherwise unused; the cache \
129-
fills lazily up to this ceiling.\n\
130-
- Future-proofing for databases beyond ~1 TB: raising this above 20 GiB \
131-
leaves headroom as the on-disk state grows.\n\
132-
\n\
133-
When to lower it:\n\
134-
- Resource-constrained hosts (testnet nodes, dev VMs, small validators) where \
135-
the lower memory ceiling is worth the throughput cost. The lower bound for \
136-
keeping up with mainnet under head-following load is workload-dependent and \
137-
not currently characterized below 4 GiB.\n\
138-
\n\
139-
Value is in bytes. Example: 21474836480 = 20 * 1024^3 = 20 GiB. The \
140-
ETHREX_ROCKSDB_BLOCK_CACHE_SIZE environment variable has the same effect.",
116+
Lower only on memory-constrained hosts, accepting reduced throughput. \
117+
ETHREX_ROCKSDB_BLOCK_CACHE_SIZE sets the same value.",
141118
help_heading = "Storage options",
142119
env = "ETHREX_ROCKSDB_BLOCK_CACHE_SIZE",
143120
)]

crates/storage/store.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ const IN_MEMORY_COMMIT_THRESHOLD: usize = 10000;
7272
/// blocks of trie diffs (~1 GB), so we flush aggressively to bound memory.
7373
const BATCH_COMMIT_THRESHOLD: usize = 4;
7474

75-
/// Default size in bytes of the RocksDB shared block cache: 20 GiB.
75+
/// Default size in bytes of the RocksDB shared block cache: 12 GiB.
7676
///
7777
/// This cache holds both data blocks AND the index/bloom-filter blocks for every
7878
/// open SST file (because we enable `cache_index_and_filter_blocks`), so its size
79-
/// is the effective upper bound on RocksDB's resident memory footprint. It is
80-
/// sized generously by default to comfortably hold the filter and index working
81-
/// set on a fully-synced mainnet node (~5 GiB) plus a useful amount of hot data
82-
/// for EVM execution — lowering it below that threshold degrades block-import
83-
/// throughput significantly (see `StoreConfig::rocksdb_block_cache_size`).
84-
pub const DEFAULT_ROCKSDB_BLOCK_CACHE_SIZE_BYTES: usize = 20 * 1024 * 1024 * 1024;
79+
/// is the effective upper bound on RocksDB's resident memory footprint. 12 GiB
80+
/// keeps the filter/index working set resident plus hot EVM state; a sweep on a
81+
/// synced mainnet node (32 GiB cap) found 8-16 GiB all keep up with head-following,
82+
/// with larger giving no gain (the OS page cache backstops the uncompressed state
83+
/// CFs) and ~8 GiB the floor where the filter set starts to thrash.
84+
pub const DEFAULT_ROCKSDB_BLOCK_CACHE_SIZE_BYTES: usize = 12 * 1024 * 1024 * 1024;
8585

8686
/// Tunable configuration for [`Store::new_with_config`] and related constructors.
8787
///

0 commit comments

Comments
 (0)