Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method and benchmarks for pooling metric options (#6394)
This PR improves the `RecordMetrics()` allocations using a pool for the `metric.AddOption` slice. `benchstat main.txt pool.txt`: ``` goos: darwin goarch: arm64 pkg: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv cpu: Apple M1 Max │ main.txt │ pool.txt │ │ sec/op │ sec/op vs base │ RecordMetrics/empty-10 4.513n ± 3% 4.620n ± 0% +2.38% (p=0.037 n=10) RecordMetrics/nil_meter-10 341.8n ± 1% 330.7n ± 4% -3.26% (p=0.022 n=10) RecordMetrics/with_Meter-10 341.1n ± 1% 330.0n ± 1% -3.27% (p=0.000 n=10) geomean 80.74n 79.59n -1.42% │ main.txt │ pool.txt │ │ B/op │ B/op vs base │ RecordMetrics/empty-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ RecordMetrics/nil_meter-10 696.0 ± 0% 680.0 ± 0% -2.30% (p=0.000 n=10) RecordMetrics/with_Meter-10 696.0 ± 0% 680.0 ± 0% -2.30% (p=0.000 n=10) geomean ² -1.54% ² ¹ all samples are equal ² summaries must be >0 to compute geomean │ main.txt │ pool.txt │ │ allocs/op │ allocs/op vs base │ RecordMetrics/empty-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ RecordMetrics/nil_meter-10 6.000 ± 0% 5.000 ± 0% -16.67% (p=0.000 n=10) RecordMetrics/with_Meter-10 6.000 ± 0% 5.000 ± 0% -16.67% (p=0.000 n=10) geomean ² -11.45% ² ¹ all samples are equal ² summaries must be >0 to compute geomean ``` Fixes #5968 --------- Co-authored-by: Damien Mathieu <[email protected]> Co-authored-by: Tyler Yahn <[email protected]>
- Loading branch information