Skip to content

Conversation

@dashpole
Copy link
Contributor

@dashpole dashpole commented Oct 2, 2025

Depends on #7441, #7443

This improves the concurrent performance of the fixed size reservoir's Offer function by 3x (i.e. 70% reduction).

TODO: can we do better with per-bucket computation of advance() and reset()?

Accomplish this by:

  • using a single atomic for count and next. This assumes that both can fit in a uint32.
  • only use a lock to guard changing w and next together.
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric/exemplar
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                           │  main24.txt  │            counter24.txt            │
                           │    sec/op    │    sec/op     vs base               │
FixedSizeReservoirOffer-24   252.10n ± 3%   78.96n ±  3%  -68.68% (p=0.002 n=6)
HistogramReservoirOffer-24   258.10n ± 4%   24.18n ± 18%  -90.63% (p=0.002 n=6)
geomean                       255.1n        43.69n        -82.87%

                           │  main24.txt  │           counter24.txt            │
                           │     B/op     │    B/op     vs base                │
FixedSizeReservoirOffer-24   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
HistogramReservoirOffer-24   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                 ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                           │  main24.txt  │           counter24.txt            │
                           │  allocs/op   │ allocs/op   vs base                │
FixedSizeReservoirOffer-24   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
HistogramReservoirOffer-24   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                 ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean
@dashpole dashpole force-pushed the optimize_fixedsize_reservoir branch from bf5b8be to 7705d99 Compare October 2, 2025 16:37
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 92.59259% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.6%. Comparing base (a10652b) to head (a894b33).

Files with missing lines Patch % Lines
sdk/metric/exemplar/fixed_size_reservoir.go 88.6% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #7447     +/-   ##
=======================================
- Coverage   85.7%   85.6%   -0.1%     
=======================================
  Files        284     284             
  Lines      25017   25036     +19     
=======================================
+ Hits       21441   21452     +11     
- Misses      3197    3203      +6     
- Partials     379     381      +2     
Files with missing lines Coverage Δ
sdk/metric/exemplar/histogram_reservoir.go 90.4% <100.0%> (-1.9%) ⬇️
sdk/metric/exemplar/storage.go 96.4% <100.0%> (-3.6%) ⬇️
sdk/metric/exemplar/fixed_size_reservoir.go 95.7% <88.6%> (-2.0%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@dashpole dashpole force-pushed the optimize_fixedsize_reservoir branch 3 times, most recently from 65f0871 to 906bb67 Compare October 3, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant