PROF-12102: The stacktraces are not obeying the stackdepth limit#299
Merged
PROF-12102: The stacktraces are not obeying the stackdepth limit#299
Conversation
b42399a to
f4afbdd
Compare
f4afbdd to
ef7adbc
Compare
jbachorik
approved these changes
Nov 21, 2025
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 PR do?:
This change fixes the profiler such that it only reports a maximum of frames as specified by -Ddd.profiling.stackdepth or the jstackdepth agent argument. Previously this limited only the number of Java frames, and still report an arbitrary number of native frames, which makes the usefulness of that argument questionable.
Motivation:
The profiler should obey the requested maximum number of stackframes, this improves usefulness and usability. In addition to that, it also saves storage in the generated JFR and in-memory, because we don't need to allocate buffers for so many frames.
Additional Notes:
Notice that when no stackdepth is specified, a default stackdepth of 2048 is assumed. In getNativeFrames(), I keep limiting this to MAX_NATIVE_FRAMES to avoid suprises.
How to test the change?:
It's not feasible to make an automated test for this, this would require very significant upfront work in the JVM. I ran existing tests and found no regressions, and I verified manually that the fix works, by running the CPU profiler with a workload and the jstackdepth argument, and verified in JMC that the stack-depth gets correctly limited.
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance.Unsure? Have a question? Request a review!