perf(profiling): bound task stack collection#19085
Draft
taegyunkim wants to merge 2 commits into
Draft
Conversation
Codeowners resolved as |
Circular import analysis
|
This comment has been minimized.
This comment has been minimized.
32b532a to
ecdbdab
Compare
3b50116 to
e3d2e8a
Compare
gh-worker-dd-mergequeue-cf854d Bot
pushed a commit
that referenced
this pull request
Jul 16, 2026
## Description Aligns profiling frame-limit configuration with the backend's [600-location limit](https://datadoghq.atlassian.net/wiki/spaces/PROF/pages/5307007274/Profiling+Libraries+Frame+Truncation+Behaviors). - raises the native exporter cap from 512 to 599 captured frames - reserves the 600th backend location for the synthetic `<N frames omitted>` indicator on truncated stacks - clamps `DD_PROFILING_MAX_FRAMES` to 599 in `ddtrace.internal.settings.profiling` - preserves configured values from 513 through 599 instead of reducing them to 512 in the native exporter - ensures collectors receive the same effective configured limit JIRA: [PROF-14213](https://datadoghq.atlassian.net/browse/PROF-14213?atlOrigin=eyJpIjoiNWFmMTNkMDg2MmJjNDVlZTlkN2JlNGZkMjg3ZWZiYzEiLCJwIjoiaiJ9) ## Testing - Added configuration tests covering the default, values below the maximum captured-frame limit, the exact 599-frame limit, and values at or above the 600-location backend limit. - Ran `TestMaxFramesConfig` on Python 3.9, all 6 tests passed. The editable install also rebuilt the native extension successfully. - Completed a clean Python 3.14 native build for the initial change. - Ran `scripts/lint checks`, targeted formatting, spelling, and `git diff --check`. Broad lint checks reported only existing repository warnings. ## Risks Configurations between 513 and 599 can now retain more frames than before. This matches the backend contract but can slightly increase per-sample work for users who explicitly configure values in that range. Values of 600 and above are now clamped to 599 at configuration load instead of reaching individual collectors unchanged. This leaves one location for the omitted-frame indicator so truncated samples remain within the backend's 600-location cap. ## Additional Notes This PR is the base of stacked #19073 and #19085, which propagate the limit into Echion and bound task-aware stack collection. [PROF-14213]: https://datadoghq.atlassian.net/browse/PROF-14213?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiaiJ9 Co-authored-by: taegyun.kim <taegyun.kim@datadoghq.com>
67ae55e to
c0a7c8f
Compare
b2e94b5 to
29fa643
Compare
c0a7c8f to
dd6bece
Compare
29fa643 to
679beb6
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.
Description
Bounds asyncio stack collection and applies an explicit task-priority frame budget after logical stack stitching.
DD_PROFILING_MAX_FRAMESphysical thread framesDD_PROFILING_MAX_FRAMEScoroutine frames per task and stops assembling a logical task chain once its frame budget is full4 * max_frames, bounded between 256 and 1,024 entriesThis is stacked only on #19073, which propagates the configured limit into Echion and applies it to plain thread stacks. Merged #19076 supplies the 600-location backend and configuration limit on
main.JIRA: PROF-14213
Testing
scripts/lint checks, C formatting, spelling, andgit diff --check. Broad checks reported only existing repository warnings.scripts/run-benchmarks --listfound no benchmark suite matching the changed Echion files.Risks
Low
DD_PROFILING_MAX_FRAMESvalues now intentionally prefer logical task ancestry over physical synchronous frames. This changes which portion of a mixed stack is reported, but preserves a bounded and logically meaningful task trace instead of allowing a deep physical stack to hide task context.If the asyncio boundary is outside the bounded physical candidates, the sampler does not guess at overlap or concatenate potentially duplicated segments. It reports the bounded logical task stack alone.
The smaller frame cache can increase cache churn in workloads with many distinct code locations. It retains a 256-entry floor and scales with configured stack depth to balance reuse and memory.
Additional Notes
Task selection and render ordering are intentionally separate. Task frames receive budgeting priority, while retained segments are still rendered in logical leaf-to-root order.
The uppercase
MAX_STACK_DISCOVERY_DEPTHconstant remains a hard internal safety bound. The configured reporting and materialization budget is stored separately instack_max_frames.