Skip to content

Fix WallClockASGCT::timerLoop skipping every other thread (PROF-14332)#493

Merged
jbachorik merged 1 commit intomainfrom
muse/impl-20260422-124935
Apr 23, 2026
Merged

Fix WallClockASGCT::timerLoop skipping every other thread (PROF-14332)#493
jbachorik merged 1 commit intomainfrom
muse/impl-20260422-124935

Conversation

@jbachorik
Copy link
Copy Markdown
Collaborator

What does this PR do?:

Fixes a bug in WallClockASGCT::timerLoop where the collectThreads lambda's no-filter fallback advances the ThreadList iterator twice per loop body, silently skipping every other thread when the wallclock thread filter is disabled.

The fix removes one spurious tid = thread_list->next(); call at the tail of the loop in ddprof-lib/src/main/cpp/wallClock.cpp. The while (thread_list->hasNext()) { tid = thread_list->next(); ... } pattern now correctly reads one tid per iteration.

Motivation:

When threadFilter->enabled() is false (no context-based wallclock filtering), every wallclock tick was sampling only half the eligible threads, producing under-sampled wallclock profiles. The typical context-filtered path is unaffected; this only bit on the fallback.

Flagged by a muse chorus review as an unrelated pre-existing bug and filed separately so it can land on its own small PR.

Additional Notes:

Pre-existing bug — not introduced by any recent change. Scope is intentionally narrow: only the redundant next() call is removed. Related concerns (e.g. ThreadList::next() lacking an internal bounds check for misuse) are pre-existing API issues and out of scope for this PR.

How to test the change?:

Manual validation: run the wallclock profiler with the context-based thread filter disabled and confirm all eligible threads appear in the sampled output rather than every other one. The change is a 1-line deletion inside the threadFilter->enabled() == false branch; the filter-enabled path is untouched.

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-14332

🤖 Generated with Claude Code via muse implement

Remove the spurious extra ThreadList::next() call in the no-filter
fallback branch of collectThreads. The loop already reads one tid per
iteration via the hasNext()/next() pattern; the trailing next() advanced
the cursor a second time, so tids was populated with only the 1st, 3rd,
5th, ... entries.

Impact: when threadFilter->enabled() is false, wallclock ticks sampled
only half of eligible threads. The context-filtered path is unaffected.

JIRA: PROF-14332

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an iteration bug in WallClockASGCT::timerLoop()’s “no thread filter” fallback path where ThreadList::next() was being called twice per loop iteration, causing every other thread to be skipped when collecting tids for wallclock sampling.

Changes:

  • Remove a redundant thread_list->next() call inside the threadFilter->enabled() == false branch of WallClockASGCT::timerLoop().
  • Ensure the fallback while (thread_list->hasNext()) { int tid = thread_list->next(); ... } pattern consumes exactly one thread id per iteration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 22, 2026

CI Test Results

Run: #24785852534 | Commit: 4eb9eb8 | Duration: 25m 11s (longest job)

All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-04-23 15:05:12 UTC

@jbachorik jbachorik marked this pull request as ready for review April 22, 2026 11:56
@jbachorik jbachorik requested a review from a team as a code owner April 22, 2026 11:56
@jbachorik jbachorik merged commit bfb60cd into main Apr 23, 2026
302 of 341 checks passed
@jbachorik jbachorik deleted the muse/impl-20260422-124935 branch April 23, 2026 20:04
@github-actions github-actions Bot added this to the 1.40.1 milestone Apr 23, 2026
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