Skip to content

feat: Add opt-in cross-thread statistics for multithreaded counters#2182

Open
shreejaykurhade wants to merge 4 commits into
google:mainfrom
shreejaykurhade:issue-thread-fairness-statistics
Open

feat: Add opt-in cross-thread statistics for multithreaded counters#2182
shreejaykurhade wants to merge 4 commits into
google:mainfrom
shreejaykurhade:issue-thread-fairness-statistics

Conversation

@shreejaykurhade

@shreejaykurhade shreejaykurhade commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses #1902 by enabling visibility into cross-thread imbalance in multithreaded counters.

Currently, only aggregated (summed) counter values are reported, which makes it difficult to assess fairness across benchmark-created threads. This change introduces an opt-in mechanism to compute and report distribution statistics across threads.

When enabled, benchmark-created thread counter values are retained long enough to compute the benchmark’s configured statistics across threads. The existing summed counter row remains unchanged, and additional aggregate rows:

  • _thread_mean
  • _thread_median
  • _thread_stddev
  • _thread_cv

For example, if three benchmark threads report work values 1, 2, and 3, the normal row still reports work=6, while the opt-in thread-stat rows report mean 2, median 2, stddev 1, and cv 50%.

Testing

  • cmake --build build
  • cmake --build build --config Debug
  • ctest --test-dir build --output-on-failure

All 74 CTest tests pass.

@shreejaykurhade

Copy link
Copy Markdown
Contributor Author

@dmah42 please review

@dmah42

dmah42 commented Apr 27, 2026

Copy link
Copy Markdown
Member

is anyone asking for this? i'm beginning to think you've pointed an agent at the codebase and asked it to come up with "improvements".

@shreejaykurhade

shreejaykurhade commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

Yes, this is intended to address #1902, which asks for cross-thread statistics to inspect fairness/imbalance in multithreaded counters.

I do use Codex to understand parts of the codebase (e.g., structure and JSON fields), but the design and implementation here are deliberate.

The change is opt-in and doesn’t affect existing behavior.

Happy to adjust if needed.

@shreejaykurhade

shreejaykurhade commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

@dmah42 check it please

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