bstree_file_readonly/cliargs/
memsize.rs

1//! Size of the different memory caches used to build and query the tree.
2use structopt::StructOpt;
3
4#[derive(Debug, StructOpt)]
5pub struct MemSizeArgs {
6  #[structopt(long, default_value = "32")] // 32 kB
7  /// Size of the L1 cache memory, in kilobytes (kB). It correspond to the page size of a DBMS.
8  pub l1: usize,
9  #[structopt(long, default_value = "8192")] // 8192 kB = 8 MB
10  /// Size of the HDD cache size, in kilobytes (kB)
11  pub disk: usize,
12  #[structopt(short = "r", long, default_value = "1.0")] // 80%
13  /// Fill factor: to prevent occupying the full l1 cache memory
14  pub fill_factor: f32,
15}
16
17impl MemSizeArgs {
18  /// Returns the size of the l1 cache, in bytes.
19  pub fn l1_byte_size(&self) -> usize {
20    ((self.l1 * 1024) as f32 * self.fill_factor) as usize
21  }
22
23  /// Returns the size of the disk cache, in bytes.
24  pub fn disk_byte_size(&self) -> usize {
25    self.disk * 1024
26  }
27}