Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark to test how expensive mapping into/out of joins is #478

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ harness = false
[[bench]]
name = "symmetric_hash_join"
harness = false

[[bench]]
name = "mapjoinperf"
harness = false
187 changes: 187 additions & 0 deletions benches/benches/mapjoinperf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use hydroflow::hydroflow_syntax;
use rand::{distributions::Uniform, prelude::Distribution, rngs::StdRng, SeedableRng};
use std::hint::black_box;

fn ops(c: &mut Criterion) {
const NUM_INTS: usize = 10_000;
let mut rng = StdRng::from_entropy();

c.bench_function("mapjoinperf/usize_nomapinput_nomapoutput", |b| {
b.iter_batched_ref(
|| {
let dist = Uniform::new(0, 100);
let input0: Vec<(usize, (usize, usize))> = (0..NUM_INTS)
.map(|_| {
(
dist.sample(&mut rng),
(dist.sample(&mut rng), dist.sample(&mut rng)),
)
})
.collect();
let input1: Vec<(usize, ())> =
(0..NUM_INTS).map(|_| (dist.sample(&mut rng), ())).collect();

hydroflow_syntax! {
my_join = join();

source_iter(black_box(input0))
-> [0]my_join;

source_iter(black_box(input1)) -> [1]my_join;

my_join -> for_each(|x| { black_box(x); });
}
},
|df| {
df.run_available();
},
BatchSize::LargeInput,
)
});

c.bench_function("mapjoinperf/usize_mapinput_nomapoutput", |b| {
b.iter_batched_ref(
|| {
let dist = Uniform::new(0, 100);
let input0: Vec<(usize, usize, usize)> = (0..NUM_INTS)
.map(|_| {
(
dist.sample(&mut rng),
dist.sample(&mut rng),
dist.sample(&mut rng),
)
})
.collect();
let input1: Vec<(usize, ())> =
(0..NUM_INTS).map(|_| (dist.sample(&mut rng), ())).collect();

hydroflow_syntax! {
my_join = join();

source_iter(black_box(input0))
-> map(|(a, b, c)| (a, (b, c)))
-> [0]my_join;

source_iter(black_box(input1)) -> [1]my_join;

my_join -> for_each(|x| { black_box(x); });
}
},
|df| {
df.run_available();
},
BatchSize::LargeInput,
)
});

c.bench_function("mapjoinperf/usize_nomapinput_mapoutput", |b| {
b.iter_batched_ref(
|| {
let dist = Uniform::new(0, 100);
let input0: Vec<(usize, (usize, usize))> = (0..NUM_INTS)
.map(|_| {
(
dist.sample(&mut rng),
(dist.sample(&mut rng), dist.sample(&mut rng)),
)
})
.collect();
let input1: Vec<(usize, ())> =
(0..NUM_INTS).map(|_| (dist.sample(&mut rng), ())).collect();

hydroflow_syntax! {
my_join = join();

source_iter(black_box(input0))
-> [0]my_join;

source_iter(black_box(input1)) -> [1]my_join;

my_join
-> map(|(a, ((b, c), ()))| (a, b, c, ()))
-> for_each(|x| { black_box(x); });
}
},
|df| {
df.run_available();
},
BatchSize::LargeInput,
)
});

c.bench_function("mapjoinperf/usize_mapinput_mapoutput", |b| {
b.iter_batched_ref(
|| {
let dist = Uniform::new(0, 100);
let input0: Vec<(usize, usize, usize)> = (0..NUM_INTS)
.map(|_| {
(
dist.sample(&mut rng),
dist.sample(&mut rng),
dist.sample(&mut rng),
)
})
.collect();
let input1: Vec<(usize, ())> =
(0..NUM_INTS).map(|_| (dist.sample(&mut rng), ())).collect();

hydroflow_syntax! {
my_join = join();

source_iter(black_box(input0))
-> map(|(a, b, c)| (a, (b, c)))
-> [0]my_join;

source_iter(black_box(input1)) -> [1]my_join;

my_join
-> map(|(a, ((b, c), ()))| (a, b, c, ()))
-> for_each(|x| { black_box(x); });
}
},
|df| {
df.run_available();
},
BatchSize::LargeInput,
)
});

c.bench_function("mapjoinperf/usize_nomapinput_dupoutput", |b| {
b.iter_batched_ref(
|| {
let dist = Uniform::new(0, 100);
let input0: Vec<(usize, (usize, usize))> = (0..NUM_INTS)
.map(|_| {
(
dist.sample(&mut rng),
(dist.sample(&mut rng), dist.sample(&mut rng)),
)
})
.collect();
let input1: Vec<(usize, ())> =
(0..NUM_INTS).map(|_| (dist.sample(&mut rng), ())).collect();

hydroflow_syntax! {
my_join = join();

source_iter(black_box(input0))
-> [0]my_join;

source_iter(black_box(input1)) -> [1]my_join;

my_join
-> map(|(a, ((b, c), ()))| (a, b, c, c))
-> for_each(|x| { black_box(x); });
}
},
|df| {
df.run_available();
},
BatchSize::LargeInput,
)
});
}

criterion_group!(mapjoinperf, ops,);
criterion_main!(mapjoinperf);