Skip to content

[TEST] Add multi-threaded metrics benchmarks: shared vs per-thread counter#3898

Merged
marcalff merged 6 commits intoopen-telemetry:mainfrom
ThomsonTan:per_thread_instrument
Mar 4, 2026
Merged

[TEST] Add multi-threaded metrics benchmarks: shared vs per-thread counter#3898
marcalff merged 6 commits intoopen-telemetry:mainfrom
ThomsonTan:per_thread_instrument

Conversation

@ThomsonTan
Copy link
Copy Markdown
Contributor

@ThomsonTan ThomsonTan commented Mar 3, 2026

Changes

The spinlock protecting the storage of an instrument could be a bottleneck if it is invoked from multiple threads. This PR adds two new benchmarks to compare the performance of shared vs per-thread counter instrument creation under concurrent workloads:

BM_MeasurementsThreadsShareCounterTest - 4 threads share a single DoubleCounter created before the threads start (baseline).
BM_MeasurementsPerThreadCounterTest - 4 threads each create their own DoubleCounter with the same name but a unique description (encoding thread id), so they don't share underlying storage.
Both new benchmarks are structurally identical (same thread count, measurement count, attributes, and Collect call) so their results are directly comparable.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@ThomsonTan ThomsonTan marked this pull request as ready for review March 3, 2026 19:38
@ThomsonTan ThomsonTan requested a review from a team as a code owner March 3, 2026 19:38
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.05%. Comparing base (267f6cd) to head (c4d6ce8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3898   +/-   ##
=======================================
  Coverage   90.05%   90.05%           
=======================================
  Files         226      226           
  Lines        7200     7200           
=======================================
  Hits         6483     6483           
  Misses        717      717           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcalff marcalff merged commit 5a66319 into open-telemetry:main Mar 4, 2026
68 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.

3 participants