Skip to content

Commit

Permalink
Allow bifrost wal fsync to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedSoliman committed Jun 4, 2024
1 parent 5e5befa commit a0fbb70
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/bifrost/src/loglets/local_loglet/log_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn db_options(options: &LocalLogletOptions) -> rocksdb::Options {
if options.rocksdb.rocksdb_disable_wal() {
opts.set_atomic_flush(true);
}
opts.set_wal_recovery_mode(rocksdb::DBRecoveryMode::AbsoluteConsistency);

opts
}
Expand Down
3 changes: 1 addition & 2 deletions crates/bifrost/src/loglets/local_loglet/log_store_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ impl LogStoreWriter {
async fn commit(&mut self, opts: &LocalLogletOptions, write_batch: WriteBatch) {
let mut write_opts = rocksdb::WriteOptions::new();
write_opts.disable_wal(opts.rocksdb.rocksdb_disable_wal());
// if WAL is enabled, we sync after every write.
write_opts.set_sync(!opts.rocksdb.rocksdb_disable_wal());
write_opts.set_sync(!opts.rocksdb_disable_wal_fsync());

trace!(
"Committing local loglet current write batch: {} items",
Expand Down
3 changes: 2 additions & 1 deletion crates/rocksdb/src/db_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ impl RocksDbManager {

// no need to retain 1000 log files by default.
//
db_options.set_keep_log_file_num(1);
db_options.set_keep_log_file_num(2);
db_options.set_recycle_log_file_num(4);
// Disable WAL archiving.
// the following two options has to be both 0 to disable WAL log archive.
db_options.set_wal_size_limit_mb(0);
Expand Down
8 changes: 8 additions & 0 deletions crates/types/src/config/bifrost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ pub struct LocalLogletOptions {
/// (See `rocksdb-total-memtables-ratio` in common).
rocksdb_memory_ratio: f32,

/// Disable fsync of WAL on every batch
rocksdb_disable_wal_fsync: bool,

/// Trigger a commit when the batch size exceeds this threshold.
///
/// Set to 0 or 1 to commit the write batch on every command.
Expand Down Expand Up @@ -97,6 +100,10 @@ impl LocalLogletOptions {
}
}

pub fn rocksdb_disable_wal_fsync(&self) -> bool {
self.rocksdb_disable_wal_fsync
}

pub fn rocksdb_memory_budget(&self) -> usize {
self.rocksdb_memory_budget
.unwrap_or_else(|| {
Expand Down Expand Up @@ -125,6 +132,7 @@ impl Default for LocalLogletOptions {
rocksdb_memory_ratio: 0.5,
writer_batch_commit_count: 2000,
writer_batch_commit_duration: Duration::ZERO.into(),
rocksdb_disable_wal_fsync: false,
}
}
}

0 comments on commit a0fbb70

Please sign in to comment.