Skip to content

Commit 7cd4b1c

Browse files
committed
rocksdb: set set_max_total_wal_size to 128M
Signed-off-by: Eval EXEC <execvy@gmail.com>
1 parent 8e043c6 commit 7cd4b1c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

light-client-lib/src/storage/db/native.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use ckb_types::{
2121
use rocksdb::{
2222
ops::{Delete, GetPinned},
2323
prelude::{Get, Iterate, Open, Put, WriteOps},
24-
DBPinnableSlice, Direction, IteratorMode, Snapshot, WriteBatch, DB,
24+
DBPinnableSlice, Direction, IteratorMode, Options, Snapshot, WriteBatch, DB,
2525
};
2626
use std::{
2727
collections::{HashMap, HashSet},
@@ -52,7 +52,12 @@ pub struct Storage {
5252

5353
impl Storage {
5454
pub fn new<P: AsRef<Path>>(path: P) -> Self {
55-
let db = Arc::new(DB::open_default(path).expect("Failed to open rocksdb"));
55+
let mut opts = Options::default();
56+
opts.create_if_missing(true);
57+
opts.set_max_total_wal_size(128 * 1024 * 1024);
58+
opts.set_write_buffer_size(128 * 1024 * 1024);
59+
opts.set_max_write_buffer_number(2);
60+
let db = Arc::new(DB::open(&opts, path).expect("Failed to open rocksdb"));
5661
Self { db }
5762
}
5863

0 commit comments

Comments
 (0)