Add build flag to disable labels
fralalonde opened this issue · 1 comments
fralalonde commented
Metric Labels have a small runtime performance impact even if they're not used:
With labels
test aggregate::bucket::bench::aggregate_counter ... bench: 17 ns/iter (+/- 0)
test aggregate::bucket::bench::aggregate_marker ... bench: 10 ns/iter (+/- 1)
test core::bench::time_bench_direct_dispatch_event ... bench: 10 ns/iter (+/- 0)
test core::proxy::bench::proxy_marker_to_aggregate ... bench: 29 ns/iter (+/- 0)
test core::proxy::bench::proxy_marker_to_void ... bench: 28 ns/iter (+/- 1)
Without labels:
test aggregate::bucket::bench::aggregate_counter ... bench: 13 ns/iter (+/- 0)
test aggregate::bucket::bench::aggregate_marker ... bench: 8 ns/iter (+/- 1)
test core::bench::time_bench_direct_dispatch_event ... bench: 8 ns/iter (+/- 0)
test core::proxy::bench::proxy_marker_to_aggregate ... bench: 22 ns/iter (+/- 0)
test core::proxy::bench::proxy_marker_to_void ... bench: 22 ns/iter (+/- 4)
This is possibly due to the extra parameter being passed around. A build flag could disable the use of labels to regain the extra perf when they're not needed.
fralalonde commented
Turns out labels have an even bigger perf cost but which is mostly optimized away if they aren't used as in the benchmarks above. Not sure there's a way around it other than creating a completely separate call path, which is more trouble than its worth. If you need labels, you pay for labels.
test aggregate::bucket::bench::aggregate_counter ... bench: 82 ns/iter (+/- 4)
test aggregate::bucket::bench::aggregate_marker ... bench: 77 ns/iter (+/- 21)
test core::bench::time_bench_direct_dispatch_event ... bench: 77 ns/iter (+/- 4)
test core::proxy::bench::proxy_marker_to_aggregate ... bench: 94 ns/iter (+/- 3)
test core::proxy::bench::proxy_marker_to_void ... bench: 98 ns/iter (+/- 4)