mz_persist_client/
internals_bench.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! Benchmarks of internal code not exposed through the public API.
11
12#![allow(missing_docs)]
13
14use std::hint::black_box;
15use std::time::Instant;
16
17use differential_dataflow::trace::Description;
18use timely::progress::Antichain;
19use tracing::info;
20
21use crate::internal::state::HollowBatch;
22use crate::internal::trace::Trace;
23
24pub fn trace_push_batch_one_iter(num_batches: usize) {
25    let mut trace = Trace::<usize>::default();
26    let mut start = Instant::now();
27    for ts in 0..num_batches {
28        if ts % 1000 == 0 {
29            info!("{} {:?}", ts, start.elapsed());
30            start = Instant::now();
31        }
32        // A single non-empty batch followed by a large number of empty batches
33        // and no compaction. This is a particularly problematic workload for
34        // our fork of Spine which came up during deserialization of State in
35        // database-issues#4985.
36        //
37        // Other, much better handled, workloads include all empty or all
38        // non-empty.
39        let len = if ts == 0 { 1 } else { 0 };
40        let _ = trace.push_batch(HollowBatch::new_run(
41            Description::new(
42                Antichain::from_elem(ts),
43                Antichain::from_elem(ts + 1),
44                Antichain::from_elem(0),
45            ),
46            vec![],
47            len,
48        ));
49    }
50    black_box(trace);
51}