Skip to content

Commit

Permalink
refactor: use read transaction in rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Dec 17, 2024
1 parent 6d745c6 commit eee8a6e
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 101 deletions.
6 changes: 3 additions & 3 deletions nomt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<T: HashAlgorithm> Nomt<T> {
assert_eq!(prev, 0, "only one session could be active at a time");
let store = self.store.clone();
let rollback_delta = if allow_rollback {
self.store.rollback().map(|r| r.delta_builder())
self.store.rollback().map(|r| r.delta_builder(&store))
} else {
None
};
Expand Down Expand Up @@ -329,7 +329,7 @@ impl<T: HashAlgorithm> Nomt<T> {
if let Some(delta_builder) = session.rollback_delta.take() {
// UNWRAP: if rollback_delta is `Some``, then rollback must be also `Some`.
let rollback = self.store.rollback().unwrap();
rollback.commit(self.store.clone(), &actuals, delta_builder)?;
rollback.commit(&actuals, delta_builder)?;
}

let mut compact_actuals = Vec::with_capacity(actuals.len());
Expand Down Expand Up @@ -465,7 +465,7 @@ impl Session {
/// this call is issued, the better for efficiency.
pub fn preserve_prior_value(&self, path: KeyPath) {
if let Some(rollback) = &self.rollback_delta {
rollback.tentative_preserve_prior(self.store.clone(), path);
rollback.tentative_preserve_prior(path);
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions nomt/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub struct Options {
/// The maximum number of commits that can be rolled back.
pub(crate) max_rollback_log_len: u32,
pub(crate) warm_up: bool,
/// The number of threads to use for fetching prior values.
pub(crate) rollback_tp_size: usize,
/// Whether to preallocate the hashtable file.
pub(crate) preallocate_ht: bool,
}
Expand All @@ -41,7 +39,6 @@ impl Options {
rollback: false,
max_rollback_log_len: 100,
warm_up: false,
rollback_tp_size: 4,
preallocate_ht: true,
}
}
Expand Down Expand Up @@ -116,15 +113,6 @@ impl Options {
self.warm_up = warm_up;
}

/// Set the number of threads to use for fetching prior values.
///
/// Only relevant if rollback is enabled.
///
/// Default: 4.
pub fn rollback_tp_size(&mut self, rollback_tp_size: usize) {
self.rollback_tp_size = rollback_tp_size;
}

/// Sets whether to preallocate the hashtable file.
///
/// Many filesystems don't handle sparse files well. If the `preallocate_ht` option is set to
Expand Down
Loading

0 comments on commit eee8a6e

Please sign in to comment.