Skip to content

Reference-chain test-stack updates, seam fixes, and repro/sweep tooling - #801

Merged
jbachorik merged 17 commits into
mainfrom
jb/rc-7-tooling
Oct 20, 2026
Merged

jbachorik merged 17 commits into
mainfrom
jb/rc-7-tooling

Conversation

@jbachorik

@jbachorik jbachorik commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?:
Repairs and finishes the reference-chain test stack (#800), and adds standalone repro/sweep/report tooling for the feature:

  • Tests (ddprof-test): restore the reverted review fixes — debug/asan/tsan build guards, fail-loud config forwarding, synchronized test-log tails, ThreadLocalMap-hop filter, frontier EXPANDED waits, target-tag matching; correlate leak tags on the (tag, incarnation) pair; add a keep-best scan-merge unit test; drop PersistentAllocator.
  • Library (ddprof-lib): rename the drain-count seam to drainReferenceChainEventCount0() (Java + JNI); restore four dropped test seams; drop the unread .expected sidecar from the roundtrip gtest. Test seams only — package-private, debug builds.
  • Scenarios (ddprof-stresstest): ReferenceChainLeakDemo (locale-stable metrics, bounded snapshot retention) and ReferenceChainLeakAntagonist (bounded sawtooth growth keeps the population slope positive).
  • Tooling (utils): repro runner, on/off comparison, budget and OFAT sweeps, JFR metrics from the original recording start, self-contained HTML reports. All scripts work on macOS bash 3.2.
  • Housekeeping: build-and-summarize reduced to log capture + grep failure extraction (LLM summarizer removed; AGENTS.md guide aligned); agent-scratch .gitignore entries; TlsPrimingTest quarantined on el7-8-release-amd64 (PROF-16281).

Motivation:
The #800 review left several reference-chain fixes reverted, which made the tests flaky or vacuous. This PR restores them and lands the repro/sweep tooling that PR's investigation produced.

Additional Notes:
Stacked on #800. No public API change.

How to test the change?:

  • bash -n over the scripts; python3 .github/scripts/quarantine.py validate.
  • :ddprof-lib:gtestDebug_referenceChainJfrRoundtrip_ut.
  • :ddprof-test:testDebug / testSlowDebug -Ptests=... for the reference-chain test classes.
  • :ddprof-stresstest:compileReproJava.

For Datadog employees:

@dd-octo-sts

dd-octo-sts Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Scan-Build Report

User:runner@runnervmlun5p
Working Directory:/home/runner/work/java-profiler/java-profiler/ddprof-lib/src/test/make
Command Line:make -j4 all
Clang Version:Ubuntu clang version 18.1.3 (1ubuntu1)
Date:Thu Sep 17 20:07:53 2026

Bug Summary

Bug TypeQuantityDisplay?
All Bugs4
C++ move semantics
Use-after-move1
Logic error
Dereference of null pointer1
Result of operation is garbage or undefined1
Unused code
Dead increment1

Reports

Bug Group Bug Type ▾ File Function/Method Line Path Length
Unused codeDead incrementreferenceChains.cppcollectStaticFieldAnchorsForRotation36771
Logic errorDereference of null pointerfaultInjection.cppcrashNow242
Logic errorResult of operation is garbage or undefinedlivenessTracker.cppsecondsToOOM138324
C++ move semanticsUse-after-movereferenceChains.cppbuildCanaryChainEvent608368

@datadog-official

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #39475539658 | Commit: a4f831a | Duration: 18m 17s (longest job)

✅ All 76 test jobs passed

Status Overview

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


Updated: 2026-10-20 18:54:01 UTC

@dd-octo-sts

dd-octo-sts Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 fd06b0f1

@jbachorik jbachorik added test:asan Run CI tests with AddressSanitizer configuration test:tsan Run CI tests with ThreadSanitizer configuration test:fuzz test:reliability labels Oct 20, 2026
@jbachorik jbachorik changed the title Reference-chain repro, sweep, and reporting tooling Reference-chain test-stack updates, seam fixes, and repro/sweep tooling Oct 20, 2026
- ReferenceChainTestHooks: consolidate debug test seams behind one
  package-private facade; drop public visibility of the JavaProfiler
  seams back to package-private
- JavaProfiler: restore the mutating-state warning on
  shouldRunPassForTest0 javadoc; getTid javadoc corrections
- referencechains tests: await handoff publication in default mode,
  continue hysteresis epochs past the initial seeding, keepBest()
  preserves in-pool correlated results, clear seeded heap-floor-ring
  samples and chainTargetHolder in finally, bound the allocator-tid
  spin-wait, seed per-(klass,tid) ramps on the allocating thread
- LeakTagCorrelationReferenceChainTest: assert at least one leak-tag
  interception in the tight-window variant
- utils/sweep-*.sh: guard parse_run pipelines with || true, fix the
  JDK<=16 safepoint double-count, resolve swept-knob precedence against
  baked-in defaults
- utils/run-refchains-repro.sh: stale budget comment, knob override
- build-and-summarize: headline IndexError guard, zip pairing of
  failure headlines, multi-count test summaries, parser failure
  artifacts
- ReferenceChainLeakAntagonist: hoist cache.size() out of the inner
  loop; ReferenceChainLeakDemo: malformed-duration usage message,
  rotating snapshot path
- refchains-report-multi.py: warn on unparsable CSV cells
The roundtrip JFR fixture is produced by referenceChainJfrRoundtrip_ut,
which does not run on CI runners without Google Test (e.g. the el7
testRelease job); asserting its existence failed the job there. Assume
instead of assert so the test skips where the gtest artifact is
unavailable and still executes wherever the gtest ran.
Comment-only rewrite of nine reference-chain test and hook files
(assertions, seams test, scenarios, launcher, test hooks, JavaProfiler
seam javadocs) to match the hand-written style of the rest of the
suite. No code changes.

Humanize pass over jb/rc-7-tooling.
Fixes from the sphinx light review (9 items):
- LeakTagCorrelationScenario.keepBest now merges violations in both
  directions; resultLine extracted and covered by the new
  LeakTagCorrelationScenarioKeepBestTest (7 tests, no profiler needed)
- AggressiveLeakReferenceChainTest: hoist shouldRunPassForTest0() out
  of assertFalse, reset the search first
- build-and-summarize: single write_unknown_summary() writer; Gradle
  exit status stays authoritative
- run-refchains-repro.sh: bash 3.2 set -u guards for empty arrays
- ReferenceChainTrackingTest: scratch JFRs via Files.createTempFile
- ReferenceChainLeakDemo: seeding in main() before run();
  heapUsedFraction falls back to Runtime.maxMemory()
- referenceChainJfrRoundtrip fixture is consume-once (unlink before
  write); ReferenceChainJfrParserTest deletes it after reading
- ReferenceChainJfrParserTest: assumeTrue fixture skip, re-applied
  from 218c2b7 (rc-7 forked before that fix)

The touched Java files also carry the humanize comment rewrites for
those files; splitting them would have left comments describing code
that the intermediate commit did not contain.
…t native name

Renaming the Java declaration to drainReferenceChainEventCount0() left no JNI
symbol for it in any build; rename both javaApi.cpp definitions (no-arg, no
leaf filter) instead, and restore the four removed seam declarations
(frontier state, resolved target tag, heap-floor reset/rising) the tests
need, plus the roundtrip gtest's stale env-var comment and its unread
.expected sidecar writer.
Replaces the literal "debug" config checks with isDebugInstrumentedBuild()
(debug/asan/tsan all compile the seams) and requiredTestConfig()'s fail-loud
forwarding; restores the synchronized testLogTail guards, the frontier-state
EXPANDED wait and target-tag matching, the ThreadLocalMap-hop filter and
(tag, incarnation) correlation, the handoff-timeout marker, painbudget=100,
the scaled child timeouts, the ActiveSetting id check, the matched population
seeds, the pass-count baseline ordering, the held[0] reservation, the
ring-reset mutation-killer test, and the roundtrip JFR env-var-first lookup.
…o snapshot retention

A cache that freezes at CAP_ENTRIES reads a ~zero population slope for the
rest of a long run, so the antagonist now recycles 25% of the cap and regrows
instead. The run-forever repro keeps only the last 5 periodic snapshots so
multi-hour sessions cannot fill the temp dir.
Aggregate every .jfr.snapshot.<round> file (a drained event is written once,
so the final snapshot alone undercounts chains), drop the swept knob from
fixed REFCHAINS_ARGS before each run (last-occurrence-wins would shadow it),
guard the safepoint pipelines with || true under pipefail, and replace the
associative array with a case function for macOS bash 3.2.
The wrapper had grown a live-tail/awk pipeline, a 150-line embedded log
parser, and summary artifacts - machinery from an era when builds were
summarized by a billed subagent call. Harnesses truncate agent output and
keep the full log on disk anyway, so the agent only needs the status line
plus the failure section, extracted by grep. Update AGENTS.md's operating
guide to match (no gradle-log-analyst delegation, no summary artifacts).
@jbachorik
jbachorik marked this pull request as ready for review October 20, 2026 14:41
@jbachorik
jbachorik requested a review from a team as a code owner October 20, 2026 14:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T14:47:53.185050Z 860860f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 860860ff5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread utils/refchains-jfr-metrics.py Outdated
Comment thread utils/sweep-refchains-all.sh Outdated
Comment thread utils/compare-refchains-repro.sh Outdated
Comment thread utils/run-refchains-repro.sh

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: FAIL

Successful discoveries are reported as missing, and the latency extractor measures elapsed time from snapshot boundaries. The correlation scenario also loses its incarnation check, allowing different tag owners to count as the same object.

Open Bits AI session

🤖 Bits Code Review · Commit 860860f

Comment thread utils/sweep-refchains-all.sh Outdated
Comment thread utils/refchains-jfr-metrics.py Outdated
@jbachorik

Copy link
Copy Markdown
Collaborator Author

Auto-expanded scope: 2 sibling issue(s) fixed in the same pass:

  • utils/sweep-refchains-all.sh:158 — bash integer numeric test applied to a non-integer (%.3f float) value
  • utils/run-chaos-harness.sh:1 — PR-modified file missing the Datadog copyright header (AGENTS.md policy)

Leak tags are recycled, so tag-only correlation in LeakTagCorrelationScenario
could accept a stale chunk that inherited the recycled tag; match the
HeapLiveObject on both identity fields and fail loud when either accessor or
stamp is missing. Format the repro's machine-readable metrics with Locale.ROOT
so a comma-decimal locale cannot silently zero parsed values.
samples_dropped_thread_local is process-global and shared with every
SIGNAL_HANDLER_GUARD_OR_DROP path, while the allowance is bounded by this
test's own sample count, so co-located runner load in the sequential el7-8
suite run can trip the bound (observed 79/195, 50/645, 272/137 across the
three RetryingTest attempts).
@jbachorik
jbachorik merged commit 539a500 into main Oct 20, 2026
55 of 65 checks passed
@jbachorik
jbachorik deleted the jb/rc-7-tooling branch October 20, 2026 18:33
@github-actions github-actions Bot added this to the 1.52.0 milestone Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Author Signed-off AI test:asan Run CI tests with AddressSanitizer configuration test:fuzz test:reliability test:tsan Run CI tests with ThreadSanitizer configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant