Apply rustfmt to entire workspace

Runs cargo fmt --all; all 573 tests still passing, clippy still clean.
No logic changes — formatting only.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
osobh
2026-04-04 20:31:33 -05:00
co-authored by Claude Sonnet 4.6
parent 3d524e2d63
commit 1c107fe58a
69 changed files with 2790 additions and 1325 deletions
@@ -46,7 +46,9 @@ fn bench_epoch_gc(c: &mut Criterion) {
b.iter_with_setup(
|| make_onion(n),
|(_tmp, _h5, mut onion)| {
let _ = onion.gc(black_box(GcPolicy::KeepLastN((n / 2) as u64))).unwrap();
let _ = onion
.gc(black_box(GcPolicy::KeepLastN((n / 2) as u64)))
.unwrap();
},
);
});
@@ -60,9 +62,11 @@ fn bench_epoch_gc(c: &mut Criterion) {
b.iter_with_setup(
|| make_onion(n),
|(_tmp, _h5, mut onion)| {
let _ = onion.gc(black_box(GcPolicy::EpochFlip(Box::new(
GcPolicy::KeepLastN((n / 2) as u64),
)))).unwrap();
let _ = onion
.gc(black_box(GcPolicy::EpochFlip(Box::new(
GcPolicy::KeepLastN((n / 2) as u64),
))))
.unwrap();
},
);
});
@@ -76,9 +80,11 @@ fn bench_epoch_gc(c: &mut Criterion) {
b.iter_with_setup(
|| {
let (tmp, h5, mut onion) = make_onion(n);
onion.gc(GcPolicy::EpochFlip(Box::new(
GcPolicy::KeepLastN((n / 2) as u64),
))).unwrap();
onion
.gc(GcPolicy::EpochFlip(Box::new(GcPolicy::KeepLastN(
(n / 2) as u64,
))))
.unwrap();
(tmp, h5, onion)
},
|(_tmp, _h5, mut onion)| {
+34 -15
View File
@@ -51,21 +51,31 @@ fn bench_merkle(c: &mut Criterion) {
for &n in &ns {
let full = RevisionMerkleTree::build(&make_entries(n));
let minus1 = RevisionMerkleTree::build(&make_entries(n - 1));
group.bench_with_input(BenchmarkId::from_parameter(n), &(full, minus1), |b, (f, m)| {
b.iter(|| f.diff_missing_revisions(black_box(m)));
});
group.bench_with_input(
BenchmarkId::from_parameter(n),
&(full, minus1),
|b, (f, m)| {
b.iter(|| f.diff_missing_revisions(black_box(m)));
},
);
}
group.finish();
// ── Diff walk: D=10 ──────────────────────────────────────────────────────
let mut group = c.benchmark_group("merkle_index/diff_walk_d10");
for &n in &ns {
if n < 20 { continue; }
let full = RevisionMerkleTree::build(&make_entries(n));
let base = RevisionMerkleTree::build(&make_entries(n - 10));
group.bench_with_input(BenchmarkId::from_parameter(n), &(full, base), |b, (f, base)| {
b.iter(|| f.diff_missing_revisions(black_box(base)));
});
if n < 20 {
continue;
}
let full = RevisionMerkleTree::build(&make_entries(n));
let base = RevisionMerkleTree::build(&make_entries(n - 10));
group.bench_with_input(
BenchmarkId::from_parameter(n),
&(full, base),
|b, (f, base)| {
b.iter(|| f.diff_missing_revisions(black_box(base)));
},
);
}
group.finish();
@@ -74,9 +84,13 @@ fn bench_merkle(c: &mut Criterion) {
for &n in &[1_000usize, 10_000] {
let full = RevisionMerkleTree::build(&make_entries(n));
let base = RevisionMerkleTree::build(&make_entries(n - 100));
group.bench_with_input(BenchmarkId::from_parameter(n), &(full, base), |b, (f, base)| {
b.iter(|| f.diff_missing_revisions(black_box(base)));
});
group.bench_with_input(
BenchmarkId::from_parameter(n),
&(full, base),
|b, (f, base)| {
b.iter(|| f.diff_missing_revisions(black_box(base)));
},
);
}
group.finish();
@@ -102,14 +116,19 @@ fn bench_merkle(c: &mut Criterion) {
// ── Serialised size report (not timed) ───────────────────────────────────
println!("\n=== Serialised size vs flat manifest (N × 60 B) ===");
println!("{:>8} {:>12} {:>12} {:>10}", "N", "Merkle (B)", "Flat (B)", "ratio");
println!(
"{:>8} {:>12} {:>12} {:>10}",
"N", "Merkle (B)", "Flat (B)", "ratio"
);
for &n in &[10usize, 100, 1_000, 10_000] {
let tree = RevisionMerkleTree::build(&make_entries(n));
let merkle_sz = tree.serialise().len();
let flat_sz = n * 60;
let flat_sz = n * 60;
println!(
"{:>8} {:>12} {:>12} {:>10.2}x",
n, merkle_sz, flat_sz,
n,
merkle_sz,
flat_sz,
flat_sz as f64 / merkle_sz as f64
);
}
+22 -19
View File
@@ -66,7 +66,10 @@ fn bench_write_one_revision(c: &mut Criterion) {
b.iter(|| {
let mut s = onion.begin_session(None).unwrap();
for i in 0u64..4 {
s.record_page(i * PAGE_SIZE as u64, black_box(&vec![0xCDu8; PAGE_SIZE as usize]));
s.record_page(
i * PAGE_SIZE as u64,
black_box(&vec![0xCDu8; PAGE_SIZE as usize]),
);
}
black_box(onion.commit_session(s, None).unwrap());
});
@@ -83,15 +86,15 @@ fn bench_reconstruct_revision(c: &mut Criterion) {
let (_f, _h5, onion, base) = tmp_onion_with_n(depth);
let target_rev = (depth - 1) as u64;
group.bench_with_input(
BenchmarkId::new("no_snapshot", depth),
&depth,
|b, _| {
b.iter(|| {
black_box(onion.reconstruct_revision(target_rev, black_box(&base)).unwrap());
});
},
);
group.bench_with_input(BenchmarkId::new("no_snapshot", depth), &depth, |b, _| {
b.iter(|| {
black_box(
onion
.reconstruct_revision(target_rev, black_box(&base))
.unwrap(),
);
});
});
}
// With snapshot: create a real snapshot at midpoint via create_snapshot()
@@ -107,15 +110,15 @@ fn bench_reconstruct_revision(c: &mut Criterion) {
}
let target_rev = onion.revision_count() - 1;
group.bench_with_input(
BenchmarkId::new("with_snapshot", depth),
&depth,
|b, _| {
b.iter(|| {
black_box(onion.reconstruct_revision(target_rev, black_box(&base)).unwrap());
});
},
);
group.bench_with_input(BenchmarkId::new("with_snapshot", depth), &depth, |b, _| {
b.iter(|| {
black_box(
onion
.reconstruct_revision(target_rev, black_box(&base))
.unwrap(),
);
});
});
}
group.finish();
+21 -17
View File
@@ -35,7 +35,9 @@ fn make_f32_random(n_bytes: usize) -> Vec<u8> {
let mut state = 0x_dead_beef_u64;
let mut out = Vec::with_capacity(n_bytes);
while out.len() < n_bytes {
state = state.wrapping_mul(6364136223846793005).wrapping_add(1442695040888963407);
state = state
.wrapping_mul(6364136223846793005)
.wrapping_add(1442695040888963407);
out.extend_from_slice(&(state as u32).to_le_bytes());
}
out.truncate(n_bytes);
@@ -72,16 +74,13 @@ fn bench_tdt_compress(c: &mut Criterion) {
let sizes = [4096usize, 65536];
let datasets: &[(&str, fn(usize) -> Vec<u8>, usize)] = &[
("f32_smooth", make_f32_smooth, 4),
("f32_random", make_f32_random, 4),
("f32_smooth", make_f32_smooth, 4),
("f32_random", make_f32_random, 4),
("int32_random", make_int32_random, 4),
("int8_seq", make_int8_seq, 1),
("int8_seq", make_int8_seq, 1),
];
let codecs = [
("zstd", Codec::Zstd),
("zstd_tdt", Codec::ZstdTdt),
];
let codecs = [("zstd", Codec::Zstd), ("zstd_tdt", Codec::ZstdTdt)];
// ── Throughput benchmark ──────────────────────────────────────────────────
let mut group = c.benchmark_group("tdt_compress/throughput");
@@ -90,10 +89,7 @@ fn bench_tdt_compress(c: &mut Criterion) {
let data = make(size);
group.throughput(Throughput::Bytes(size as u64));
for &(codec_name, codec) in &codecs {
let id = BenchmarkId::new(
format!("{codec_name}/{dtype}"),
format!("{size}B"),
);
let id = BenchmarkId::new(format!("{codec_name}/{dtype}"), format!("{size}B"));
group.bench_with_input(id, &data, |b, d| {
b.iter(|| bench_compress(d, codec));
});
@@ -126,16 +122,24 @@ fn bench_tdt_compress(c: &mut Criterion) {
// ── Compression ratio summary (printed, not timed) ───────────────────────
// Run once outside Criterion to print ratio comparison.
println!("\n─── TDT compression ratio summary ───");
println!("{:<20} {:>8} {:>10} {:>10} {:>8}",
"dataset/size", "orig", "zstd", "zstd_tdt", "savings");
println!(
"{:<20} {:>8} {:>10} {:>10} {:>8}",
"dataset/size", "orig", "zstd", "zstd_tdt", "savings"
);
for &size in &sizes {
for &(dtype, make, _w) in datasets {
let data = make(size);
let zstd_size = compress_page(&data, Codec::Zstd).unwrap().len();
let tdt_size = compress_page(&data, Codec::ZstdTdt).unwrap().len();
let tdt_size = compress_page(&data, Codec::ZstdTdt).unwrap().len();
let savings_pct = 100.0 * (1.0 - tdt_size as f64 / zstd_size as f64);
println!("{:<20} {:>8} {:>10} {:>10} {:>7.1}%",
format!("{dtype}/{size}B"), size, zstd_size, tdt_size, savings_pct);
println!(
"{:<20} {:>8} {:>10} {:>10} {:>7.1}%",
format!("{dtype}/{size}B"),
size,
zstd_size,
tdt_size,
savings_pct
);
}
}
println!();