FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Wire reference chains into profiler lifecycle and JNI API by jbachorik · Pull Request #798 · DataDog/java-profiler · GitHub

Repository navigation

Wire reference chains into profiler lifecycle and JNI API - #798

Open
jbachorik wants to merge 18 commits into
mainfrom
jb/rc-4-profiler-wiring
Open

jbachorik wants to merge 18 commits into
mainfrom
jb/rc-4-profiler-wiring

Conversation

jbachorik commented Sep 17, 2026 •
edited
Loading

Copy link
Copy Markdown
Collaborator

What does this PR do?:

Hooks the reference-chain engine into the profiler lifecycle. Profiler starts and stops ReferenceChainTracker and LivenessTracker together with the recording, writes resolved chains into JFR on dump() and emits abandoned-search events. vmEntry GC hooks feed the tracker, and there are new JFR event types for the chains.

ObjectSampler now always passes the recording's flags to LivenessTracker, so they can't go stale between recordings. LivenessTracker is started last; if it fails to start, the sampler is deactivated and SAMPLED_OBJECT_ALLOC is disabled again.

javaApi.cpp adds the reference-chain natives and test seams, declared in JavaProfiler.java. The seams are real only in debug builds - release builds export no-op stubs, so calling them never throws UnsatisfiedLinkError.

Motivation:

Makes the reference-chain tracker reachable from a live recording.

Additional Notes:

A few engine fixes ride along:

  • The heap callback no longer takes _resolved_chains_lock inside the FollowReferences pause, where it could stall the walk behind the JFR dump thread copying the cache. Evictions are queued into a preallocated buffer and applied in one batch on the BFS thread, outside the walk.
  • PriorityExpandSet::insert() returns false on a full table instead of probing forever.
  • LivenessTracker::cleanup_table() takes an account_epoch flag, so the overflow sweep in track() doesn't claim the GC epoch the background sweep needs. Entries remember the epoch they were admitted in and are only aged for GCs they actually survived.
  • New counters for urgency-boost admissions and back-offs (LIVENESS_URGENT_BOOST_ADMITS / LIVENESS_URGENT_BOOST_BACKED_OFF); secondsToOOM() no longer divides by zero.
  • The debug test seams prime ProfiledThread TLS on entry, like the other JNI entry points.

How to test the change?:

  • :ddprof-lib:gtestDebug / :ddprof-lib:gtestRelease - the referenceChains and liveness suites, incl. new tests for the PriorityExpandSet full table, ClassTagAllocator, the urgency-boost backstop and account_epoch.
  • :ddprof-lib:assembleReleaseJar builds the release library with the seam stubs.
  • Java integration tests via testDebug / testRelease.

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-15341

🤖 Generated with Claude Code

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

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:57 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

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

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #37616728506 | Commit: e9e835c | Duration: 17m 28s (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-10-07 12:10:47 UTC

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

Copy link
Copy Markdown
Contributor

✅ All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 7802e497

jbachorik force-pushed the jb/rc-4-profiler-wiring branch from e8f5ee5 to 93f2dbf Compare September 17, 2026 19:08
jbachorik added this pull request to stack #803 September 17, 2026 20:02
jbachorik marked this pull request as ready for review September 17, 2026 20:03
jbachorik requested a review from a team as a code owner September 17, 2026 20:03

chatgpt-codex-connector Bot commented Sep 17, 2026 •
edited
Loading

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-06T14:34:28.345419Z d21eb08 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.

jbachorik marked this pull request as draft September 17, 2026 20:04
jbachorik force-pushed the jb/rc-4-profiler-wiring branch from 93f2dbf to 217a7ab Compare September 17, 2026 20:05

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93f2dbf486

ℹ️ 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 ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated

datadog-datadog-prod-us1-2 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Stopping a recording can omit all reference-chain events since the last dump. The lifecycle also keeps strong thread references and stale chain data across recording sessions.

Open Bits AI session

