Add get_difficulty_map method

This commit is contained in:
Bojan Serafimov
2023-01-05 01:58:18 -05:00
parent 01e09fc56c
commit 115549261c
2 changed files with 26 additions and 4 deletions

View File

@@ -125,14 +125,19 @@ fn bench_from_real_project(c: &mut Criterion) {
let queries: Vec<(Key, Lsn)> = uniform_query_pattern(&layer_map);
// Define and name the benchmark function
let mut group = c.benchmark_group("real_map_uniform_queries");
group.bench_function("current_code", |b| {
let mut group = c.benchmark_group("real_map");
group.bench_function("uniform_queries", |b| {
b.iter(|| {
for q in queries.clone().into_iter() {
layer_map.search(q.0, q.1);
}
});
});
group.bench_function("get_difficulty_map", |b| {
b.iter(|| {
// TODO call get_difficulty_map
});
});
group.finish();
}
@@ -168,14 +173,19 @@ fn bench_sequential(c: &mut Criterion) {
.collect();
// Define and name the benchmark function
let mut group = c.benchmark_group("sequential_uniform_queries");
group.bench_function("current_code", |b| {
let mut group = c.benchmark_group("sequential");
group.bench_function("uniform_queries", |b| {
b.iter(|| {
for q in queries.clone().into_iter() {
layer_map.search(q.0, q.1);
}
});
});
group.bench_function("get_difficulty_map", |b| {
b.iter(|| {
// TODO call get_difficulty_map
});
});
group.finish();
}

View File

@@ -10,6 +10,7 @@
//! corresponding files are written to disk.
//!
use crate::keyspace::KeyPartitioning;
use crate::metrics::NUM_ONDISK_LAYERS;
use crate::repository::Key;
use crate::tenant::storage_layer::InMemoryLayer;
@@ -321,6 +322,17 @@ where
Ok(max_stacked_deltas)
}
/// For each part of a keyspace partitioning, return the maximum number of layers
/// that would be needed for page reconstruction in that part at the given LSN.
///
/// This method is used to decide where to create new image layers. Computing the
/// result for the entire partitioning at once allows this function to be more
/// efficient, and further optimization is possible by using iterators instead,
/// to allow early return.
pub fn get_difficulty_map(&self, _lsn: Lsn, _partitioning: &KeyPartitioning) -> Vec<usize> {
todo!()
}
/// Return all L0 delta layers
pub fn get_level0_deltas(&self) -> Result<Vec<Arc<L>>> {
Ok(self.l0_delta_layers.clone())