diff --git a/benches/level_manifest.rs b/benches/level_manifest.rs index b26e4d2..91277a2 100644 --- a/benches/level_manifest.rs +++ b/benches/level_manifest.rs @@ -5,6 +5,8 @@ fn iterate_segments(c: &mut Criterion) { let mut group = c.benchmark_group("Iterate level manifest"); group.sample_size(10); + std::fs::create_dir_all(".bench").unwrap(); + for segment_count in [0, 1, 5, 10, 100, 500, 1_000, 2_000, 4_000] { group.bench_function(format!("iterate {segment_count} segments"), |b| { let folder = tempfile::tempdir_in(".bench").unwrap(); @@ -28,7 +30,9 @@ fn find_segment(c: &mut Criterion) { let mut group = c.benchmark_group("Find segment in disjoint level"); group.sample_size(10); - for segment_count in [1u64, 5, 10, 100, 500, 1_000, 2_000, 4_000] { + std::fs::create_dir_all(".bench").unwrap(); + + for segment_count in [1u64, 4, 5, 10, 100, 500, 1_000, 2_000, 4_000] { group.bench_function( format!("find segment in {segment_count} segments - binary search"), |b| { diff --git a/src/tree/mod.rs b/src/tree/mod.rs index e8f35f1..928abb3 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -630,8 +630,8 @@ impl Tree { let level_manifest = self.levels.read().expect("lock is poisoned"); for level in &level_manifest.levels { - // NOTE: Based on benchmarking, binary search is only worth it after ~4 segments - if level.len() >= 5 { + // NOTE: Based on benchmarking, binary search is only worth it with ~4 segments + if level.len() >= 4 { if let Some(level) = level.as_disjoint() { // TODO: unit test in disjoint level: // [a:5, a:4] [a:3, b:5]