MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / bench_append

Function bench_append

crates/commitlog/benches/write.rs:40–81  ·  view source on GitHub ↗
(c: &mut Criterion, label: &str, params: Params)

Source from the content-addressed store, hash-verified

38}
39
40fn bench_append(c: &mut Criterion, label: &str, params: Params) {
41 let id = BenchmarkId::from_parameter(&params);
42 c.benchmark_group(label)
43 .sample_size(10)
44 .sampling_mode(SamplingMode::Flat)
45 .throughput(Throughput::Elements(params.total_appends))
46 .bench_with_input(
47 id,
48 &params,
49 |b,
50 Params {
51 payloads,
52 txs_per_commit,
53 total_appends,
54 fsync_every,
55 }| {
56 let tmp = tempdir_in(".").unwrap();
57 let dir = CommitLogDir::from_path_unchecked(tmp.path());
58 let clog = Commitlog::open(dir, Options::default(), None).unwrap();
59 let mut offset = clog.max_committed_offset().unwrap_or_default();
60
61 b.iter(|| {
62 let mut payloads = payloads.iter().cycle();
63 for i in 0..*total_appends {
64 clog.commit(payloads.by_ref().take(txs_per_commit.get() as usize).map(|payload| {
65 let tx = Transaction {
66 offset,
67 txdata: payload,
68 };
69 offset += 1;
70 tx
71 }))
72 .unwrap();
73 if i % fsync_every == 0 {
74 clog.flush_and_sync().unwrap();
75 }
76 }
77 clog.flush_and_sync().unwrap();
78 })
79 },
80 );
81}
82
83fn baseline(c: &mut Criterion) {
84 let params = Params::with_payloads([Payload::new([b'z'; 64])]);

Callers 4

baselineFunction · 0.85
large_payloadFunction · 0.85
mixed_payloadsFunction · 0.85

Calls 11

iterMethod · 0.65
commitMethod · 0.65
openFunction · 0.50
throughputMethod · 0.45
unwrapMethod · 0.45
pathMethod · 0.45
max_committed_offsetMethod · 0.45
mapMethod · 0.45
takeMethod · 0.45
getMethod · 0.45
flush_and_syncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…