Skip to content

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Oct 2, 2025

This improves the concurrent performance of the histogram reservoir's Offer function by 10x (i.e. 90% reduction).

Accomplish this by:

  • Use atomic.Value instead of locking.
  • Store references to measurements, rather than measurements themselves for better store/load performance.
  • Avoid allocations for measurements using a sync pool.
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric/exemplar
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                           │  main24.txt   │              new24.txt              │
                           │    sec/op     │    sec/op     vs base               │
FixedSizeReservoirOffer-24    254.8n ±  4%   246.6n ±  8%        ~ (p=0.394 n=6)
HistogramReservoirOffer-24   257.40n ± 10%   24.35n ± 12%  -90.54% (p=0.002 n=6)
geomean                       256.1n         77.50n        -69.74%

                           │  main24.txt  │             new24.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  │             new24.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%               ²

Depends on #7441. Marking as a draft until that is merged.

Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.7%. Comparing base (0c97dfd) to head (77db4ee).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7443   +/-   ##
=====================================
  Coverage   85.7%   85.7%           
=====================================
  Files        287     287           
  Lines      25347   25359   +12     
=====================================
+ Hits       21744   21757   +13     
+ Misses      3222    3220    -2     
- Partials     381     382    +1     
Files with missing lines Coverage Δ
sdk/metric/exemplar/histogram_reservoir.go 92.0% <100.0%> (-1.4%) ⬇️
sdk/metric/exemplar/storage.go 96.6% <100.0%> (-3.4%) ⬇️

... 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_histogram_reservoir branch from 7c1476f to 7b79e43 Compare October 7, 2025 14:40
dashpole added a commit that referenced this pull request Oct 7, 2025
Forked from this discussion here:
#7443 (comment)

It seems like a good idea for us as a group to align on and document
what we are comfortable with in terms of how ordered measurements are
reflected in collected metric data.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@pellared pellared mentioned this pull request Oct 10, 2025
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