Skip to content

feat(wall): support unfiltered suppression and protect crash bootstrap (PROF-12146) - #663

Open
kaahos wants to merge 93 commits into
mainfrom
paul.fournillon/wallclock-all-threads
Open

kaahos wants to merge 93 commits into
mainfrom
paul.fournillon/wallclock-all-threads

Conversation

@kaahos

@kaahos kaahos commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?:

Enables lifecycle-owned wall-clock suppression with wallprecheck=true,filter=. Omitting filter still enables context filtering. Retained native identities let normal-thread hooks identify a blocked run; the timer never registers remote threads.

Also protects crash-handler bootstrap before TLS-based recursion bookkeeping, blocks profiling signals before publishing exit marks, removes TLS work from the wakeup handler, and repairs the bounded GC-generations regression oracle.

Motivation:

An unfiltered recording needs reliable run boundaries before it can omit repeated signals. OS thread state alone cannot prove that a blocked run is unchanged. Uniform reservoir selection therefore precedes suppression; suppressed selections still count toward the epoch denominator, while failed sends do not.

The crash-bootstrap defect is inherited from the guard/TLS lineage in #134, #540 and #713, not caused by unfiltered profiling. A TLS recursion guard cannot protect the first TLS access, including during startup or pthread teardown. Exit marks bypass that access; a Linux fault fence covers the remaining TLS prefix.

Additional Notes:

  • Exit marks and identity reuse: ThreadExitRegistry::isCurrentExiting() clears a mark whose identity a live thread reused (TLS present, profiling signals unblocked). Native-memory and socket-timeout admission use it; the crash handlers keep the raw check, because a TLS read can fault during teardown.
    Human review: mandatory. The change touches signal handlers, the SIGSEGV/SIGBUS crash path, thread teardown and lock-free registries.

Accepted costs (reviewer acknowledgment required):

Cost Where Why accepted
A SIGSEGV/SIGBUS at a profiler-owned PC (inside libjavaProfiler, a W^X trap, or the JDK-8313796 interpreter range) makes a raw identity syscall and scans 64 registry probes; on Linux the fence adds two mask syscalls. Faults at other PCs (implicit null checks, poll pages) chain to the JVM first, with no syscall or TLS read. Profiler::isProfilerOwnedFault, segvHandler/busHandler A TLS access cannot be made safe before the thread is known to be live. Until the library range is known, every fault takes the slow path.
Sampled native allocations make one raw identity syscall; unsampled ones make none. MallocTracer::maybeRecord shouldSample() reads no TLS, so it runs first. Weights stay unbiased; a sample that lands on the profiler's own allocation is dropped and counted in malloc_samples_dropped.
The owner registry retains up to 2,048 identities with an 8,192-entry TID index; cold registration allocates the TID index with new (std::nothrow) (failure leaves the registry inactive) and may wait on a non-signal mutex. Capacity or timer-probe exhaustion falls back to ordinary sampling. threadFilter.h Bounded memory; failure mode is ordinary sampling, not lost data.
The block tracker's per-slot backing (ThreadFilter::kMaxThreads × sizeof(BlockState), 128 KiB) is retained after stop() and reported in a new NativeMem category, wall_block_tracker. wallClockBlockTracker.cpp, nativeMem.h In-flight owner hooks can carry slot IDs across stop(). wallclock stays recording-scoped and reads 0 when idle, as ProfilerLifecycleTest asserts.
WallClockEpoch.numSuccessfulSamples now counts precheck-suppressed selections, in filtered and unfiltered mode. wallClock.h Keeps the epoch denominator equal to reservoir selections.
  • This is not alternate-stack protection: there is no sigaltstack. Unhooked threads and cancellation paths do not all receive an early exit mark. macOS has no fence.
  • Bundled changes outside the PR's purpose are tracked separately: crash-bootstrap hardening (PROF-16790), _activated_mask in Profiler::stop() and the musl wall-timer guard (PROF-16793, also present on main), and the GCGenerationsTest rewrite (PROF-16794).
  • The OpenJ9/Semeru integration JVM selection that was bundled here moved to fix(ci): run the labeled JVM in dd-trace integration cells and skip musl/OpenJ9 (PROF-16792) #1062 (PROF-16792).
  • Merged with current main. main now installs malloc hooks per recording with an identity-checked live-library walk, which supersedes this PR's earlier loader-outside-mutex malloc fix (PROF-16791); that fix and its tests were dropped. main's unowned-tail reset at start and at recording-memory release now delegates to WallClockBlockTracker. main's reference-chain stop test seeds _activated_mask, because this PR's stop() only stops engines that start() activated.
  • Review: Sphinx standard review of the full range found no Critical or High findings; the Low test and doc findings are fixed. One Low finding stays open: an exit mark is cleared if an exiting thread re-initializes TLS (no current call site does). The last-probe registry tests hardcode the 4096-slot table and 64-probe window instead of shared constants. The wall_block_tracker no-growth check in ProfilerLifecycleTest only runs in a CPU-only restart test, and WallClockAccountingTest checks a fixture-local tracker, so both guard the category only weakly.

How to test the change?:

  • ./.claude/commands/build-and-summarize :ddprof-lib:gtestDebug (crash bootstrap, thread filter, wall clock, block tracker, malloc admission).
  • ./.claude/commands/build-and-summarize :ddprof-test:testDebug -Ptests='com.datadoghq.profiler.wallclock.*' and -Ptests='com.datadoghq.profiler.nativemem.*' on glibc and musl.

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 security review (run the dd:platform-security-review
    skill, or file a request via the PSEC review form).
    bewaire also runs automatically on every PR.
  • This PR doesn't touch any of that.
  • JIRA: PROF-12146

Unsure? Have a question? Request a review!

@dd-octo-sts

dd-octo-sts Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #45696042812 | Commit: 9dead9b | Duration: 30m 52s (longest job)

✅ All 108 test jobs passed

Status Overview

JDK glibc-aarch64/asan glibc-aarch64/debug glibc-aarch64/release glibc-aarch64/tsan glibc-amd64/asan glibc-amd64/debug glibc-amd64/release glibc-amd64/tsan musl-aarch64/debug musl-aarch64/release musl-amd64/debug musl-amd64/release
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: 108 | Passed: 108 | Failed: 0


Updated: 2026-11-25 21:09:17 UTC

