Skip to content

refactor(profiling): clarify stack unwind safety limit - #20352

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
taegyunkim/prof-14213-clarify-stack-discovery-limit
Sep 21, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
taegyunkim/prof-14213-clarify-stack-discovery-limit

Conversation

@taegyunkim

@taegyunkim taegyunkim commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

PROF-14213

Clarifies the existing native stack safety ceiling by renaming MAX_TASK_FRAMES to MAX_STACK_UNWIND_SAFETY_LIMIT everywhere it is used, while retaining the value 2048 and the current behavior.

The ceiling applies to thread, task, and greenlet stack unwinding, truncation probing, and task-aware stitching, not just task stacks. The name and comment distinguish this internal safety ceiling from the configured per-sample frame limit.

Keeps asyncio boundary detection inline in find_upper_python_stack_size to minimize the diff. The full-stack scan, return semantics, and existing asyncio/uvloop boundary-frame caches are unchanged.

This deliberately does not introduce the bounded task frame budget from #19085.

Testing

Latest follow-up (4fcfbd6830):

  • scripts/lint cformat --fix and scripts/lint cformat: passed.
  • scripts/lint checks: passed (existing repository-wide AST-grep warnings were reported).
  • git diff --check: passed. No MAX_STACK_DISCOVERY_DEPTH references remain.
  • Targeted scripts/run-tests in the Python 3.13 profiling environment could not start: environment setup reported an inaccessible worktree Git path and a permission error reading the generated requirements cache. The latest follow-ups have not been runtime-tested.

Previously recorded validation, before these review follow-ups:

  • Python 3.13 profiling environment: 408 passed, 35 skipped, 2 xfailed.
  • Python 3.13 uvloop profiling environment: 411 passed, 32 skipped, 2 xfailed.
  • Native stack standalone test build on Python 3.13: all 23 C++ tests passed, including StackUnwind.ProbeBudgetExhaustionRemainsUnknown.
  • scripts/run-benchmarks --list <changed files>: no matching benchmark suites.

Risks

Low. This is an internal naming and comment change. The safety-limit value, all call sites, full-stack boundary scan, boundary caching, and stitching behavior are unchanged.

Additional Notes

This is prerequisite 1 for #19085.

No release note is needed because the change is internal and behavior-preserving; the PR uses the changelog/no-changelog label.

@taegyunkim taegyunkim added the changelog/no-changelog A changelog entry is not required for this PR. label Sep 15, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c058e08 | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

No remaining files require a CODEOWNERS review.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 1 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 210 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 210 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=133)
ddtrace.debugging._debugger -×-> ddtrace.trace  (product:debugging -> product:tracing, score=131)
ddtrace.llmobs._integrations.claude_agent_sdk -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)
ddtrace.aiguard._api_client -×-> ddtrace.trace  (product:aiguard -> product:tracing, score=131)
ddtrace.llmobs._integrations.litellm -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@taegyunkim taegyunkim changed the title refactor(profiling): clarify stack discovery limits refactor(profiling): clarify stack unwind safety limit Sep 18, 2026
@taegyunkim
taegyunkim marked this pull request as ready for review September 18, 2026 19:22
@taegyunkim
taegyunkim requested a review from a team as a code owner September 18, 2026 19:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T19:23:48.608784Z c058e08 Draft marked ready
🔒 Security Review ✅ Completed 2026-09-18T19:25:28.582462Z c058e08 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 1bfcfc7 into main Sep 21, 2026
475 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the taegyunkim/prof-14213-clarify-stack-discovery-limit branch September 21, 2026 14:30
taegyunkim added a commit that referenced this pull request Sep 21, 2026
Adopt MAX_STACK_UNWIND_SAFETY_LIMIT from #20352 while retaining asyncio task frame budgeting and upstream task-address discovery changes.
brettlangdon pushed a commit that referenced this pull request Sep 23, 2026
## Description

[PROF-14213](https://datadoghq.atlassian.net/browse/PROF-14213)

Clarifies the existing native stack safety ceiling by renaming `MAX_TASK_FRAMES` to `MAX_STACK_UNWIND_SAFETY_LIMIT` everywhere it is used, while retaining the value 2048 and the current behavior.

The ceiling applies to thread, task, and greenlet stack unwinding, truncation probing, and task-aware stitching, not just task stacks. The name and comment distinguish this internal safety ceiling from the configured per-sample frame limit.

Keeps asyncio boundary detection inline in `find_upper_python_stack_size` to minimize the diff. The full-stack scan, return semantics, and existing asyncio/uvloop boundary-frame caches are unchanged.

This deliberately does not introduce the bounded task frame budget from #19085.

## Testing

Latest follow-up (`4fcfbd6830`):

- `scripts/lint cformat --fix` and `scripts/lint cformat`: passed.
- `scripts/lint checks`: passed (existing repository-wide AST-grep warnings were reported).
- `git diff --check`: passed. No `MAX_STACK_DISCOVERY_DEPTH` references remain.
- Targeted `scripts/run-tests` in the Python 3.13 profiling environment could not start: environment setup reported an inaccessible worktree Git path and a permission error reading the generated requirements cache. The latest follow-ups have not been runtime-tested.

Previously recorded validation, before these review follow-ups:

- Python 3.13 profiling environment: 408 passed, 35 skipped, 2 xfailed.
- Python 3.13 uvloop profiling environment: 411 passed, 32 skipped, 2 xfailed.
- Native stack standalone test build on Python 3.13: all 23 C++ tests passed, including `StackUnwind.ProbeBudgetExhaustionRemainsUnknown`.
- `scripts/run-benchmarks --list <changed files>`: no matching benchmark suites.

## Risks

Low. This is an internal naming and comment change. The safety-limit value, all call sites, full-stack boundary scan, boundary caching, and stitching behavior are unchanged.

## Additional Notes

This is prerequisite 1 for #19085.

No release note is needed because the change is internal and behavior-preserving; the PR uses the `changelog/no-changelog` label.


[PROF-14213]: https://datadoghq.atlassian.net/browse/PROF-14213?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: taegyun.kim <taegyun.kim@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants