Skip to content

Commit 8c2d190

Browse files
committed
Test changes
1 parent 2e538d4 commit 8c2d190

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

linera-views/src/backends/rocks_db.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{
1414
};
1515

1616
use linera_base::ensure;
17+
use rocksdb::{BlockBasedOptions, Cache, DBCompactionStyle};
1718
use serde::{Deserialize, Serialize};
1819
use tempfile::TempDir;
1920
use thiserror::Error;
@@ -49,8 +50,8 @@ const MAX_VALUE_SIZE: usize = 3221225072;
4950
// 8388608 and so for offset reason we decrease by 400
5051
const MAX_KEY_SIZE: usize = 8388208;
5152

52-
const DB_CACHE_SIZE: usize = 128 * 1024 * 1024; // 128 MiB
53-
const DB_MAX_WRITE_BUFFER_NUMBER: i32 = 8;
53+
const WRITE_BUFFER_SIZE: usize = 512 * 1024 * 1024; // 512 MiB
54+
const MAX_WRITE_BUFFER_NUMBER: i32 = 128;
5455

5556
/// The RocksDB client that we use.
5657
type DB = rocksdb::DBWithThreadMode<rocksdb::MultiThreaded>;
@@ -304,16 +305,26 @@ impl RocksDbStoreInternal {
304305
options.create_if_missing(true);
305306
options.create_missing_column_families(true);
306307
// Flush in-memory buffer to disk more often
307-
options.set_write_buffer_size(DB_CACHE_SIZE);
308-
options.set_max_write_buffer_number(DB_MAX_WRITE_BUFFER_NUMBER);
308+
options.set_write_buffer_size(WRITE_BUFFER_SIZE);
309+
options.set_max_write_buffer_number(MAX_WRITE_BUFFER_NUMBER);
309310
options.set_compression_type(rocksdb::DBCompressionType::Lz4);
310-
options.set_level_zero_slowdown_writes_trigger(-1);
311-
options.set_level_zero_stop_writes_trigger(48);
312-
options.set_stats_dump_period_sec(60);
313-
options.enable_statistics();
311+
options.set_level_zero_slowdown_writes_trigger(MAX_WRITE_BUFFER_NUMBER / 2);
312+
options.set_level_zero_stop_writes_trigger(MAX_WRITE_BUFFER_NUMBER);
314313
options.increase_parallelism(num_cpus::get() as i32);
315-
options.set_max_background_jobs(8);
314+
options.set_max_background_jobs(num_cpus::get() as i32);
316315
options.set_level_compaction_dynamic_level_bytes(true);
316+
options.set_compaction_style(DBCompactionStyle::Universal);
317+
options.optimize_universal_style_compaction(1024 * 1024 * 1024); // 1 GB
318+
options.set_target_file_size_base(512 * 1024 * 1024); // 512 MB
319+
320+
let mut block_options = BlockBasedOptions::default();
321+
block_options.set_pin_l0_filter_and_index_blocks_in_cache(true);
322+
block_options.set_cache_index_and_filter_blocks(true);
323+
block_options.set_block_cache(&Cache::new_hyper_clock_cache(
324+
16 * 1024 * 1024 * 1024, // 16 GB
325+
8 * 1024, // 8 KB
326+
));
327+
options.set_block_based_table_factory(&block_options);
317328

318329
let db = DB::open(&options, path_buf)?;
319330
let executor = RocksDbStoreExecutor {

0 commit comments

Comments
 (0)