@kaahos
kaahos force-pushed the paul.fournillon/wallclock-all-threads branch 3 times, most recently from 3902a14 to f302dd5 Compare July 19, 2026 12:00
@kaahos kaahos changed the title feat(wall): add configurable wall thread scope feat(wall): support signal suppression for unfiltered threads Jul 19, 2026
@kaahos
kaahos force-pushed the paul.fournillon/wallclock-all-threads branch 2 times, most recently from 0ad425c to fb1c44d Compare July 19, 2026 18:43
@dd-octo-sts

dd-octo-sts Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (commit fb1c44d)

Pipeline: https://gitlab.ddbuild.io/DataDog/apm-reliability/benchmarking-platform/-/pipelines/125547869 Commit: fb1c44de77197780eae60267ff98bd38a907a558

⚠️ Significant outliers

  • 🔴 fj-kmeans (JDK 21): runtime +5.9% (2679→2836 ms)
  • 🔴 future-genetic (JDK 21): runtime +3.8% (2083→2162 ms)
Runtime details (per benchmark × JDK)
Benchmark JDK Latest Dev Δ (dev vs latest) Issues L/D
akka-uct 21 ✅ 10210 ms (21 iters) ✅ 10256 ms (21 iters) ≈ +0.5% (±10.9%) — / —
akka-uct 25 ✅ 8953 ms (24 iters) ✅ 8890 ms (24 iters) ≈ -0.7% (±10.2%) — / —
finagle-chirper 21 ✅ 6000 ms (33 iters) ✅ 5960 ms (33 iters) ≈ -0.7% (±25.4%) ⚠️ W:3 / ⚠️ W:3
finagle-chirper 25 ✅ 5431 ms (36 iters) ✅ 5443 ms (36 iters) ≈ +0.2% (±24.6%) ⚠️ W:4 / ⚠️ W:3
fj-kmeans 21 ✅ 2679 ms (70 iters) ✅ 2836 ms (66 iters) 🔴 +5.9% — / —
fj-kmeans 25 ✅ 2847 ms (66 iters) ✅ 2828 ms (66 iters) ≈ -0.7% (±2.6%) — / —
future-genetic 21 ✅ 2083 ms (89 iters) ✅ 2162 ms (86 iters) 🔴 +3.8% — / —
future-genetic 25 ✅ 2076 ms (90 iters) ✅ 2122 ms (88 iters) ≈ +2.2% (±2.5%) — / —
naive-bayes 21 ✅ 1252 ms (136 iters) ✅ 1248 ms (137 iters) ≈ -0.3% (±32.7%) — / —
naive-bayes 25 ✅ 1008 ms (170 iters) ✅ 1023 ms (167 iters) ≈ +1.5% (±31.7%) — / —
reactors 21 ✅ 16312 ms (15 iters) ✅ 16357 ms (15 iters) ≈ +0.3% (±8.8%) — / —
reactors 25 ✅ 18416 ms (15 iters) ✅ 18780 ms (15 iters) ≈ +2% (±3.6%) — / —
Internal counter details (ddprof)

ddprof internal counters, latest / dev (✅ = 0, · = unavailable):

Benchmark JDK Dropped rec Dropped jvmti Dropped trace Skipped WC AGCT fail Unwind fail
akka-uct 21 ✅ / ✅ ✅ / ✅ 2 / ✅ 1891 / 2004 ✅ / ✅ ✅ / ✅
akka-uct 25 ✅ / ✅ ✅ / ✅ 1 / 1 2305 / 2283 ✅ / ✅ ✅ / ✅
finagle-chirper 21 ✅ / ✅ ✅ / ✅ 4 / 2 8183 / 8674 ✅ / ✅ ✅ / ✅
finagle-chirper 25 ✅ / ✅ ✅ / ✅ ✅ / ✅ 8087 / 8641 ✅ / ✅ ✅ / ✅
fj-kmeans 21 ✅ / ✅ ✅ / ✅ 2 / 2 1270 / 1278 ✅ / ✅ ✅ / ✅
fj-kmeans 25 ✅ / ✅ ✅ / ✅ 3 / 3 1282 / 1275 ✅ / ✅ ✅ / ✅
future-genetic 21 ✅ / ✅ ✅ / ✅ 1 / 3 2966 / 3007 ✅ / ✅ ✅ / ✅
future-genetic 25 ✅ / ✅ ✅ / ✅ 2 / ✅ 2992 / 2972 ✅ / ✅ ✅ / ✅
naive-bayes 21 ✅ / ✅ ✅ / ✅ 3 / 6 3491 / 3501 ✅ / ✅ ✅ / ✅
naive-bayes 25 ✅ / ✅ ✅ / ✅ 1 / 5 3488 / 3493 ✅ / ✅ ✅ / ✅
reactors 21 ✅ / ✅ ✅ / ✅ 2 / ✅ 1711 / 1786 ✅ / ✅ ✅ / ✅
reactors 25 ✅ / ✅ ✅ / ✅ ✅ / ✅ 1819 / 1920 ✅ / ✅ ✅ / ✅

@kaahos
kaahos force-pushed the paul.fournillon/wallclock-all-threads branch from fb1c44d to 1118f62 Compare July 19, 2026 21:16
@dd-octo-sts

dd-octo-sts Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (commit 1118f62)

Pipeline: https://gitlab.ddbuild.io/DataDog/apm-reliability/benchmarking-platform/-/pipelines/125554643 Commit: 1118f62831a4384bdf0283ef01a626c5bdc48af5

⚠️ Significant outliers

  • 🟢 fj-kmeans (JDK 21): runtime -3.9% (2808→2698 ms)
  • 🟢 future-genetic (JDK 25): runtime -4.2% (2088→2001 ms)
