Skip to content

Conversation

travis79
Copy link
Member

@travis79 travis79 commented Jul 24, 2025

This adds some very basic benchmarks to some of the labeled/dual-labeled metrics.

You can run these locally using cargo bench. To run a specific set of benches: cargo bench --bench dual_labeled_counter

This adds some very basic benchmarks to some of the labeled/dual-labeled metrics.

You can run these locally using `cargo bench`. To run a specific set of benches: `cargo bench --bench dual_labeled_counter`
@travis79 travis79 force-pushed the marking-some-benches branch from b8ac836 to 57e4292 Compare July 24, 2025 11:51
@travis79 travis79 changed the title Marking some benches Add criterion crate and benchmarks for some metric types Jul 24, 2025
Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

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

These benchmarks don't actually test what you intended.

You're using the glean-core types, but calling the dispatched methods.
Because Glean is never initialized, the dispatcher will never actually run and thus the majority of the work won't be executed.

I think it would make more sense to move those benchmarks into the RLB and use the glean::private::* types after initializing Glean.
And then we probably also need at least one call to test_get_value at the end of each benchmark to ensure the dispatcher is actually going through all tasks, otherwise all we measure is how fast we can put things on to the dispatcher queue.

c.bench_function("dual_labeled_counter_get_and_add", |b| {
b.iter(|| {
for (k, c) in &keys {
let m = black_box(metric.get(k, c));
Copy link
Member

Choose a reason for hiding this comment

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

This black_box doesn't make sense. You're using the return value, so it won't be eliminated anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, I was using it under the assumption that it would encourage the compiler to not optimize this. I'll rework this and move things to the RLB as you suggest. Thanks for the pointers here, benchmarking things like this is new territory for me :)

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.

2 participants