Skip to content

Commit

Permalink
fix: fix bug with bench
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
  • Loading branch information
MrCroxx committed May 26, 2023
1 parent d6a7a28 commit 1230529
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
16 changes: 10 additions & 6 deletions foyer-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ pub struct Args {
dir: String,

/// (MiB)
#[arg(long)]
#[arg(long, default_value_t = 1024)]
capacity: usize,

/// (s)
#[arg(short, long)]
#[arg(short, long, default_value_t = 60)]
time: u64,

#[arg(long)]
#[arg(long, default_value_t = 16)]
concurrency: usize,

/// must be power of 2
#[arg(long)]
#[arg(long, default_value_t = 16)]
pools: usize,

/// (s)
Expand All @@ -84,7 +84,7 @@ pub struct Args {
look_up_range: u64,

/// read only file store: max cache file size (MiB)
#[arg(long, default_value_t = 64)]
#[arg(long, default_value_t = 16)]
rofs_max_file_size: usize,

/// read only file store: ratio of garbage to trigger reclaim (0 ~ 1)
Expand Down Expand Up @@ -122,6 +122,8 @@ async fn main() {
let args = Args::parse();
args.verify();

println!("{:#?}", args);

create_dir_all(&args.dir).unwrap();

let iostat_path = match detect_fs_type(&args.dir) {
Expand All @@ -144,7 +146,7 @@ async fn main() {

let store_config = ReadOnlyFileStoreConfig {
dir: PathBuf::from(&args.dir),
capacity: args.capacity * 1024 * 1024,
capacity: args.capacity * 1024 * 1024 / args.pools,
max_file_size: args.rofs_max_file_size * 1024 * 1024,
trigger_reclaim_garbage_ratio: args.rofs_trigger_reclaim_garbage_ratio,
trigger_reclaim_capacity_ratio: args.rofs_trigger_reclaim_capacity_ratio,
Expand All @@ -164,6 +166,8 @@ async fn main() {
store_config,
};

println!("{:#?}", config);

let container = Container::open(config).await.unwrap();
let container = Arc::new(container);

Expand Down
17 changes: 17 additions & 0 deletions foyer/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ where
pub store_config: S::C,
}

impl<I, P, H, S> std::fmt::Debug for Config<I, P, H, S>
where
I: Index,
P: Policy<I = I, H = H>,
H: Handle<I = I>,
S: Store<I = I>,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Config")
.field("capacity", &self.capacity)
.field("pool_count_bits", &self.pool_count_bits)
.field("policy_config", &self.policy_config)
.field("store_config", &self.store_config)
.finish()
}
}

#[allow(clippy::type_complexity)]
pub struct Container<I, P, H, D, S>
where
Expand Down
2 changes: 1 addition & 1 deletion foyer/src/policies/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub trait Policy: Send + Sync + 'static {
fn eviction_iter(&self) -> Self::E<'_>;
}

pub trait Config: Send + Sync + Clone + 'static {}
pub trait Config: Send + Sync + std::fmt::Debug + Clone + 'static {}

pub trait Handle: Send + Sync + 'static {
type I: Index;
Expand Down
2 changes: 1 addition & 1 deletion foyer/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use error::Result;
pub trait Store: Send + Sync + Sized + 'static {
type I: Index;
type D: Data;
type C: Send + Sync + Clone + 'static;
type C: Send + Sync + Clone + std::fmt::Debug + 'static;

async fn open(pool: usize, config: Self::C) -> Result<Self>;

Expand Down

0 comments on commit 1230529

Please sign in to comment.