Runtime details (per benchmark × JDK)
Benchmark JDK Latest Dev Δ (dev vs latest) Issues L/D
akka-uct 21 ✅ 10294 ms (21 iters) ✅ 10251 ms (21 iters) ≈ -0.4% (±11.4%) — / —
akka-uct 25 ✅ 8933 ms (24 iters) ✅ 8835 ms (24 iters) ≈ -1.1% (±10%) — / —
finagle-chirper 21 ✅ 6016 ms (33 iters) ✅ 6034 ms (33 iters) ≈ +0.3% (±25.3%) ⚠️ W:3 / ⚠️ W:3
finagle-chirper 25 ✅ 5462 ms (36 iters) ✅ 5452 ms (36 iters) ≈ -0.2% (±24.6%) ⚠️ W:3 / ⚠️ W:3
fj-kmeans 21 ✅ 2808 ms (66 iters) ✅ 2698 ms (70 iters) 🟢 -3.9% — / —
fj-kmeans 25 ✅ 2812 ms (66 iters) ✅ 2813 ms (66 iters) ≈ +0% (±2.6%) — / —
future-genetic 21 ✅ 2067 ms (90 iters) ✅ 2083 ms (90 iters) ≈ +0.8% (±2.7%) — / —
future-genetic 25 ✅ 2088 ms (89 iters) ✅ 2001 ms (93 iters) 🟢 -4.2% — / —
naive-bayes 21 ✅ 1239 ms (138 iters) ✅ 1231 ms (138 iters) ≈ -0.6% (±32.7%) — / —
naive-bayes 25 ✅ 1019 ms (168 iters) ✅ 1011 ms (169 iters) ≈ -0.8% (±32.1%) — / —
reactors 21 ✅ 16149 ms (15 iters) ✅ 16215 ms (15 iters) ≈ +0.4% (±8.4%) — / —
reactors 25 ✅ 18598 ms (15 iters) ✅ 18345 ms (15 iters) ≈ -1.4% (±5.1%) — / —
Internal counter details (ddprof)

ddprof internal counters, latest / dev (✅ = 0, · = unavailable):

Benchmark JDK Dropped rec Dropped jvmti Dropped trace Skipped WC AGCT fail Unwind fail
akka-uct 21 ✅ / ✅ ✅ / ✅ 2 / 2 1978 / 1973 ✅ / ✅ ✅ / ✅
akka-uct 25 ✅ / ✅ ✅ / ✅ 2 / ✅ 2287 / 2449 ✅ / ✅ ✅ / ✅
finagle-chirper 21 ✅ / ✅ ✅ / ✅ 2 / 2 8978 / 8724 ✅ / ✅ ✅ / ✅
finagle-chirper 25 ✅ / ✅ ✅ / ✅ ✅ / ✅ 8633 / 8297 ✅ / ✅ ✅ / ✅
fj-kmeans 21 ✅ / ✅ ✅ / ✅ 2 / 1 1257 / 1281 ✅ / ✅ ✅ / ✅
fj-kmeans 25 ✅ / ✅ ✅ / ✅ 1 / 4 1280 / 1268 ✅ / ✅ ✅ / ✅
future-genetic 21 ✅ / ✅ ✅ / ✅ ✅ / 3 2909 / 2923 ✅ / ✅ ✅ / ✅
future-genetic 25 ✅ / ✅ ✅ / ✅ 2 / 5 2847 / 2887 ✅ / ✅ ✅ / ✅
naive-bayes 21 ✅ / ✅ ✅ / ✅ 7 / 4 3492 / 3493 ✅ / ✅ ✅ / ✅
naive-bayes 25 ✅ / ✅ ✅ / ✅ 4 / 2 3463 / 3473 ✅ / ✅ ✅ / ✅
reactors 21 ✅ / ✅ ✅ / ✅ ✅ / 1 1761 / 1721 ✅ / ✅ ✅ / ✅
reactors 25 ✅ / ✅ ✅ / ✅ ✅ / ✅ 1916 / 1880 ✅ / ✅ ✅ / ✅

@dd-octo-sts

dd-octo-sts Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (commit 40dbe8e)

Pipeline: https://gitlab.ddbuild.io/DataDog/apm-reliability/benchmarking-platform/-/pipelines/125596529 Commit: 40dbe8e833888192b6026558590bce1cf0ad1c9f

⚠️ Significant outliers

  • 🟢 fj-kmeans (JDK 21): runtime -2.7% (2823→2748 ms)
  • 🔴 future-genetic (JDK 21): runtime +4.1% (2041→2125 ms)
  • 🔴 future-genetic (JDK 25): runtime +5.8% (1994→2110 ms)
Runtime details (per benchmark × JDK)
Benchmark JDK Latest Dev Δ (dev vs latest) Issues L/D
akka-uct 21 ✅ 10340 ms (21 iters) ✅ 10312 ms (21 iters) ≈ -0.3% (±11.6%) — / —
akka-uct 25 ✅ 8871 ms (24 iters) ✅ 8849 ms (24 iters) ≈ -0.2% (±10.1%) — / —
finagle-chirper 21 ✅ 6017 ms (33 iters) ✅ 6015 ms (33 iters) ≈ -0% (±25%) ⚠️ W:3 / ⚠️ W:4
finagle-chirper 25 ✅ 5470 ms (36 iters) ✅ 5509 ms (36 iters) ≈ +0.7% (±24.2%) ⚠️ W:4 / ⚠️ W:3
fj-kmeans 21 ✅ 2823 ms (66 iters) ✅ 2748 ms (68 iters) 🟢 -2.7% — / —
fj-kmeans 25 ✅ 2856 ms (66 iters) ✅ 2847 ms (66 iters) ≈ -0.3% (±2.6%) — / —
future-genetic 21 ✅ 2041 ms (90 iters) ✅ 2125 ms (88 iters) 🔴 +4.1% — / —
future-genetic 25 ✅ 1994 ms (93 iters) ✅ 2110 ms (88 iters) 🔴 +5.8% — / —
naive-bayes 21 ✅ 1247 ms (137 iters) ✅ 1259 ms (135 iters) ≈ +1% (±33.5%) — / —
naive-bayes 25 ✅ 1027 ms (167 iters) ✅ 1018 ms (168 iters) ≈ -0.9% (±31.5%) — / —
reactors 21 ✅ 16583 ms (15 iters) ✅ 16798 ms (15 iters) ≈ +1.3% (±7.5%) — / —
reactors 25 ✅ 18582 ms (15 iters) ✅ 18610 ms (15 iters) ≈ +0.2% (±5.1%) — / —
Internal counter details (ddprof)

ddprof internal counters, latest / dev (✅ = 0, · = unavailable):

