Skip to content

Commit 79b3372

Browse files
iovoidjrchatruc
authored andcommitted
perf(l1): disable compression of database (#5223)
**Motivation** We see decompression taking a significant part of database reads. **Description** Here we disable compression for the table where FKVs are stored, and use a hash-based index optimized for point operations. --------- Co-authored-by: Javier Rodríguez Chatruc <49622509+jrchatruc@users.noreply.github.com> Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
1 parent a8217e1 commit 79b3372

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Perf
44

5+
### 2025-11-10
6+
- Disable RocksDB compression [#5223](https://github.com/lambdaclass/ethrex/pull/5223)
7+
58
### 2025-11-07
69
- Reuse stack pool in LEVM [#5179](https://github.com/lambdaclass/ethrex/pull/5179)
710

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ uuid = { version = "1.18.1", features = ["v4"] }
119119
tower-http = { version = "0.6.2", features = ["cors"] }
120120
indexmap = { version = "2.11.4" }
121121

122-
rocksdb = "0.24.0"
122+
rocksdb = { version="0.24.0", default-features = false, features = ["bindgen-runtime"] }
123123

124124
[patch.crates-io]
125125
secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "patch-0.30.0-sp1-5.0.0" }

crates/storage/store_db/rocksdb.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ impl Store {
180180
db_options.set_enable_write_thread_adaptive_yield(true);
181181
db_options.set_compaction_readahead_size(4 * 1024 * 1024); // 4MB
182182
db_options.set_advise_random_on_open(false);
183+
db_options.set_compression_type(rocksdb::DBCompressionType::None);
184+
db_options.set_bottommost_compression_type(rocksdb::DBCompressionType::None);
183185

184186
// db_options.enable_statistics();
185187
// db_options.set_stats_dump_period_sec(600);
@@ -239,10 +241,10 @@ impl Store {
239241
cf_opts.set_level_zero_file_num_compaction_trigger(4);
240242
cf_opts.set_level_zero_slowdown_writes_trigger(20);
241243
cf_opts.set_level_zero_stop_writes_trigger(36);
244+
cf_opts.set_compression_type(rocksdb::DBCompressionType::None);
242245

243246
match cf_name.as_str() {
244247
CF_HEADERS | CF_BODIES => {
245-
cf_opts.set_compression_type(rocksdb::DBCompressionType::Zstd);
246248
cf_opts.set_write_buffer_size(128 * 1024 * 1024); // 128MB
247249
cf_opts.set_max_write_buffer_number(4);
248250
cf_opts.set_target_file_size_base(256 * 1024 * 1024); // 256MB
@@ -252,7 +254,6 @@ impl Store {
252254
cf_opts.set_block_based_table_factory(&block_opts);
253255
}
254256
CF_CANONICAL_BLOCK_HASHES | CF_BLOCK_NUMBERS => {
255-
cf_opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
256257
cf_opts.set_write_buffer_size(64 * 1024 * 1024); // 64MB
257258
cf_opts.set_max_write_buffer_number(3);
258259
cf_opts.set_target_file_size_base(128 * 1024 * 1024); // 128MB
@@ -263,7 +264,18 @@ impl Store {
263264
cf_opts.set_block_based_table_factory(&block_opts);
264265
}
265266
CF_TRIE_NODES => {
266-
cf_opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
267+
cf_opts.set_write_buffer_size(512 * 1024 * 1024); // 512MB
268+
cf_opts.set_max_write_buffer_number(6);
269+
cf_opts.set_min_write_buffer_number_to_merge(2);
270+
cf_opts.set_target_file_size_base(256 * 1024 * 1024); // 256MB
271+
cf_opts.set_memtable_prefix_bloom_ratio(0.2); // Bloom filter
272+
273+
let mut block_opts = BlockBasedOptions::default();
274+
block_opts.set_block_size(16 * 1024); // 16KB
275+
block_opts.set_bloom_filter(10.0, false); // 10 bits per key
276+
cf_opts.set_block_based_table_factory(&block_opts);
277+
}
278+
CF_FLATKEYVALUE => {
267279
cf_opts.set_write_buffer_size(512 * 1024 * 1024); // 512MB
268280
cf_opts.set_max_write_buffer_number(6);
269281
cf_opts.set_min_write_buffer_number_to_merge(2);
@@ -276,7 +288,6 @@ impl Store {
276288
cf_opts.set_block_based_table_factory(&block_opts);
277289
}
278290
CF_RECEIPTS | CF_ACCOUNT_CODES => {
279-
cf_opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
280291
cf_opts.set_write_buffer_size(128 * 1024 * 1024); // 128MB
281292
cf_opts.set_max_write_buffer_number(3);
282293
cf_opts.set_target_file_size_base(256 * 1024 * 1024); // 256MB
@@ -287,7 +298,6 @@ impl Store {
287298
}
288299
_ => {
289300
// Default for other CFs
290-
cf_opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
291301
cf_opts.set_write_buffer_size(64 * 1024 * 1024); // 64MB
292302
cf_opts.set_max_write_buffer_number(3);
293303
cf_opts.set_target_file_size_base(128 * 1024 * 1024); // 128MB

0 commit comments

Comments
 (0)