Skip to content

Last value aggregations use volatile instead of atomics#8560

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
jack-berg:optimize-last-value
Jul 2, 2026
Merged

Last value aggregations use volatile instead of atomics#8560
jack-berg merged 1 commit into
open-telemetry:mainfrom
jack-berg:optimize-last-value

Conversation

@jack-berg

Copy link
Copy Markdown
Member

Huge win in last value aggregation performance by ussing a volatile instead of atomics. The realization is that atomics aren't required because the tracking of whether values are recorded is done in the parent AggregatorHandle, meaning the actual aggregator itself is never collected if there are no values. Thus it doesn't need to reset to an "unset" state.

Hopefully this also reduces the variance of gauge performance cases, which have been unreliable.

Benchmark Threads Temporality Cardinality Instrument Baseline (ops/s) After (ops/s) Δ ops/s Δ %
threads1 1 CUMULATIVE 1 COUNTER_SUM 158,568,637 157,302,401 -1,266,235 -0.8%
threads1 1 CUMULATIVE 1 GAUGE_LAST_VALUE 84,391,938 177,561,358 +93,169,419 +110.4%
threads1 1 CUMULATIVE 1 HISTOGRAM_BASE2_EXPONENTIAL 42,063,874 39,226,998 -2,836,876 -6.7%
threads1 1 CUMULATIVE 1 HISTOGRAM_EXPLICIT 96,618,066 97,039,201 +421,135 +0.4%
threads1 1 CUMULATIVE 1 UP_DOWN_COUNTER_SUM 155,066,532 155,220,291 +153,759 +0.1%
threads1 1 CUMULATIVE 128 COUNTER_SUM 113,296,533 112,512,651 -783,882 -0.7%
threads1 1 CUMULATIVE 128 GAUGE_LAST_VALUE 133,640,492 143,589,227 +9,948,735 +7.4%
threads1 1 CUMULATIVE 128 HISTOGRAM_BASE2_EXPONENTIAL 42,456,092 41,839,011 -617,081 -1.5%
threads1 1 CUMULATIVE 128 HISTOGRAM_EXPLICIT 68,795,746 68,355,287 -440,459 -0.6%
threads1 1 CUMULATIVE 128 UP_DOWN_COUNTER_SUM 110,120,331 109,630,704 -489,627 -0.4%
threads1 1 DELTA 1 COUNTER_SUM 116,642,454 115,575,628 -1,066,826 -0.9%
threads1 1 DELTA 1 GAUGE_LAST_VALUE 41,310,133 124,167,205 +82,857,072 +200.6%
threads1 1 DELTA 1 HISTOGRAM_BASE2_EXPONENTIAL 42,801,022 41,251,394 -1,549,628 -3.6%
threads1 1 DELTA 1 HISTOGRAM_EXPLICIT 58,788,702 61,217,877 +2,429,175 +4.1%
threads1 1 DELTA 1 UP_DOWN_COUNTER_SUM 113,438,421 112,345,626 -1,092,794 -1.0%
threads1 1 DELTA 128 COUNTER_SUM 90,648,633 89,443,733 -1,204,900 -1.3%
threads1 1 DELTA 128 GAUGE_LAST_VALUE 30,048,822 104,916,888 +74,868,066 +249.2%
threads1 1 DELTA 128 HISTOGRAM_BASE2_EXPONENTIAL 40,351,625 40,868,681 +517,056 +1.3%
threads1 1 DELTA 128 HISTOGRAM_EXPLICIT 68,966,473 69,167,930 +201,457 +0.3%
threads1 1 DELTA 128 UP_DOWN_COUNTER_SUM 96,706,975 93,188,151 -3,518,824 -3.6%
threads4 4 CUMULATIVE 1 COUNTER_SUM 71,299,570 72,529,285 +1,229,715 +1.7%
threads4 4 CUMULATIVE 1 GAUGE_LAST_VALUE 31,089,443 66,748,976 +35,659,533 +114.7%
threads4 4 CUMULATIVE 1 HISTOGRAM_BASE2_EXPONENTIAL 18,315,218 16,773,898 -1,541,319 -8.4%
threads4 4 CUMULATIVE 1 HISTOGRAM_EXPLICIT 17,130,737 20,587,648 +3,456,911 +20.2%
threads4 4 CUMULATIVE 1 UP_DOWN_COUNTER_SUM 67,441,580 70,858,140 +3,416,560 +5.1%
threads4 4 CUMULATIVE 128 COUNTER_SUM 101,917,926 106,807,936 +4,890,011 +4.8%
threads4 4 CUMULATIVE 128 GAUGE_LAST_VALUE 99,772,907 151,544,793 +51,771,886 +51.9%
threads4 4 CUMULATIVE 128 HISTOGRAM_BASE2_EXPONENTIAL 69,414,310 69,808,432 +394,122 +0.6%
threads4 4 CUMULATIVE 128 HISTOGRAM_EXPLICIT 71,859,876 73,052,921 +1,193,044 +1.7%
threads4 4 CUMULATIVE 128 UP_DOWN_COUNTER_SUM 102,675,867 102,818,613 +142,746 +0.1%
threads4 4 DELTA 1 COUNTER_SUM 17,860,366 17,215,213 -645,154 -3.6%
threads4 4 DELTA 1 GAUGE_LAST_VALUE 18,414,726 18,575,692 +160,967 +0.9%
threads4 4 DELTA 1 HISTOGRAM_BASE2_EXPONENTIAL 10,272,237 10,723,117 +450,879 +4.4%
threads4 4 DELTA 1 HISTOGRAM_EXPLICIT 12,299,067 12,034,402 -264,665 -2.2%
threads4 4 DELTA 1 UP_DOWN_COUNTER_SUM 17,354,541 18,025,717 +671,175 +3.9%
threads4 4 DELTA 128 COUNTER_SUM 70,640,757 69,943,441 -697,316 -1.0%
threads4 4 DELTA 128 GAUGE_LAST_VALUE 52,635,745 82,263,039 +29,627,294 +56.3%
threads4 4 DELTA 128 HISTOGRAM_BASE2_EXPONENTIAL 52,465,326 53,754,789 +1,289,463 +2.5%
threads4 4 DELTA 128 HISTOGRAM_EXPLICIT 53,967,236 54,678,786 +711,551 +1.3%
threads4 4 DELTA 128 UP_DOWN_COUNTER_SUM 68,654,779 68,744,860 +90,081 +0.1%

@jack-berg
jack-berg requested a review from a team as a code owner July 1, 2026 19:32
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.93%. Comparing base (ed81bf2) to head (d23bfa1).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8560      +/-   ##
============================================
- Coverage     90.97%   90.93%   -0.04%     
+ Complexity    10206    10204       -2     
============================================
  Files          1013     1013              
  Lines         27166    27158       -8     
  Branches       3182     3180       -2     
============================================
- Hits          24713    24696      -17     
- Misses         1729     1738       +9     
  Partials        724      724              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg
jack-berg merged commit 3101d38 into open-telemetry:main Jul 2, 2026
28 checks passed
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