Skip to content

Commit

Permalink
feat(benchtop): expose page cache upper levels / prepopulation in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier authored and pepyakin committed Feb 12, 2025
1 parent 600306b commit 9985657
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions benchtop/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ impl Backend {
hashtable_buckets: Option<u32>,
page_cache_size: Option<usize>,
leaf_cache_size: Option<usize>,
page_cache_upper_levels: usize,
prepopulate_page_cache: bool,
overlay_window_length: usize,
) -> DB {
match self {
Expand All @@ -34,6 +36,8 @@ impl Backend {
hashtable_buckets,
page_cache_size,
leaf_cache_size,
page_cache_upper_levels,
prepopulate_page_cache,
overlay_window_length,
)),
Backend::SpTrie => DB::SpTrie(SpTrieDB::open(reset)),
Expand Down
12 changes: 12 additions & 0 deletions benchtop/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ pub struct WorkloadParams {
#[arg(long = "page-cache-size")]
pub page_cache_size: Option<usize>,

/// The number of upper levels of the NOMT page tree to keep permanently cached.
/// Only used with the Nomt backend.
#[arg(long = "page-cache-upper-levels")]
#[clap(default_value = "3")]
pub page_cache_upper_levels: usize,

/// Whether to prepopulate the page cache with the upper levels of the page tree in NOMT.
/// Only used with the Nomt backend.
#[arg(long = "prepopulate-page-cache")]
#[clap(default_value = "true")]
pub prepopulate_page_cache: bool,

/// The size of the leaf cache used in NOMT to store Beatree leaves, measured in MiB.
/// Only used with the Nomt backend.
#[arg(long = "leaf-cache-size")]
Expand Down
4 changes: 4 additions & 0 deletions benchtop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub fn init(params: InitParams) -> Result<()> {
workload_params.hashtable_buckets,
workload_params.page_cache_size,
workload_params.leaf_cache_size,
workload_params.page_cache_upper_levels,
workload_params.prepopulate_page_cache,
0,
);
db.execute(None, &mut *init, None);
Expand All @@ -54,6 +56,8 @@ pub fn run(params: RunParams) -> Result<()> {
workload_params.hashtable_buckets,
workload_params.page_cache_size,
workload_params.leaf_cache_size,
workload_params.page_cache_upper_levels,
workload_params.prepopulate_page_cache,
workload_params.overlay_window_length,
);

Expand Down
4 changes: 4 additions & 0 deletions benchtop/src/nomt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ impl NomtDB {
hashtable_buckets: Option<u32>,
page_cache_size: Option<usize>,
leaf_cache_size: Option<usize>,
page_cache_upper_levels: usize,
prepopulate_page_cache: bool,
overlay_window_capacity: usize,
) -> Self {
let nomt_db_folder =
Expand All @@ -50,6 +52,8 @@ impl NomtDB {
if let Some(buckets) = hashtable_buckets {
opts.hashtable_buckets(buckets);
}
opts.page_cache_upper_levels(page_cache_upper_levels);
opts.prepopulate_page_cache(prepopulate_page_cache);

let nomt = Nomt::open(opts).unwrap();
Self {
Expand Down

0 comments on commit 9985657

Please sign in to comment.