Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Use LZ4 for DB compression #194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/storage/db/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ impl RocksDB {
}
let backup_path = backup_path.into_os_string().into_string().unwrap();

let backup_db =
DB::open_default(&backup_path).map_err(|e| RocksdbError::InternalError(e))?;
let mut backup_db_options = Options::default();
backup_db_options.set_compression_type(rocksdb::DBCompressionType::Lz4);

let backup_db = DB::open(&backup_db_options, &backup_path)
.map_err(|e| RocksdbError::InternalError(e))?;
let mut write_options = rocksdb::WriteOptions::default();
write_options.disable_wal(true); // Significantly faster, WAL doesn't provide benefits for backups
let mut write_batch = rocksdb::WriteBatch::default();
Expand Down Expand Up @@ -226,6 +229,7 @@ impl RocksDB {
// Create RocksDB options
let mut opts = Options::default();
opts.create_if_missing(true); // Creates a database if it does not exist
opts.set_compression_type(rocksdb::DBCompressionType::Lz4);

let mut tx_db_opts = rocksdb::TransactionDBOptions::default();
tx_db_opts.set_default_lock_timeout(5000); // 5 seconds
Expand Down