@@ -10,41 +10,46 @@ pub mod version;
10
10
use anyhow:: format_err;
11
11
use log:: debug;
12
12
use rocksdb:: {
13
- BlockBasedOptions , Cache , ColumnFamily , ColumnFamilyDescriptor , DBIterator , Direction ,
14
- IteratorMode , Options , DB ,
13
+ BlockBasedOptions , Cache , ColumnFamily , ColumnFamilyDescriptor , DBCompressionType , DBIterator ,
14
+ Direction , IteratorMode , Options , DB ,
15
15
} ;
16
16
use serde:: { de:: DeserializeOwned , Serialize } ;
17
17
use sha2:: { Digest , Sha256 } ;
18
18
19
19
pub type Result < T > = result:: Result < T , DBError > ;
20
20
21
21
fn get_db_default_options ( ) -> Options {
22
- let mut options = Options :: default ( ) ;
23
- options. create_if_missing ( true ) ;
24
- options. create_missing_column_families ( true ) ;
25
-
26
- let n = num_cpus:: get ( ) ;
27
- options. increase_parallelism ( n as i32 ) ;
28
-
29
- let mut env = rocksdb:: Env :: new ( ) . unwrap ( ) ;
30
-
31
- // While a compaction is ongoing, all the background threads
32
- // could be used by the compaction. This can stall writes which
33
- // need to flush the memtable. Add some high-priority background threads
34
- // which can service these writes.
35
- env. set_high_priority_background_threads ( 4 ) ;
36
- options. set_env ( & env) ;
37
-
38
- // Set max total wal size to 4G.
39
- options. set_max_total_wal_size ( 4 * 1024 * 1024 * 1024 ) ;
40
-
41
- let cache = Cache :: new_lru_cache ( 512 * 1024 * 1024 ) ;
42
22
let mut block_opts = BlockBasedOptions :: default ( ) ;
43
- block_opts. set_block_cache ( & cache) ;
44
- block_opts. set_bloom_filter ( 10.0 , false ) ;
45
- options. set_block_based_table_factory ( & block_opts) ;
46
23
47
- options
24
+ block_opts. set_block_size ( 64 << 10 ) ; // kb
25
+ block_opts. set_block_cache ( & Cache :: new_lru_cache ( 64 << 20 ) ) ; // mb
26
+ block_opts. set_cache_index_and_filter_blocks ( true ) ;
27
+ block_opts. set_bloom_filter ( 10.0 , true ) ;
28
+ // block_opts.set_pin_top_level_index_and_filter(true);
29
+
30
+ let mut opts = Options :: default ( ) ;
31
+
32
+ opts. set_max_open_files ( 256 ) ;
33
+
34
+ opts. create_if_missing ( true ) ;
35
+ opts. create_missing_column_families ( true ) ;
36
+ opts. set_write_buffer_size ( 64 << 20 ) ; // mb
37
+ opts. set_max_write_buffer_number ( 2 ) ;
38
+ // opts.set_min_blob_size(2 << 10); // kb
39
+ // // opts.set_blob_file_size(256 << 20); // mb
40
+ // opts.set_enable_blob_files(true);
41
+ // opts.set_enable_blob_gc(true);
42
+ opts. set_enable_pipelined_write ( true ) ;
43
+
44
+ opts. set_compression_type ( DBCompressionType :: Lz4 ) ;
45
+ // opts.set_blob_compression_type(DBCompressionType::Lz4);
46
+ opts. set_bottommost_compression_type ( DBCompressionType :: Zstd ) ;
47
+ opts. set_block_based_table_factory ( & block_opts) ;
48
+ opts. enable_statistics ( ) ;
49
+ let n = num_cpus:: get ( ) ;
50
+ opts. increase_parallelism ( n as i32 ) ;
51
+ opts. set_level_compaction_dynamic_level_bytes ( true ) ;
52
+ opts
48
53
}
49
54
50
55
#[ derive( Debug ) ]
0 commit comments