Benchmark JDK Dropped rec Dropped jvmti Dropped trace Skipped WC AGCT fail Unwind fail
akka-uct 21 ✅ / ✅ ✅ / ✅ ✅ / 6 1978 / 1998 ✅ / ✅ ✅ / ✅
akka-uct 25 ✅ / ✅ ✅ / ✅ ✅ / 1 2344 / 2271 ✅ / ✅ ✅ / ✅
finagle-chirper 21 ✅ / ✅ ✅ / ✅ 2 / 2 8863 / 8312 ✅ / ✅ ✅ / ✅
finagle-chirper 25 ✅ / ✅ ✅ / ✅ 1 / ✅ 8368 / 8738 ✅ / ✅ ✅ / ✅
fj-kmeans 21 ✅ / ✅ ✅ / ✅ 7 / 1 1284 / 1242 ✅ / ✅ ✅ / ✅
fj-kmeans 25 ✅ / ✅ ✅ / ✅ 1 / 4 1302 / 1289 ✅ / ✅ ✅ / ✅
future-genetic 21 ✅ / ✅ ✅ / ✅ 1 / 1 2979 / 2980 ✅ / ✅ ✅ / ✅
future-genetic 25 ✅ / ✅ ✅ / ✅ ✅ / ✅ 2847 / 2862 ✅ / ✅ ✅ / ✅
naive-bayes 21 ✅ / ✅ ✅ / ✅ 4 / 5 3520 / 3534 ✅ / ✅ ✅ / ✅
naive-bayes 25 ✅ / ✅ ✅ / ✅ 3 / 3 3523 / 3509 ✅ / ✅ ✅ / ✅
reactors 21 ✅ / ✅ ✅ / ✅ 2 / 2 1682 / 1809 ✅ / ✅ ✅ / ✅
reactors 25 ✅ / ✅ ✅ / ✅ 2 / ✅ 1806 / 1871 ✅ / ✅ ✅ / ✅

Copilot AI review requested due to automatic review settings July 21, 2026 07:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Extends wall-clock “owned-block” signal suppression to unfiltered (explicit filter=) wall recordings when wallprecheck=true, by introducing a thread registry keyed by native TID and integrating it into both ASGCT and JVMTI wall-clock sampling paths.

Changes:

  • Added unfiltered wall thread registry support (native TID indexing, lifecycle generations, recording epochs) and wired it into profiler lifecycle + wall-clock precheck logic.
  • Added a bounded candidate-selection/backfill mechanism for precheck to avoid reverting to O(N) registry work per wall tick under heavy suppression.
  • Added Java integration tests, C++ unit tests, and a JMH benchmark to validate behavior and measure overhead.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ddprof-test/src/test/java/com/datadoghq/profiler/wallclock/UnfilteredWallPrecheckTest.java New integration coverage for suppression behavior in explicit-empty-filter wall recordings.
ddprof-test/src/test/java/com/datadoghq/profiler/wallclock/UnfilteredWallPrecheckRestartTest.java Verifies registry activation does not leak across recording restarts and handles stopped gaps safely.
ddprof-test/src/test/java/com/datadoghq/profiler/wallclock/JvmtiBasedUnfilteredWallPrecheckTest.java Ensures the unfiltered path works when wall sampling delegates stacks via JVMTI.
ddprof-test/src/test/java/com/datadoghq/profiler/wallclock/J9WallClockPrecheckCapabilityTest.java Confirms J9 wall engine capability gating prevents activation of unfiltered tracking.
ddprof-test/src/test/java/com/datadoghq/profiler/AbstractProfilerTest.java Adds beforeProfilerStart() hook to allow test setup before profiler thread callbacks are enabled.
ddprof-stresstest/src/jmh/java/com/datadoghq/profiler/WallClockPrecheckBenchmarkHooks.java Exposes owned-block hooks to benchmarks without widening core API surface.
ddprof-stresstest/src/jmh/java/com/datadoghq/profiler/stresstest/scenarios/throughput/WallClockPrecheckOverheadBenchmark.java Adds throughput benchmark comparing wallprecheck=false/true as owned-block population grows.
ddprof-lib/src/test/cpp/wallprecheck_args_ut.cpp Adds capability tests and verifies explicit-empty vs omitted filter parsing behavior.
ddprof-lib/src/test/cpp/wallClockCandidateSelector_ut.cpp Unit-tests the new bounded candidate selection logic.
ddprof-lib/src/test/cpp/threadFilter_ut.cpp Expands tests for registry/epoch/lifecycle behavior and adjusts TID usage in recovery test.
ddprof-lib/src/main/cpp/wallClockCandidateSelector.h Adds reusable “randomized prefix without replacement” candidate selection with stats.
ddprof-lib/src/main/cpp/wallClock.h Integrates candidate selector and adds bounded-visit backfill path to the wall timer loop.
ddprof-lib/src/main/cpp/wallClock.cpp Updates precheck suppression to validate registry identity + context transitions; supports lazy registry lookups.
ddprof-lib/src/main/cpp/threadFilter.h Introduces registry state (TID index, epochs, lifecycle generation) and APIs for unfiltered tracking.
ddprof-lib/src/main/cpp/threadFilter.cpp Implements lock-free lookups + mutex-serialized writers for TID indexing, epoch refresh, and retirement.
ddprof-lib/src/main/cpp/profiler.h Declares bootstrap of existing Java threads for registry population.
ddprof-lib/src/main/cpp/profiler.cpp Boots existing Java threads into registry when unfiltered tracking is active; deactivates registry on stop/failure.
ddprof-lib/src/main/cpp/jvmThread.h Adds capability check for cross-thread native TID lookup support.
ddprof-lib/src/main/cpp/jvmThread.cpp Implements native TID lookup support predicate.
ddprof-lib/src/main/cpp/javaApi.cpp Ensures TLS slot binding is validated/refreshed before using owned-block and filter APIs.
ddprof-lib/src/main/cpp/engine.h Adds wall-engine capability hook for unfiltered precheck support.
ddprof-lib/src/main/cpp/counters.h Adds counters for registry bootstrap and bounded-lookup/backfill diagnostics.

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

@dd-octo-sts

dd-octo-sts Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (commit d82291f)

Pipeline: https://gitlab.ddbuild.io/DataDog/apm-reliability/benchmarking-platform/-/pipelines/125875202 Commit: d82291ff62852b63091350a05ebf26283fa39029

✅ Within expected boundaries

No significant runtime deltas (all within run-to-run noise) and no internal-counter outliers.

