Skip to content

[SDK] Compact metric storage after stream removal - #7945

Merged
martincostello merged 5 commits into
open-telemetry:mainfrom
matt-hensley:matt-hensley/metric-churn
Oct 15, 2026
Merged

martincostello merged 5 commits into
open-telemetry:mainfrom
matt-hensley:matt-hensley/metric-churn

Conversation

@matt-hensley

@matt-hensley matt-hensley commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Removed metric streams leave empty slots in the reader's storage that the collect path keeps scanning. Collection slows as metric streams churn.

Storage is now compacted during collection, so only active streams are scanned.

Results (same session, same machine; churned vs. clean provider, ratio = churned / clean):

.NET 10.0

Historical streams Temporality Before: clean Before: churned Before: ratio After: clean After: churned After: ratio
16 Cumulative 225.1 ns 231.3 ns 1.03 224.8 ns 226.9 ns 1.01
16 Delta 186.6 ns 187.1 ns 1.00 182.6 ns 180.9 ns 0.99
256 Cumulative 224.5 ns 344.5 ns 1.53 222.3 ns 226.6 ns 1.02
256 Delta 179.4 ns 292.8 ns 1.63 179.2 ns 183.0 ns 1.02
1024 Cumulative 234.8 ns 699.5 ns 2.98 228.0 ns 233.1 ns 1.02
1024 Delta 176.8 ns 654.2 ns 3.70 182.3 ns 178.4 ns 0.98

.NET Framework 4.7.2

Historical streams Temporality Before: clean Before: churned Before: ratio After: clean After: churned After: ratio
16 Cumulative 646.7 ns 660.3 ns 1.02 615.0 ns 631.3 ns 1.03
16 Delta 527.8 ns 527.6 ns 1.00 570.2 ns 504.7 ns 0.89 *
256 Cumulative 616.0 ns 1,128.8 ns 1.83 614.2 ns 622.7 ns 1.01
256 Delta 527.2 ns 1,009.8 ns 1.92 516.2 ns 516.6 ns 1.00
1024 Cumulative 630.9 ns 2,752.2 ns 4.36 614.4 ns 624.1 ns 1.02
1024 Delta 505.2 ns 2,371.8 ns 4.70 498.1 ns 511.9 ns 1.03

** benchmark noise

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, successful build/tests, etc.)
  • Tests added/updated
  • CHANGELOG.md file(s) updated for non-trivial changes
  • Changes in public API reviewed (if applicable)
  • AI usage disclosure:
    • No AI used
    • AI-assisted
    • Bulk AI-generated
  • I have the experience and knowledge necessary to understand, review, and validate all content in this PR1

Footnotes

  1. Yes, I can answer maintainer questions about the content of this PR without using AI. ↩

@github-actions github-actions Bot added pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package perf Performance related labels Oct 14, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-15 07:57 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.28%. Comparing base (e5b5ac6) to head (a21a021).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7945      +/-   ##
==========================================
- Coverage   92.28%   92.28%   -0.01%     
==========================================
  Files         363      363              
  Lines       21022    21038      +16     
==========================================
+ Hits        19401    19414      +13     
- Misses       1621     1624       +3     
Flag Coverage Δ
unittests-Project-Experimental 92.40% <100.00%> (-0.01%) ⬇️
unittests-Project-Stable 92.40% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rc/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs 93.90% <100.00%> (+0.65%) ⬆️

... and 2 files with indirect coverage changes

@matt-hensley
matt-hensley marked this pull request as ready for review October 14, 2026 19:43
@matt-hensley
matt-hensley requested a review from a team as a code owner October 14, 2026 19:43
Comment thread src/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs Outdated
Co-authored-by: Martin Costello <martin@martincostello.com>
This was referenced Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Performance related pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants