Repository navigation
Conversation
…rden contention test
|
@DataDog review |
There was a problem hiding this comment.
Open TaskBlock duration can be omitted while a Java-owned wait reacquires its monitor, or when stop succeeds only after a retry. Both paths can close pending segments without reporting their elapsed duration.
🤖 Bits Code Review · Commit bcd7894
| OSThreadState state = block != nullptr ? block->activeBlockState() : OSThreadState::UNKNOWN; | ||
| // Same rejections as the exit: a context crossing or a too-short segment. | ||
| if (identity == nullptr || state == OSThreadState::UNKNOWN || | ||
| !blockedInJvmti(candidate, state) || |
There was a problem hiding this comment.
Preserve Java-owned waits during monitor reacquisition
With Java-owned Object.wait instrumentation, a notified waiter remains inside the call until it reacquires the monitor. JDK 17/21 probes observed BLOCKED while Object.wait remained on the stack. Requiring IN_OBJECT_WAIT therefore rejects a legitimate open interval during reacquisition: dumps omit its duration, and stop closes it without reporting it. Accept monitor-entry blocking for JAVA-owned OBJECT_WAIT runs.
| !blockedInJvmti(candidate, state) || | |
| !(blockedInJvmti(candidate, state) || | |
| (state == OSThreadState::OBJECT_WAIT && | |
| block->activeBlockOwner() == BlockRunOwner::JAVA && | |
| blockedInJvmti(candidate, OSThreadState::MONITOR_WAIT))) || |
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
What each reaction means
- 👍 Useful: correct, and you're fixing it or will.
- 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
- 😕 Unclear: you can't tell what it means or why it matters.
- 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.
🤖 Bits Code Review · Open Bits AI session
| } | ||
| // Stop is a final dump: capture open intervals before TaskBlock is disabled. | ||
| OpenTaskBlockSegments open_segments(_max_stack_depth); | ||
| if (taskBlockEnabled()) open_segments.collect(&_thread_filter, &_block_tracker); |
There was a problem hiding this comment.
Retain open-segment collection when stop is retried
A signal-drain or TaskBlock-rotation timeout returns after disabling TaskBlock, destroying this collector while leaving the profiler RUNNING. A subsequent successful stop skips collection because taskBlockEnabled() is false, then closes all remaining segments without reporting their pending duration. Collection eligibility must survive producer shutdown; update the admission-dependent collection gates in dump and stop consistently, or preserve collection across retries.
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
What each reaction means
- 👍 Useful: correct, and you're fixing it or will.
- 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
- 😕 Unclear: you can't tell what it means or why it matters.
- 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.
🤖 Bits Code Review · Open Bits AI session
CI Test ResultsRun: #45835135905 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-11-26 14:35:12 UTC |
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 1 Pipeline job failed
Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: d6353c2 | Docs | View more details | Give us feedback! |
Memory overhead check: ❌ over budgetProfiler
✅ Not budgeted (too noisy on shared runners)
A limit was exceeded. Either fix the regression, or raise the limit in |
Scan-Build Report
Bug Summary
Filter Results by FileReports
|
||||||||||||||||||||||||||||||||||||
What does this PR do?:
At each dump, and at stop, java-profiler now emits the elapsed part of every still-open owned blocked interval as a TaskBlock. Long blocks therefore count in every upload they span.
{control, start[2]}pair.controlpacks a generation and an index intostart[].control.controlwith onefetch_and. The exit then emits only the last segment.GetThreadListStackTracesbefore the dump takes the stripes. Only threads whose JVMTI state matches their block are reported, so abandoned intervals are skipped.continuedondatadog.TaskBlock, true on all segments but the last.Motivation:
A dump used to emit nothing for an open interval, so earlier uploads lost long blocks and a thread that never unblocked was never reported (PROF-16858). dd-trace-java#11546's sleep-across-uploads smoke test expects segments.
Additional Notes:
TASK_BLOCK_EMITTEDnow counts segments, not intervals.continuedchain can lack its last segment.continued=falseand the blocker. Eligibility is judged on the real end.liveDumpPreservesCompletedTaskBlockInterval, theNativeSocketTaskBlockLifecycleTeststop case, andNettyEpollTaskBlockTest.verifySurvivorAcrossRestart. In the last one, a Netty wait that survives a restart now leaves exactly onecontinuedsegment in the stopping recording. The Netty interval-counting helper skipscontinuedsegments, so they cannot hide a lost completed interval.stop()skips collection.continued).How to test the change?:
ThreadSleepTaskBlockProfilingTestpassed 2 of 3 runs; that class fails 3/3 against feat(natsock): cover validated Netty epoll images and composed lifecycle (PROF-14931) #730. The failing case,onlySpanlessPlatformSleepsEmitTaskBlocks, saw one 4 ms span-free event on the "active" thread, outside its span. The test counts every TaskBlock on that thread, including span-free class-loading contention at thread start, which this app shows routinely on other threads. It did not recur in 10 reruns. The test fix is on dd-trace-java#11546.nativeReadSpanningDumpContributesToBothChunks: counts only the stream read and its blocker-less dump segment. Passed 20/20 on Linux aarch64 JDK 17 debug (on 998dd6c, a fresh clone per run), plus a full*TaskBlock*run.taskBlockSegments_ut: a dump-vs-exit race run 100,000 times. Passed on debug and TSan, Linux aarch64 (podman).*TaskBlock*Java tests (137): passed on macOS, and on Linux aarch64 JDK 21 including the native read case.spotlessCheck,qualityChecks,buildRelease: passed.continued, stop close): all killed.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.