Skip to content

Introduce 'light' liveheap tracking for GC generations#93

Merged
jbachorik merged 2 commits into
mainfrom
jb/live_heap_lite
May 15, 2024
Merged

Introduce 'light' liveheap tracking for GC generations#93
jbachorik merged 2 commits into
mainfrom
jb/live_heap_lite

Conversation

@jbachorik
Copy link
Copy Markdown
Collaborator

@jbachorik jbachorik commented May 9, 2024

What does this PR do?:
This change introduces a lightweight mode of the liveness tracker which is not collecting stacktraces and is tracking only the allocated type and the instance age.

Motivation:
For the Java memory leak page it is beneficial to be able to use the GC generations metric without the threat of crashing the app due to JVMTI jmethodID issue when symbolizing the stacktraces.
This mode is not enabled by default and needs to be turned on by supplying generations=true argument to the agent.

How to test the change?:
A new sanity test is added which is making sure setting the profiler argument generations=true will indeed turn on the liveness tracker.

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 review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-9743

Unsure? Have a question? Request a review!

@jbachorik jbachorik requested a review from richardstartin May 9, 2024 14:23
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2024

🔧 Report generated by pr-comment-scanbuild

Scan-Build Report

User:runner@fv-az774-224
Working Directory:/home/runner/work/java-profiler/java-profiler/ddprof-lib/src/test/make
Command Line:make -j4 clean all
Clang Version:Ubuntu clang version 14.0.0-1ubuntu1.1
Date:Tue May 14 11:50:47 2024

Bug Summary

Bug TypeQuantityDisplay?
All Bugs6
Logic error
Assigned value is garbage or undefined1
Dereference of null pointer2
Result of operation is garbage or undefined1
Unused code
Dead initialization1
Dead nested assignment1

Reports

Bug Group Bug Type ▾ File Function/Method Line Path Length
Logic errorAssigned value is garbage or undefineddwarf.cppparseInstructions23520
Unused codeDead initializationlivenessTracker.cppcleanup_table451
Unused codeDead nested assignmentvmStructs.cppcheckNativeBinding8181
Logic errorDereference of null pointerflightRecorder.cppflush14138
Logic errorDereference of null pointersafeAccess.hload3518
Logic errorResult of operation is garbage or undefineddwarf.hgetSLeb14225

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2024

🔧 Report generated by pr-comment-cppcheck

CppCheck Report

Warnings (5)

Style Violations (161)

@jbachorik jbachorik force-pushed the jb/live_heap_lite branch from 3a6bcc7 to 14b1bf0 Compare May 9, 2024 14:48
event._size = size;
event._weight = (float)((size == 0 || _interval == 0) ? 1 : 1 / (1 - exp(-size / (double)_interval)));

frames = new jvmtiFrameInfo[_max_stack_depth];
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.

Can this use a linear allocator instead to avoid fragmentation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Linear allocator requires a clearly defined lifecycle. This is, unfortunately, not the case here.
I could try something like _calltrace_buffer but that would require locking. I did a quick check whether removing this allocation would help with the internal fragmentation (by having only one pre-allocated array and single lock, so reducing parallelism to 1) but the RSS growth I can observe is unaffected :(

@jbachorik jbachorik force-pushed the jb/live_heap_lite branch 2 times, most recently from 06315aa to 0e378c1 Compare May 13, 2024 08:06
@jbachorik jbachorik force-pushed the jb/live_heap_lite branch from 0e378c1 to b858193 Compare May 14, 2024 11:49
@jbachorik jbachorik merged commit bef5e91 into main May 15, 2024
@github-actions github-actions Bot added this to the 1.8.0 milestone May 15, 2024
@jbachorik jbachorik deleted the jb/live_heap_lite branch May 15, 2024 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants