Skip to content

Commit

Permalink
Merge branch 'optimize-local-writes'
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Aug 31, 2023
2 parents b96565d + f721c91 commit a6fe1d8
Show file tree
Hide file tree
Showing 45 changed files with 1,284 additions and 1,286 deletions.
60 changes: 4 additions & 56 deletions lib/benches/bench_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ use tempfile::TempDir;
use tokio::runtime::Runtime;
use utils::Actor;

criterion_group!(default, write_file, read_file, remove_file, sync);
criterion_group!(default, write_file, read_file, sync);
criterion_main!(default);

const FILE_SIZES_M: &[u64] = &[1, 8];

fn write_file(c: &mut Criterion) {
let runtime = Runtime::new().unwrap();

Expand All @@ -21,7 +19,7 @@ fn write_file(c: &mut Criterion) {

let buffer_size = 4096;

for &m in FILE_SIZES_M {
for m in [1, 8, 16] {
let file_size = m * 1024 * 1024;

group.throughput(Throughput::Bytes(file_size));
Expand Down Expand Up @@ -63,7 +61,7 @@ fn read_file(c: &mut Criterion) {

let buffer_size = 4096;

for &m in FILE_SIZES_M {
for m in [1, 8, 16] {
let file_size = m * 1024 * 1024;

group.throughput(Throughput::Bytes(file_size));
Expand Down Expand Up @@ -108,63 +106,13 @@ fn read_file(c: &mut Criterion) {
group.finish();
}

fn remove_file(c: &mut Criterion) {
let runtime = Runtime::new().unwrap();

let mut group = c.benchmark_group("lib/remove_file");
group.sample_size(10);

for &m in FILE_SIZES_M {
let file_size = m * 1024 * 1024;

group.throughput(Throughput::Bytes(file_size));
group.bench_function(BenchmarkId::from_parameter(format!("{m} MiB")), |b| {
let file_name = Utf8Path::new("file.dat");

b.iter_batched_ref(
|| {
let mut rng = StdRng::from_entropy();
let base_dir = TempDir::new_in(env!("CARGO_TARGET_TMPDIR")).unwrap();

let repo = runtime.block_on(async {
let repo = utils::create_repo(
&mut rng,
&base_dir.path().join("repo.db"),
0,
StateMonitor::make_root(),
)
.await;
utils::write_file(
&mut rng,
&repo,
file_name,
file_size as usize,
4096,
false,
)
.await;
repo
});

(base_dir, repo)
},
|(_base_dir, repo)| {
runtime.block_on(async { repo.remove_entry(file_name).await.unwrap() });
},
BatchSize::LargeInput,
);
});
}
group.finish();
}

fn sync(c: &mut Criterion) {
let runtime = Runtime::new().unwrap();

let mut group = c.benchmark_group("lib/sync");
group.sample_size(10);

for &m in FILE_SIZES_M {
for m in [1, 8] {
let file_size = m * 1024 * 1024;

group.throughput(Throughput::Bytes(file_size));
Expand Down
3 changes: 1 addition & 2 deletions lib/src/blob/block_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::{
blob::BlobId,
branch::Branch,
error::{Error, Result},
locator::Locator,
protocol::{BlockId, RootNode},
protocol::{BlockId, Locator, RootNode},
store,
};

Expand Down
78 changes: 0 additions & 78 deletions lib/src/blob/buffer.rs

This file was deleted.

Loading

0 comments on commit a6fe1d8

Please sign in to comment.