Skip to content

Index counter_data_ by the pool-local thread number in thread_func's exit log - #7838

Merged
hkaiser merged 1 commit into
masterfrom
fix-thread-func-counter-index
Oct 23, 2026
Merged

hkaiser merged 1 commit into
masterfrom
fix-thread-func-counter-index

Conversation

@hkaiser

@hkaiser hkaiser commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

  • The log message at the end of scheduled_thread_pool<Scheduler>::thread_func read counter_data_[global_thread_num], but counter_data_ has one entry per worker of the pool and is indexed by the pool-local thread_num everywhere else (the scheduling loop of the same function uses counter_data_[thread_num]). For every pool except the first one, global_thread_num is offset by the pool's first thread, so the read went past the end of the vector or reported another worker's count. It now uses thread_num.

Any background context you want to provide?

The read only happens when thread manager logging is enabled at level info or above, otherwise the arguments of LTM_(info) are not evaluated, which is probably why it went unnoticed.

This is the same kind of mix-up between pool-local and global worker numbers that #7812 fixes for the scheduler mode setters, but in a different file, so the two PRs don't conflict.

Found while reviewing #7836.

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

…exit log

counter_data_ has one entry per worker of the pool and is indexed by the
pool-local thread number everywhere else. The log message at the end of
thread_func used the global thread number, which for every pool but the
first one reads past the end of the vector or another worker's count.

Signed-off-by: Hartmut Kaiser <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b4f1f0e-ea9a-4060-8f1e-9ac4577003f4
📥 Commits

Reviewing files that changed from the base of the PR and between cacea4d and 59c4609.

📒 Files selected for processing: 1
  • libs/core/thread_pools/include/hpx/thread_pools/scheduled_thread_pool_impl.hpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Corrected thread execution counts in runtime reporting so counts are associated with the appropriate worker thread. This improves the accuracy of per-thread execution statistics.

The thread-exit log now reads the executed-thread count using the local worker index, thread_num, instead of the global thread number.

Changes: Thread exit logging

Layer / File(s) Summary
Use the local worker index
libs/core/thread_pools/include/hpx/thread_pools/scheduled_thread_pool_impl.hpp
The thread-exit log reads the executed-thread count using thread_num instead of global_thread_num.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Possibly related PRs

  • TheHPXProject/hpx#7836: Adds directly executed-thread counts using a pool-local worker index, which this change uses when reading the count for the exit log.

Suggested labels: category: scheduler

Merge Risk: ⚪ Minimal · up to 59c46

No actionable merge-blocking risk remains from this change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the actual change: the exit log in thread_func now indexes counter_data_ by the pool-local thread_num instead of global_thread_num. It matches the raw summary and the PR objectives, an…
Description check Passed The description states the bug, the cause, and the fix. The read used global_thread_num, but counter_data_ is indexed by the pool-local thread_num. For pools after the first, the global number is offs…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: the exit log in thread_func now indexes counter_data_ by the pool-local thread_num instead of global_thread_num. It matches the raw summary and the PR objectives, and it is specific enough for a reviewer scanning history.

Full details: Description check

Explanation

The description states the bug, the cause, and the fix. The read used global_thread_num, but counter_data_ is indexed by the pool-local thread_num. For pools after the first, the global number is offset, which can read past the vector or report another worker's count. The fix changes the index to thread_num. The description also explains when the bug shows up (info-level logging) and how it relates to related PRs. This matches the one-line code change in the raw summary and the PR objectives.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@StellarBot

Copy link
Copy Markdown
Collaborator

Commit 59c460962c74574edef1e8021e239deba7c395d5, Jenkins build 6138

Performance test report
PropertyReferenceCurrent
Run date2026-10-22T11:38:44.798129-05:002026-10-23T10:12:56.327444-05:00
Hostmedusa00.rostam.cct.lsu.edumedusa00.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++/opt/apps/llvm/18.1.8/bin/clang++
Test nameExecutorPercentage Diff.Classification
benchmark_is_heap
hpx::is_heapseq16.67 %+++
Plot
small_vector_benchmark
hpx::small_vectorfxn:void(), 84.67 %++
Plot
stream_report
Stream benchmark - Scaleparallel_executor_default_parallel_policy_allocator0.20 %++
Plot

Explanation of Symbols

The benchmarks ran on medusa00, the results are compared with the references of that node.

Percentage Diff. is the change of the median time relative to the reference, positive values mean faster.

SymbolMeaning
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval within ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected
no referenceNo reference results for this node yet, the plot shows only the current results

@hkaiser
hkaiser merged commit 8416088 into master Oct 23, 2026
87 of 90 checks passed
@hkaiser
hkaiser deleted the fix-thread-func-counter-index branch October 23, 2026 19:11
@hkaiser hkaiser mentioned this pull request Oct 23, 2026
1 of 2 tasks
hkaiser added a commit that referenced this pull request Oct 26, 2026
Describe the PRs merged since release-2.0.X was last rebuilt on master
(#7769, #7784, #7787, #7829, #7832, #7833, #7835, #7836, #7838, #7839, #7845,
#7855, #7858, #7860, #7864, #7865, #7867), and state in the C++20 modules
section and under Breaking changes that applications must include only the
public headers and the generated hpx/modules/<module>.hpp headers, not the
headers inside an HPX module. Regenerate the closed issue and pull request
lists for release-2.0.X at b059b41 against the v1.11.0 tag (795 PRs,
178 issues).

Signed-off-by: Hartmut Kaiser <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants