Skip to content

Commit

Permalink
Add bench for batch points
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Dec 16, 2022
1 parent 4773607 commit 53dfd61
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions crates/re_query/benches/obj_query_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn obj_mono_points(c: &mut Criterion) {
.into_iter()
.map(move |point_idx| obj_path!("points", Index::Sequence(point_idx as _)))
.collect_vec();
let msgs = mono_data_messages(&paths);
let msgs = build_messages(&paths, 1);

{
let mut group = c.benchmark_group("obj_mono_points");
Expand All @@ -58,12 +58,39 @@ fn obj_mono_points(c: &mut Criterion) {
}
}

criterion_group!(benches, obj_mono_points,);
fn obj_batch_points(c: &mut Criterion) {
{
// Each mono point gets logged at a different path
let paths = [ObjPath::from("points")];
let msgs = build_messages(&paths, NUM_POINTS as _);

{
let mut group = c.benchmark_group("obj_batch_points");
group.throughput(criterion::Throughput::Elements(
(NUM_POINTS * NUM_FRAMES) as _,
));
group.bench_function("insert", |b| {
b.iter(|| insert_messages(msgs.iter()));
});
}

{
let mut group = c.benchmark_group("obj_batch_points");
group.throughput(criterion::Throughput::Elements(NUM_POINTS as _));
let mut store = insert_messages(msgs.iter());
group.bench_function("query", |b| {
b.iter(|| query_and_visit(&mut store, &paths));
});
}
}
}

criterion_group!(benches, obj_mono_points, obj_batch_points);
criterion_main!(benches);

// --- Helpers ---

fn mono_data_messages(paths: &[ObjPath]) -> Vec<MsgBundle> {
fn build_messages(paths: &[ObjPath], pts: usize) -> Vec<MsgBundle> {
(0..NUM_FRAMES)
.into_iter()
.flat_map(move |frame_idx| {
Expand All @@ -72,7 +99,7 @@ fn mono_data_messages(paths: &[ObjPath]) -> Vec<MsgBundle> {
MsgId::ZERO,
path.clone(),
[build_frame_nr(frame_idx as _)],
(build_some_point2d(1), build_some_colors(1)),
(build_some_point2d(pts), build_some_colors(pts)),
)
.unwrap()
})
Expand Down Expand Up @@ -100,7 +127,7 @@ fn query_and_visit(store: &mut DataStore, paths: &[ObjPath]) {

for path in paths.iter() {
if let Ok(df) = query_entity_with_primary(
&store,
store,
&timeline_query,
path,
Point2D::NAME,
Expand Down

1 comment on commit 53dfd61

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: 53dfd61 Previous: d2cf10b Ratio
datastore/batch/rects/insert 1685918 ns/iter (± 8589) 1663360 ns/iter (± 9671) 1.01
datastore/batch/rects/query 1331 ns/iter (± 0) 1320 ns/iter (± 11) 1.01
obj_mono_points/insert 870960845 ns/iter (± 3957706) 1005976957 ns/iter (± 4768465) 0.87
obj_mono_points/query 345115 ns/iter (± 3185) 339183 ns/iter (± 1887) 1.02
obj_batch_points/insert 89614513 ns/iter (± 453869) 96265981 ns/iter (± 979624) 0.93
obj_batch_points/query 11350 ns/iter (± 22) 11275 ns/iter (± 96) 1.01
obj_batch_points_sequential/insert 23008225 ns/iter (± 31033) 22272144 ns/iter (± 474816) 1.03
obj_batch_points_sequential/query 5655 ns/iter (± 29) 5625 ns/iter (± 35) 1.01
obj_batch_points_sequential/Tuid::random 37 ns/iter (± 0) 37 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.