Skip to content

Commit ecee043

Browse files
committed
Test changes
1 parent ea89e16 commit ecee043

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

linera-views/src/backends/rocks_db.rs

Lines changed: 24 additions & 10 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,11 @@ 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 = 256 * 1024 * 1024; // 256 MB
54+
const MAX_WRITE_BUFFER_NUMBER: i32 = 8;
55+
56+
const HYPER_CLOCK_CACHE_SIZE: usize = 128 * 1024 * 1024 * 1024; // 128 GB
57+
const HYPER_CLOCK_CACHE_BLOCK_SIZE: usize = 8 * 1024; // 8 KB
5458

5559
/// The RocksDB client that we use.
5660
type DB = rocksdb::DBWithThreadMode<rocksdb::MultiThreaded>;
@@ -304,17 +308,27 @@ impl RocksDbStoreInternal {
304308
options.create_if_missing(true);
305309
options.create_missing_column_families(true);
306310
// 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);
311+
options.set_write_buffer_size(WRITE_BUFFER_SIZE);
312+
options.set_max_write_buffer_number(MAX_WRITE_BUFFER_NUMBER);
309313
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();
314-
options.increase_parallelism(num_cpus::get() as i32);
315-
options.set_max_background_jobs(8);
314+
options.set_level_zero_slowdown_writes_trigger(12);
315+
options.set_level_zero_stop_writes_trigger(20);
316+
options.increase_parallelism((num_cpus::get() as i32) / 2);
317+
options.set_max_background_jobs((num_cpus::get() as i32) / 3);
316318
options.set_level_compaction_dynamic_level_bytes(true);
317319

320+
options.set_compaction_style(DBCompactionStyle::Level);
321+
options.set_target_file_size_base(WRITE_BUFFER_SIZE as u64);
322+
323+
let mut block_options = BlockBasedOptions::default();
324+
block_options.set_pin_l0_filter_and_index_blocks_in_cache(true);
325+
block_options.set_cache_index_and_filter_blocks(true);
326+
block_options.set_block_cache(&Cache::new_hyper_clock_cache(
327+
HYPER_CLOCK_CACHE_SIZE,
328+
HYPER_CLOCK_CACHE_BLOCK_SIZE,
329+
));
330+
options.set_block_based_table_factory(&block_options);
331+
318332
let db = DB::open(&options, path_buf)?;
319333
let executor = RocksDbStoreExecutor {
320334
db: Arc::new(db),

0 commit comments

Comments
 (0)