Runtime details (per benchmark × JDK)
Benchmark JDK Latest Dev Δ (dev vs latest) Issues L/D
akka-uct 21 ✅ 10141 ms (21 iters) ✅ 10278 ms (21 iters) ≈ +1.4% (±11.9%) — / —
akka-uct 25 ✅ 8800 ms (24 iters) ✅ 8939 ms (24 iters) ≈ +1.6% (±9.7%) — / —
finagle-chirper 21 ✅ 6003 ms (33 iters) ✅ 6060 ms (33 iters) ≈ +0.9% (±25.4%) ⚠️ W:3 / ⚠️ W:3
finagle-chirper 25 ✅ 5463 ms (36 iters) ✅ 5482 ms (36 iters) ≈ +0.3% (±24.1%) ⚠️ W:3 / ⚠️ W:3
fj-kmeans 21 ✅ 2780 ms (68 iters) ✅ 2771 ms (68 iters) ≈ -0.3% (±2.7%) — / —
fj-kmeans 25 ✅ 2752 ms (68 iters) ✅ 2824 ms (66 iters) ≈ +2.6% (±2.7%) — / —
future-genetic 21 ✅ 2082 ms (90 iters) ✅ 2035 ms (91 iters) ≈ -2.3% (±2.6%) — / —
future-genetic 25 ✅ 2101 ms (88 iters) ✅ 2055 ms (90 iters) ≈ -2.2% (±2.6%) — / —
naive-bayes 21 ✅ 1299 ms (132 iters) ✅ 1232 ms (138 iters) ≈ -5.2% (±31.7%) — / —
naive-bayes 25 ✅ 1011 ms (169 iters) ✅ 1013 ms (169 iters) ≈ +0.2% (±31.4%) — / —
reactors 21 ✅ 16511 ms (15 iters) ✅ 16445 ms (15 iters) ≈ -0.4% (±9.8%) — / —
reactors 25 ✅ 18516 ms (15 iters) ✅ 18146 ms (15 iters) ≈ -2% (±6.2%) — / —
Internal counter details (ddprof)

ddprof internal counters, latest / dev (✅ = 0, · = unavailable):

Benchmark JDK Dropped rec Dropped jvmti Dropped trace Skipped WC AGCT fail Unwind fail
akka-uct 21 ✅ / ✅ ✅ / ✅ 2 / 2 1925 / 1914 ✅ / ✅ ✅ / ✅
akka-uct 25 ✅ / ✅ ✅ / ✅ 2 / 3 2117 / 2331 ✅ / ✅ ✅ / ✅
finagle-chirper 21 ✅ / ✅ ✅ / ✅ 4 / 3 8401 / 8842 ✅ / ✅ ✅ / ✅
finagle-chirper 25 ✅ / ✅ ✅ / ✅ 1 / 1 8557 / 8073 ✅ / ✅ ✅ / ✅
fj-kmeans 21 ✅ / ✅ ✅ / ✅ 2 / 3 1243 / 1272 ✅ / ✅ ✅ / ✅
fj-kmeans 25 ✅ / ✅ ✅ / ✅ ✅ / 1 1265 / 1283 ✅ / ✅ ✅ / ✅
future-genetic 21 ✅ / ✅ ✅ / ✅ 3 / 1 3054 / 3036 ✅ / ✅ ✅ / ✅
future-genetic 25 ✅ / ✅ ✅ / ✅ ✅ / 1 2890 / 2867 ✅ / ✅ ✅ / ✅
naive-bayes 21 ✅ / ✅ ✅ / ✅ 4 / 3 3522 / 3464 ✅ / ✅ ✅ / ✅
naive-bayes 25 ✅ / ✅ ✅ / ✅ 4 / 5 3452 / 3463 ✅ / ✅ ✅ / ✅
reactors 21 ✅ / ✅ ✅ / ✅ ✅ / 2 1679 / 1552 ✅ / ✅ ✅ / ✅
reactors 25 ✅ / ✅ ✅ / ✅ ✅ / ✅ 1933 / 1805 ✅ / ✅ ✅ / ✅

@dd-octo-sts

dd-octo-sts Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (commit ec76f58)

Pipeline: https://gitlab.ddbuild.io/DataDog/apm-reliability/benchmarking-platform/-/pipelines/125883187 Commit: ec76f5829d243f516dee70833f3dfbe7a2b9eaa3

⚠️ Significant outliers

  • 🟢 fj-kmeans (JDK 21): runtime -4.1% (2839→2724 ms)
  • 🔴 future-genetic (JDK 21): runtime +3% (2066→2127 ms)
  • 🔴 future-genetic (JDK 25): runtime +5.8% (2006→2122 ms)
Runtime details (per benchmark × JDK)
Benchmark JDK Latest Dev Δ (dev vs latest) Issues L/D
akka-uct 21 ✅ 10350 ms (21 iters) ✅ 10305 ms (21 iters) ≈ -0.4% (±11.3%) — / —
akka-uct 25 ✅ 8864 ms (24 iters) ✅ 8976 ms (24 iters) ≈ +1.3% (±10.4%) — / —
finagle-chirper 25 ✅ 5472 ms (36 iters) ✅ 5418 ms (36 iters) ≈ -1% (±24.3%) ⚠️ W:3 / ⚠️ W:3
fj-kmeans 21 ✅ 2839 ms (66 iters) ✅ 2724 ms (68 iters) 🟢 -4.1% — / —
fj-kmeans 25 ✅ 2851 ms (66 iters) ✅ 2836 ms (66 iters) ≈ -0.5% (±2.6%) — / —
future-genetic 21 ✅ 2066 ms (89 iters) ✅ 2127 ms (87 iters) 🔴 +3% — / —
future-genetic 25 ✅ 2006 ms (92 iters) ✅ 2122 ms (87 iters) 🔴 +5.8% — / —
naive-bayes 21 ✅ 1277 ms (134 iters) ✅ 1289 ms (133 iters) ≈ +0.9% (±32.4%) — / —
naive-bayes 25 ✅ 1021 ms (167 iters) ✅ 1023 ms (168 iters) ≈ +0.2% (±31.6%) — / —
reactors 21 ✅ 15903 ms (15 iters) ✅ 16452 ms (15 iters) ≈ +3.5% (±8.8%) — / —
reactors 25 ✅ 18032 ms (15 iters) ✅ 18628 ms (15 iters) ≈ +3.3% (±4.7%) — / —
Internal counter details (ddprof)

ddprof internal counters, latest / dev (✅ = 0, · = unavailable):

