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

feat(benchmarks): Write better benchmark for testing the aggregator #3839

Merged
merged 8 commits into from
Jul 22, 2024

Conversation

iambriccardo
Copy link
Member

@iambriccardo iambriccardo commented Jul 19, 2024

This PR reworks the benchmarks for the aggregator by adding more fine-grained control over certain parameters.

Closes: #3844

#skip-changelog

relay-metrics/benches/benches.rs Outdated Show resolved Hide resolved
relay-metrics/benches/benches.rs Outdated Show resolved Hide resolved
relay-metrics/benches/benches.rs Outdated Show resolved Hide resolved
relay-metrics/benches/benches.rs Outdated Show resolved Hide resolved
];

for input in &inputs {
for (input_name, input) in &inputs {
c.bench_with_input(
Copy link
Member

Choose a reason for hiding this comment

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

Can make a criterion group here and specify throughput, compare to here

g.throughput(criterion::Throughput::Elements(params.rounds as u64));

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nice!

},
|(mut aggregator, buckets)| {
for (project_key, bucket) in buckets {
aggregator.merge(project_key, bucket, None).unwrap();
#[allow(clippy::unit_arg)]
black_box(aggregator.merge(project_key, bucket, None).unwrap());
Copy link
Member

Choose a reason for hiding this comment

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

I think the black box should be on the aggregator after the loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought that black_box is handled specifically by the compiler just by wrapping an expression with it. Maybe I need to better read the docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I read the docs, it's indeed doing some stuff with the result value, treating it pessimistically.

Copy link
Member

Choose a reason for hiding this comment

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

The result value here is just the unit type. I am not sure what the compiler is allowed to optimize here, but for me it makes more sense on the "result".

@iambriccardo iambriccardo marked this pull request as ready for review July 22, 2024 09:43
@iambriccardo iambriccardo requested a review from a team as a code owner July 22, 2024 09:43
relay-metrics/Cargo.toml Outdated Show resolved Hide resolved
relay-metrics/benches/benches.rs Outdated Show resolved Hide resolved
@iambriccardo iambriccardo merged commit ab8210f into master Jul 22, 2024
23 checks passed
@iambriccardo iambriccardo deleted the riccardo/feat/improve-benchmark branch July 22, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve benchmarks for the aggregator
2 participants