From a706e34616a71666f23aee003805efac1a95985e Mon Sep 17 00:00:00 2001 From: Jeff Repanich <149295+smiggleworth@users.noreply.github.com> Date: Fri, 21 Aug 2026 18:13:43 -0400 Subject: [PATCH] bench: bound durable fixture write batches --- benches/support/workloads/context.rs | 19 +++++++++++-------- tests/benchmark_startup_recovery_contract.rs | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 tests/benchmark_startup_recovery_contract.rs diff --git a/benches/support/workloads/context.rs b/benches/support/workloads/context.rs index 3147b45..ac56b9c 100644 --- a/benches/support/workloads/context.rs +++ b/benches/support/workloads/context.rs @@ -36,6 +36,7 @@ pub struct BenchContext { pub const ANALYTICAL_BENCHMARK_QUERY_MEMORY_BYTES: usize = 64 * 1024 * 1024; pub const LARGE_ANALYTICAL_BENCHMARK_QUERY_MEMORY_BYTES: usize = 96 * 1024 * 1024; pub const LARGE_ANALYTICAL_BENCHMARK_QUERY_TIMEOUT_MS: u64 = 120_000; +const BENCH_DOCUMENT_WRITE_BATCH_ROWS: usize = 10_000; #[derive(Debug, Clone, serde::Serialize)] pub struct QueryBreakdownMicros { @@ -701,15 +702,17 @@ fn create_bench_fulltext_index( } fn put_bench_documents(ctx: &BenchContext, dataset_rows: usize) -> Result<(), CassieError> { - let documents = build_bench_documents(dataset_rows); - if documents.is_empty() { - return Ok(()); + let mut documents = build_bench_documents(dataset_rows).into_iter(); + loop { + let batch = documents + .by_ref() + .take(BENCH_DOCUMENT_WRITE_BATCH_ROWS) + .collect::>(); + if batch.is_empty() { + return Ok(()); + } + ctx.cassie.midge.put_documents(&ctx.collection, batch)?; } - - ctx.cassie - .midge - .put_documents(&ctx.collection, documents) - .map(|_| ()) } pub(super) fn build_bench_documents( diff --git a/tests/benchmark_startup_recovery_contract.rs b/tests/benchmark_startup_recovery_contract.rs new file mode 100644 index 0000000..23e8865 --- /dev/null +++ b/tests/benchmark_startup_recovery_contract.rs @@ -0,0 +1,14 @@ +#[test] +fn should_bound_durable_benchmark_document_write_batches() { + // Arrange + let fixture = include_str!("../benches/support/workloads/context.rs"); + + // Act + let declares_bounded_batch = + fixture.contains("const BENCH_DOCUMENT_WRITE_BATCH_ROWS: usize = 10_000;"); + let writes_bounded_batches = fixture.contains(".take(BENCH_DOCUMENT_WRITE_BATCH_ROWS)"); + + // Assert + assert!(declares_bounded_batch); + assert!(writes_bounded_batches); +}