Benchmark JDK Dropped rec Dropped jvmti Dropped trace Skipped WC AGCT fail Unwind fail
akka-uct 21 ✅ / ✅ ✅ / ✅ ✅ / ✅ ✅ / ✅ ✅ / ✅ ✅ / ✅
akka-uct 25 ✅ / ✅ ✅ / ✅ 1 / 3 2089 / 2428 ✅ / ✅ ✅ / ✅
finagle-chirper 21 ✅ / ✅ ✅ / ✅ 7 / 2 8520 / 8487 ✅ / ✅ ✅ / ✅
finagle-chirper 25 ✅ / ✅ ✅ / ✅ 4 / 2 8382 / 8319 ✅ / ✅ ✅ / ✅
fj-kmeans 21 ✅ / ✅ ✅ / ✅ 4 / 4 1278 / 1277 ✅ / ✅ ✅ / ✅
fj-kmeans 25 ✅ / ✅ ✅ / ✅ 4 / ✅ 1290 / 1289 ✅ / ✅ ✅ / ✅
future-genetic 21 ✅ / ✅ ✅ / ✅ 3 / 2 2953 / 3032 ✅ / ✅ ✅ / ✅
future-genetic 25 ✅ / ✅ ✅ / ✅ 2 / 2 2846 / 2856 ✅ / ✅ ✅ / ✅
naive-bayes 21 ✅ / ✅ ✅ / ✅ 3 / 3 3534 / 3561 ✅ / ✅ ✅ / ✅
naive-bayes 25 ✅ / ✅ ✅ / ✅ 1 / 3 3480 / 3510 ✅ / ✅ ✅ / ✅
reactors 21 ✅ / ✅ ✅ / ✅ 1 / ✅ 1614 / 1718 ✅ / ✅ ✅ / ✅
reactors 25 ✅ / ✅ ✅ / ✅ ✅ / 3 1962 / 1876 ✅ / ✅ ✅ / ✅

@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@DataDog DataDog deleted a comment from dd-octo-sts Bot Jul 21, 2026
@kaahos kaahos added the human_review:mandatory Human review required — see PR description label Nov 19, 2026
@kaahos kaahos changed the title feat(wall): support unfiltered suppression and protect crash bootstrap (PROF-16669) feat(wall): support unfiltered suppression and protect crash bootstrap (PROF-12146) Nov 19, 2026

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: FAIL

The PR adds unfiltered wall-sampling suppression and teardown protection; earlier class-loader, fault-recovery, ELF-validation and CI-reporting concerns are resolved. Two issues remain: malformed Semeru URLs prevent OpenJ9 integration provisioning, and the GC-generations restart test expects liveness samples that stop has already discarded.

Open Bits AI session

🤖 Bits Code Review · Commit a2c4a46

@rkennke

rkennke commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Suggestion: filter JVM-owned faults by PC before the exit registry and the fence

Reviewed at 366748fab.

The new code makes every SIGSEGV/SIGBUS pay for the crash-bootstrap protection: gettid, a 64-probe registry scan, and on Linux two rt_sigprocmask calls. Most of these faults belong to the JVM: implicit null checks, polling pages, stack banging, and J9 null-check faults. The profiler does not handle any of them; it only chains them to the JVM.

crashHandlerInternal() handles four cases. You can identify each one from the fault PC alone:

Case How it is identified
SafeAccess (safefetch/safestore/safeCopy) PC in the asm stubs in this library
checkFault() recovery PC in [profiler_min_address, profiler_max_address) (it returns early otherwise)
WX trap Trap::isFaultInstruction(pc)
JDK-8313796 workaround VMStructs::isInterpretedFrameValidFunc(pc)

A fault whose PC matches none of these is never handled here. It can chain before the handler reads TLS, consults the registry or arms the fence:

// Every case crashHandlerInternal() handles is identified by the fault PC.
// Other faults belong to the JVM and chain without any syscall or TLS access.
bool Profiler::isProfilerOwnedFault(void* ucontext) {
  const uintptr_t pc = static_cast<uintptr_t>(StackFrame(ucontext).pc());
  const uintptr_t min = profiler_min_address.load(std::memory_order_relaxed);
  const uintptr_t max = profiler_max_address.load(std::memory_order_relaxed);
  if (min == 0 || (pc >= min && pc < max)) return true;  // range unknown: stay conservative
  if (WX_MEMORY && Trap::isFaultInstruction(pc)) return true;
  return VM::isHotspot() && _need_JDK_8313796_workaround &&
         VMStructs::isInterpretedFrameValidFunc(reinterpret_cast<const void*>(pc));
}

void Profiler::segvHandler(int signo, siginfo_t *siginfo, void *ucontext) {
  if (!isProfilerOwnedFault(ucontext) ||
      ThreadExitRegistry::contains(ThreadExitRegistry::currentId())) {
    chainOrTerminate(signo, siginfo, ucontext, OS::getSegvChainTarget(), orig_segvHandler);
    return;
  }
  CrashBootstrapFence bootstrap_fence;
  // ... unchanged
}
// busHandler: same change with getBusChainTarget()/orig_busHandler.

