@@ -14,6 +14,7 @@ use std::{
1414} ;
1515
1616use linera_base:: ensure;
17+ use rocksdb:: { BlockBasedOptions , Cache , DBCompactionStyle } ;
1718use serde:: { Deserialize , Serialize } ;
1819use tempfile:: TempDir ;
1920use thiserror:: Error ;
@@ -49,8 +50,11 @@ const MAX_VALUE_SIZE: usize = 3221225072;
4950// 8388608 and so for offset reason we decrease by 400
5051const 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.
5660type 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