🤖 Datadog Autotest · Commit 93f2dbf · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/profiler.cpp Outdated
jbachorik force-pushed the jb/rc-4-profiler-wiring branch from 217a7ab to b5588b7 Compare September 17, 2026 20:19
jbachorik force-pushed the jb/rc-4-profiler-wiring branch from b5588b7 to b09e78d Compare September 17, 2026 20:20
jbachorik force-pushed the jb/rc-4-profiler-wiring branch 2 times, most recently from e99dbc2 to 61cfd3d Compare September 17, 2026 21:33
jbachorik force-pushed the jb/rc-4-profiler-wiring branch from 61cfd3d to ac29386 Compare September 17, 2026 22:15

This comment has been minimized.

jbachorik force-pushed the jb/rc-4-profiler-wiring branch from 5f7ef97 to 2fbc79b Compare September 18, 2026 07:06
Base automatically changed from jb/rc-3-refchain-tracker to main October 6, 2026 09:03
jbachorik and others added 12 commits October 6, 2026 11:54
Introduces the ReferenceChainEvent/ReferenceChainAbandonedEvent payloads
(event.h), their JFR metadata (jfrMetadata.*), and the FlightRecorder
emission paths that serialize chain events into JFR recording buffers,
including the constant-pool handling for per-hop edge labels. Emission
is pull-style: profiler.cpp snapshots events and hands them to
FlightRecorder; this layer does not depend on the tracker itself.
- ReferenceChainEvent carries one vector of ReferenceChainHop
  (klass id + retention-edge label) instead of two parallel vectors
- Compress the sub-option floor/ceiling rationale and the provisional
  default constant comments to one concise statement each
- Drop design-doc and Jira references from code comments; revert the
  unrelated LineNumberTable comment rewrite
- cleanup_table: account_epoch flag; track() overflow sweep skips epoch claim
- admitForTracking: LIVENESS_URGENT_BOOST_ADMITS/BACKED_OFF counters
- secondsToOOM: zero-denominator guard; ringThirdsStats -> ringWindowStats
- JNI poll seam calls finishLoopIterationSerialized
- gtests: DipThenRecover, OddLengthRisingWindow
…rences pause

- heapReferenceCallback ran invalidateResolvedChain() inside the
  FollowReferences STW pause, taking _resolved_chains_lock, which
  drainPendingChainEvents() holds across its cache copy on the JFR dump
  thread. Evictions are now queued and applied on the BFS thread outside
  any walk.
- PriorityExpandSet::insert() had no occupancy bound and could spin
  forever on a full table; it now returns false.
… seam

- referenceChainsPesTests.inc: PriorityExpandSet round-trip, rebuildFrom,
  full-table self-termination; ClassTagAllocator negative-tag minting
- referenceChainsTestAccessors.h: cacheChain() passes source_tag and
  source_tag_val through unchanged
- referenceChainsOomTests.inc: setCanaryBackoffForTest() takes ns
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jbachorik force-pushed the jb/rc-4-profiler-wiring branch from 47c0511 to d21eb08 Compare October 6, 2026 12:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jbachorik marked this pull request as ready for review October 6, 2026 14:28

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d21eb089f7

ℹ️ 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".

datadog-datadog-prod-us1-2 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The shared accessor's gtest include breaks the reference-chain fuzz build. Deferred overflow accounting also allows newly admitted objects to receive ages for GCs that occurred before their allocation.

Open Bits AI session

🤖 Bits Code Review · Commit d21eb08 · @DataDog review to ask questions

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copy link
Copy Markdown
Collaborator Author

@DataDog review

datadog-datadog-prod-us1-2 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Allocation callbacks can reach an uninitialized liveness table during recording startup and crash the JVM. Queue overflow and reap-only cleanup also introduce stale reference-chain and leak-population results.

Open Bits AI session

🤖 Bits Code Review · Commit 753deda · @DataDog review to ask questions

Copy link
Copy Markdown
Collaborator Author

Fixed in 0668fa1 (addressing general review comment).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Collaborator Author

@DataDog review

datadog-datadog-prod-us1-2 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Urgent liveness admission races with table cleanup, and debug JNI queue inspection races with the BFS worker, potentially crashing the JVM.

Open Bits AI session

🤖 Bits Code Review · Commit dc36a90 · @DataDog review to ask questions

jbachorik and others added 2 commits October 7, 2026 13:44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

1 participant


Back | FazBrowse Home | New Git URL