Why this matters beyond per-fault CPU

  • rt_sigprocmask changes the mask under sighand->siglock (__set_current_blocked()). That spinlock is shared by all threads of the process, and signal sending (tgkill, including the wall timer's SIGVTALRM) takes the same lock. With the fence, every JVM fault on every thread takes that lock twice.
  • When many threads fault at the same time, they contend on that lock. Does an armed polling page at a safepoint or handshake produce such a burst? If it does, the fence can make time-to-safepoint longer, not only use more CPU. The "Accepted costs" table does not cover this.

Why this also improves on main

  • On main, every JVM fault already reads TLS twice: SIGNAL_HANDLER_GUARD_NO_SAMPLE() and crashHandlerInternal() both call ProfiledThread::current(). With the prefilter, JVM faults read no TLS and do less work than on main.
  • This PR fixes a first TLS access in the crash handler that can fault during startup or pthread teardown. JVM faults on such a thread also run that access today. The prefilter removes it for every thread, not only for threads with an exit mark. If JVM faults caused the original crashes, the prefilter alone prevents them.
  • The exit registry and the fence are then needed only for faults whose PC is in this library. Please check whether the fence is still worth its cost for those faults.
  • There is a precedent for this pattern. ctimer_linux.cpp calls OS::shouldProcessSignal() first and forwards foreign signals with OS::forwardForeignSignal() before it does any profiler work. With this change, crash signals follow the same rule.

What to check

  • The SafeAccess stubs must stay inside the profiler library range. They are asm in safeAccess.cpp, so the range check covers them.
  • isInterpretedFrameValidFunc() and Trap::isFaultInstruction() must not read TLS or memory that can fault. Please confirm both are pure address comparisons.
  • Behavior change: when there is no chain target and no original handler, the existing fallthrough returns, and chainOrTerminate() restores SIG_DFL and re-raises. The JVM always installs a handler, so this should not matter in practice. Please confirm that the early path should use chainOrTerminate().
  • Faults in libc called from profiler code (for example, memcpy in a walk) have a PC outside the library. checkFault() does not recover them today, so the prefilter does not change that behavior.

If you keep the current design, please measure two things against main: an NPE-heavy microbenchmark, and time-to-safepoint with many threads (for example, 200+ threads and frequent safepoints).

@rkennke

rkennke commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Review findings (all Low)

Reviewed range: ed77c41a2..366748fab (merge base to head). Sphinx standard review; each finding below was checked against the code at 366748fab. No Critical, High or Medium findings.

1. ensureTidIndexLocked() allocates with plain new (threadFilter.cpp:556)

The TidIndex (8,192 entries) is allocated with new TidIndex() on the Profiler::start() path. If the allocation fails, the JVM terminates. AGENTS.md requires new (std::nothrow) where an OOM must be survivable. WallClockBlockTracker::ensureAllocated() in this PR already uses std::nothrow and fails open. Suggestion: use std::nothrow, leave _tid_index null on failure, and keep the registry inactive. registerThread() already returns -1 while the index is null.

2. A stale exit mark disables malloc sampling for a thread that reuses a TID (mallocTracer.cpp:434)

ThreadExitRegistry stores raw gettid values. A mark is cleared only in ProfiledThread::initCurrentThread() and ThreadLocalDataPool::claim(), which both run only when a thread acquires TLS. maybeRecord() rejects a marked thread before it acquires TLS. If an unhooked native thread reuses the TID of a marked thread:

  • every sampled allocation on it is dropped (MALLOC_SAMPLES_DROPPED);
  • segvHandler()/busHandler() skip recovery for its faults;
  • only a wall or CPU sample that acquires TLS clears the mark. If nativemem is the only engine, nothing clears it.

Suggestion: when the exit check hits and ProfiledThread::current() is null, treat the identity as reused and call ThreadExitRegistry::clearCurrent(). Otherwise, document the limitation.

3. JavaProfilerTestSupport is public API of the production jar (JavaProfilerTestSupport.java:10)

The class is public in ddprof-lib/src/main, so it ships in the artifact, and its JNI entry points are linked into release binaries. The javadoc says the hooks "do not appear on JavaProfiler's public API surface". That is true for JavaProfiler but not for the jar. Suggestion: make the class package-private and reach it from tests through a same-package shim, as WallClockPrecheckBenchmarkHooks does. Or keep it public and correct the javadoc.

4. Benchmark tearDown() can skip profiler.stop() (WallClockPrecheckOverheadBenchmark.java:161)

If a worker is still alive after the 5 s join, tearDown() throws before profiler.stop() and Files.deleteIfExists(recording). The profiler then stays started in the shared JVM of WallClockPrecheckOverheadBenchmarkTest, and later tests fail with "already started". The same happens on the setup() failure path, which calls tearDown(). Suggestion: run the stop and the delete in finally blocks, and attach secondary failures with addSuppressed.

5. OSThreadState::SLEEPING is hardcoded as 7 (ParkBlockChurnAntagonist.java:263, WallClockPrecheckBenchmarkHooks.java:14)

The value is correct today. If the enum is renumbered, both callers pass the wrong state, and the tests still pass because armedSleepingRuns counts any non-zero token. Suggestion: define one named constant and use it in both places.

@kaahos

kaahos commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Re: #663 (comment)

Thanks, adopted in 5a95f10, with a test fix in d2e3639.

  • Profiler::isProfilerOwnedFault(pc) runs first in segvHandler/busHandler. It accepts a PC in the library range (an unknown range counts as owned), a WX trap, or the HotSpot JDK-8313796 interpreter range. Any other fault goes to chainOrTerminate() before the exit registry, the fence or the guard. So JVM faults read no TLS and make no syscalls.
  • Checked: the range loads are relaxed atomics on static state, Trap::isFaultInstruction and isInterpretedFrameValidFunc only compare addresses, and the SafeAccess stubs are asm inside the library range.
  • Early path: I kept chainOrTerminate() on purpose. It restores SIG_DFL and re-raises when there is neither a chain target nor an original handler; the JVM always installs one, so this only matters outside a JVM.
  • The exit registry and the fence stay for profiler-owned faults, where the bootstrap TLS read still happens.
  • Tests: crashFaultPrefilter_ut covers each branch. crash_bootstrap_ut runs these cases in forked children: SEGV/BUS outside the range (no bootstrap, no admission), inside the range, and min == 0. Removing the prefilter fails both outside-range tests.
  • The first Linux run showed that gtests which narrow the profiler range must keep the SafeAccess stubs inside it, or the prefilter chains their probe faults. d2e3639 adds profilerRangeTestSupport.h for that. Production is unaffected: the stubs live in the library.

With the prefilter in, I did not run the NPE or time-to-safepoint benchmarks: JVM faults no longer reach the fence at all.

@kaahos

kaahos commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Re: #663 (comment)

Thanks, all five addressed:

  1. ensureTidIndexLocked(): 171021f. It uses new (std::nothrow) and returns bool; on failure the registry and unfiltered tracking stay off. A UNIT_TEST failure seam covers it.
  2. Stale exit mark: b255d53 adds ThreadExitRegistry::isCurrentExiting(), now used in MallocTracer::maybeRecord(). A marked tid with no ProfiledThread is treated as reused, and its mark is cleared, only when SIGPROF and SIGVTALRM are not both blocked. Every mark site blocks them first, and a really exiting thread also has null TLS during teardown, so "no TLS" alone would clear marks that are still valid. A new thread that starts with both signals blocked is still dropped, as before. The segv/bus handlers keep the raw check, because their TLS read can fault in teardown. The same helper will replace the raw check that feat(taskblock): compose Linux native I/O producers with shared socket hooks (PROF-14931) #666 adds in the native socket interposer.
  3. JavaProfilerTestSupport: f208962 makes it package-private behind a test bridge, and JavaProfilerApiSurfaceTest asserts it is not public. From fix(wall): preserve context and sampling-epoch provenance across dumps (PROF-12146) #890 on, the class lives in the ddprof-test tree, so it is not in the production jar there.
  4. Benchmark teardown: 3859127 stops the profiler and deletes the recording through try-with-resources even when a worker is stuck, and the setup path also catches Error. A new test, stuckWorkerStillStopsProfilerAndDeletesRecording, covers it.
  5. SLEEPING: 4ab9db3 adds one constant, WallClockPrecheckBenchmarkHooks.OSTHREAD_STATE_SLEEPING, pointing to threadState.h, used by both callers.

@dd-octo-sts

dd-octo-sts Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Memory overhead check: ✅ within budget

Profiler c8acbfe65, pipeline. Budget: utils/memcheck/budget.txt. NMT and /proc values are profiled minus no-profiler runs on the same runner.

scenario metric value Δ since budget set limit headroom
allocs native_mem_live_bytes 21.87 MiB +185 KiB 21.95 MiB 81 KiB ok
allocs native_mem_max_bytes 23.12 MiB +170 KiB 23.20 MiB 86 KiB ok
allocs nmt.class 301 KiB +4 KiB 563 KiB 262 KiB ok
allocs nmt.internal 364 KiB −5 KiB 666 KiB 302 KiB ok
classesM native_mem_live_bytes (coverage-corrected) 23.43 MiB +149 KiB 23.55 MiB 128 KiB ok
classesM native_mem_max_bytes (coverage-corrected) 25.39 MiB +206 KiB 25.45 MiB 60 KiB ok
classesM nmt.class 2.94 MiB −2 KiB 3.20 MiB 268 KiB ok
classesM nmt.internal 3.20 MiB +4 KiB 3.50 MiB 303 KiB ok
mixed native_mem_live_bytes 23.35 MiB +205 KiB 23.45 MiB 102 KiB ok
mixed native_mem_max_bytes 40.92 MiB +206 KiB 41.00 MiB 81 KiB ok
mixed nmt.class 303 KiB −4 KiB 563 KiB 260 KiB ok
mixed nmt.internal 409 KiB −1 KiB 717 KiB 308 KiB ok
threads native_mem_live_bytes 19.25 MiB +166 KiB 19.35 MiB 100 KiB ok
threads native_mem_max_bytes 20.28 MiB +172 KiB 20.40 MiB 125 KiB ok
threads nmt.class 114 KiB +1 KiB 410 KiB 296 KiB ok
threads nmt.internal 162 KiB −2 KiB 461 KiB 299 KiB ok
traces native_mem_live_bytes 20.41 MiB +189 KiB 20.50 MiB 88 KiB ok
traces native_mem_max_bytes 21.63 MiB +229 KiB 21.70 MiB 68 KiB ok
traces nmt.class 470 KiB −2 KiB 768 KiB 299 KiB ok
traces nmt.internal 612 KiB −3 KiB 870 KiB 259 KiB ok

✅ nmt.tracing absent in every scenario.

Not budgeted (too noisy on shared runners)
scenario nmt.code nmt.gc nmt.total proc.VmRSS proc.RssAnon
allocs 1.61 MiB 4 KiB 2.67 MiB 36.25 MiB 31.95 MiB
classesM 5.22 MiB 64 KiB 13.58 MiB 39.48 MiB 35.05 MiB
mixed 1.55 MiB 4 KiB 2.86 MiB 32.59 MiB 27.97 MiB
threads 5 KiB 2 KiB 674 KiB 25.00 MiB 19.82 MiB
traces 6.20 MiB 49 KiB 7.71 MiB 32.50 MiB 27.90 MiB

@rkennke

rkennke commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Re-review of the fixes: all six earlier findings are resolved

Head: c8acbfe65. Merge base with main: 8e0f20466. Reviewed range: the seven fix commits after 366748fab (5a95f1013..d2e363912), checked with /code-review medium. I also read the conflict resolutions in the merges from main (af8cb8e48, c8acbfe65), and they are correct. After b8ca44e99, the reverted CI files are identical to main.

No Critical or High findings. Everything below is optional: none of it blocks the merge.

Optional fixes

  1. Medium (test only). returnAddressAttribution_ut.cpp, in the fixture SetUp(), still narrows the range with Profiler::setAddressRangeForTest(). It is the only narrowed-range fixture that does not use setProfilerRangeWithSafeAccessForTest(). If the link order puts a SafeAccess stub outside the window, the prefilter chains the probe fault to the gtest crash handler, and the binary crashes. Fix: call setProfilerRangeWithSafeAccessForTest(range_lo, range_hi).
  2. Low. ThreadExitRegistry::isCurrentExiting() decides "reused TID" from the current signal mask, which can change after the mark. Every mark site calls blockProfilingForExit() first, so this needs later teardown code that unblocks SIGPROF/SIGVTALRM and then mallocs. If that happens, the sample clears the mark and acquireCurrent() sets TLS on a thread that is exiting. The earlier raw contains() check could not fail this way. Suggestion: state this assumption in the comment.
  3. Low (test). No test covers a mask with only one of SIGPROF/SIGVTALRM blocked. Changing the && to || in isCurrentExiting() still passes. Suggestion: add that case to mallocTracerAdmission_ut.
  4. Low. ThreadFilter::init(): when ensureTidIndexLocked() fails with the context filter on, the registry goes inactive and every thread is rejected, so the recording has no wall or CPU samples and nothing says why. Suggestion: log or count that branch.
  5. Low. The setTidIndexAllocationFailureForTest() comment says the hook fails "the next" allocation, but the flag stays set, and AllocationFailureKeepsRegistryInactive relies on that. Suggestion: "fails allocations while set".
  6. Low (test). CrashFaultPrefilterTest::TearDown() writes fixed values to process-wide state (VM hotspot flag, the interpreted-frame range, the JDK-8313796 flag) instead of restoring the previous ones. Under gtest shuffle, a later test can take a different branch. Suggestion: save in SetUp(), restore in TearDown().
  7. Low. The six ddprof-test files that still hardcode OSThreadState::SLEEPING as 7 (e.g. PrecheckTest, UnfilteredWallPrecheckTest) could use one shared constant too. This code predates the earlier finding, which named only the two stresstest places.

@rkennke rkennke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. Feel free to address the new findings. Thanks, Roman

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human_review:mandatory Human review required — see PR description sphinx:critical Sphinx: critical — human review required test:asan Run CI tests with AddressSanitizer configuration test:fuzz test:release Run CI tests with release configuration test:reliability test:tsan Run CI tests with ThreadSanitizer configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants