Enable live heap profiling by default on safe JVM versions#11039
Draft
Enable live heap profiling by default on safe JVM versions#11039
Conversation
43f65b1 to
019c0b1
Compare
Adds unified config key `profiling.liveheap.enabled` that auto-detects safe systems (isJmethodIDSafe || isOldObjectSampleAvailable) and enables live heap profiling by default. Ddprof native library is preferred with JFR OldObjectSample as fallback. New `profiling.liveheap.jfr.enabled` replaces deprecated `profiling.heap.enabled` with context-aware deprecation warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
019c0b1 to
e9f2f3f
Compare
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Adds a unified config key
profiling.liveheap.enabledthat auto-detects safe systems and enables live heap profiling by default. The ddprof native library is preferred, with JFRjdk.OldObjectSampleas an automatic fallback.Introduces
profiling.jfr.liveheap.enabledas the replacement for the deprecatedprofiling.heap.enabled, with context-aware deprecation warnings. Cross-awareness between ddprof and JFR paths prevents double collection and warns when live heap profiling becomes effectively inactive.Enablement Logic
flowchart TD A["profiling.liveheap.enabled\n(unified master switch)"] A -->|"false"| B["ALL live heap OFF\n(ddprof + JFR)"] A -->|"unset or true"| C{Split into two paths} C --> D["ddprof path\nDatadogProfilerConfig"] C --> E["JFR path\nOpenJdkController"] D --> JFRCHK{"profiling.jfr.liveheap.enabled\nexplicitly true?"} JFRCHK -->|yes| JFRDIS["ddprof MEMLEAK OFF\n⚠️ warn: JFR explicitly requested,\ndisabling ddprof (superior mode)\nto avoid double collection"] JFRCHK -->|no| F["profiling.ddprof.liveheap.enabled"] F -->|"false"| G["MEMLEAK OFF"] F -->|"unset or true"\ndefault = isJmethodIDSafe| H{"JVM safe?\nJava 8, 11.0.23+,\n17.0.11+, 21.0.3+, 22+"} H -->|yes| I[MEMLEAK ON] H -->|no| J["MEMLEAK ON\n⚠️ warn: not stable on this JVM"] G --> GCHK{"JFR OldObjectSample\navailable?"} GCHK -->|no| GWARN["⚠️ warn: live heap\nwill be inactive"] GCHK -->|yes| GOK[JFR fallback active] E --> K{"Which key is set?"} K -->|"profiling.jfr.liveheap.enabled"| L{value?} K -->|"profiling.heap.enabled\n(deprecated)"| DEP{ddprof likely active?} K -->|"neither set"| NOKEY{"ddprof likely\nactive?"} L -->|"true"| L1[OldObjectSample ON] L -->|"false"| LCHK{"ddprof likely\nactive?"} LCHK -->|yes| L2[OldObjectSample OFF] LCHK -->|no| L2WARN["OldObjectSample OFF\n⚠️ warn: live heap\nwill be inactive"] NOKEY -->|yes| NOKEY_OFF["OldObjectSample OFF\n(ddprof handles live heap)"] NOKEY -->|no| NOKEY_JFP{"JVM supports it?\nJava 11.0.12+,\n17.0.3+, 18+"} NOKEY_JFP -->|yes| O["OldObjectSample ON\n(JFR fallback)"] NOKEY_JFP -->|no| P[OldObjectSample OFF] DEP -->|yes| DEP1["⚠️ warn: has no effect\n(ddprof handles live heap)\nkey ignored"] DEP -->|"no, value=true"| DEP2["⚠️ warn: redundant\n(JFR already on by default)"] DEP -->|"no, value=false"| DEP3["⚠️ warn: use new key\nprofiling.jfr.liveheap.enabled"] DEP2 --> DEP_ON[OldObjectSample ON] DEP3 --> DEP_OFF[OldObjectSample OFF] style B fill:#f66,color:#fff style G fill:#f66,color:#fff style JFRDIS fill:#fa0,color:#fff style L2 fill:#f66,color:#fff style L2WARN fill:#f66,color:#fff style NOKEY_OFF fill:#69c,color:#fff style P fill:#f66,color:#fff style DEP_OFF fill:#f66,color:#fff style GWARN fill:#fa0,color:#fff style I fill:#6b6,color:#fff style J fill:#fa0,color:#fff style L1 fill:#6b6,color:#fff style O fill:#6b6,color:#fff style GOK fill:#6b6,color:#fff style DEP_ON fill:#6b6,color:#fff style DEP1 fill:#fd6,color:#333 style DEP2 fill:#fd6,color:#333 style DEP3 fill:#fd6,color:#333Motivation
Live heap profiling provides valuable memory leak detection but was previously opt-in (
profiling.ddprof.liveheap.enableddefaulted tofalse). Users had to know about and explicitly enable it.This change makes it enabled by default on safe systems, matching the pattern already used by allocation profiling. The two live heap mechanisms (ddprof native and JFR OldObjectSample) are now unified under a single flag with automatic fallback.
[PROF-14188]
Additional Notes
isMemoryLeakProfilingSafe()returns true when at least one safe mechanism is available:isJmethodIDSafe() || isOldObjectSampleAvailable()falseto dynamicisJmethodIDSafe()profiling.jfr.liveheap.enabled=truedisables ddprof MEMLEAK on user request (avoids double collection)profiling.ddprof.liveheap.enabled=falsewith no JFR fallback warns about inactive live heapprofiling.jfr.liveheap.enabled=falsewith no ddprof warns about inactive live heapprofiling.heap.enabledare context-aware:isEventEnabledwas called withjdk.OldObjectSample#enabledwhich resulted in a double#enabledlookup, making the warning dead codeContributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROF-14188]
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.