Skip to content

Commit 312d766

Browse files
committed
Test changes
1 parent 6c389ed commit 312d766

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

linera-views/src/backends/rocks_db.rs

Lines changed: 24 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,12 @@ 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 = 4 * 1024 * 1024 * 1024; // 4 GiB
54+
const MAX_WRITE_BUFFER_NUMBER: i32 = 64;
55+
56+
const UNIVERSAL_STYLE_COMPACTION_SIZE: usize = 1024 * 1024 * 1024; // 1 GB
57+
const HYPER_CLOCK_CACHE_SIZE: usize = 64 * 1024 * 1024 * 1024; // 64 GB
58+
const HYPER_CLOCK_CACHE_BLOCK_SIZE: usize = 8 * 1024; // 8 KB
5459

5560
/// The RocksDB client that we use.
5661
type DB = rocksdb::DBWithThreadMode<rocksdb::MultiThreaded>;
@@ -304,16 +309,26 @@ impl RocksDbStoreInternal {
304309
options.create_if_missing(true);
305310
options.create_missing_column_families(true);
306311
// 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);
312+
options.set_write_buffer_size(WRITE_BUFFER_SIZE);
313+
options.set_max_write_buffer_number(MAX_WRITE_BUFFER_NUMBER);
309314
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();
315+
options.set_level_zero_slowdown_writes_trigger(MAX_WRITE_BUFFER_NUMBER / 2);
316+
options.set_level_zero_stop_writes_trigger(MAX_WRITE_BUFFER_NUMBER);
314317
options.increase_parallelism(num_cpus::get() as i32);
315-
options.set_max_background_jobs(8);
318+
options.set_max_background_jobs(num_cpus::get() as i32);
316319
options.set_level_compaction_dynamic_level_bytes(true);
320+
options.set_compaction_style(DBCompactionStyle::Universal);
321+
options.optimize_universal_style_compaction(UNIVERSAL_STYLE_COMPACTION_SIZE);
322+
options.set_target_file_size_base(UNIVERSAL_STYLE_COMPACTION_SIZE as u64 / 2);
323+
324+
let mut block_options = BlockBasedOptions::default();
325+
block_options.set_pin_l0_filter_and_index_blocks_in_cache(true);
326+
block_options.set_cache_index_and_filter_blocks(true);
327+
block_options.set_block_cache(&Cache::new_hyper_clock_cache(
328+
HYPER_CLOCK_CACHE_SIZE,
329+
HYPER_CLOCK_CACHE_BLOCK_SIZE,
330+
));
331+
options.set_block_based_table_factory(&block_options);
317332

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

0 commit comments

Comments
 (0)