Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions benches/support/workloads/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<Vec<_>>();
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(
Expand Down
14 changes: 14 additions & 0 deletions tests/benchmark_startup_recovery_contract.rs
Original file line number Diff line number Diff line change
@@ -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);
}