Skip to content

PROF-12102: The stacktraces are not obeying the stackdepth limit#299

Merged
rkennke merged 1 commit intomainfrom
rkennke/PROF-12102
Nov 21, 2025
Merged

PROF-12102: The stacktraces are not obeying the stackdepth limit#299
rkennke merged 1 commit intomainfrom
rkennke/PROF-12102

Conversation

@rkennke
Copy link
Contributor

@rkennke rkennke commented Nov 21, 2025

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:

  • 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-12102

Unsure? Have a question? Request a review!

@rkennke rkennke marked this pull request as ready for review November 21, 2025 14:40
@rkennke rkennke merged commit 0a7db6a into main Nov 21, 2025
94 of 95 checks passed
@rkennke rkennke deleted the rkennke/PROF-12102 branch November 21, 2025 15:24
@github-actions github-actions bot added this to the 1.35.0 milestone Nov 21, 2025
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