-
Notifications
You must be signed in to change notification settings - Fork 583
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
Pool metric options created in the otelhttp instrumentation #5968
Comments
This looks to be a straightforward pool for the objects created in |
A benchmark with the See this as an example: opentelemetry-go-contrib/instrumentation/net/http/otelhttp/internal/semconv/bench_test.go Line 19 in a59214f
|
I have implemnted two benchmark functions in
Full test results:
|
Could you open a PR with the code change and benchmark? That would provide the appropriate data to review your analysis. |
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]>
Pooling the options created by otelhttp instrumentation should reduce allocations and improve performance.
Tasks
Originally posted by @MrAlias in #5818 (comment)
The text was updated successfully, but these errors were encountered: