Skip to content

perf(profiling): reuse asyncio task unwind buffers#18568

Draft
taegyunkim wants to merge 3 commits into
mainfrom
taegyunkim/prof-14423-asyncio-tasks-buffer-reuse
Draft

perf(profiling): reuse asyncio task unwind buffers#18568
taegyunkim wants to merge 3 commits into
mainfrom
taegyunkim/prof-14423-asyncio-tasks-buffer-reuse

Conversation

@taegyunkim

@taegyunkim taegyunkim commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

Reuse native stack-collector buffers while unwinding asyncio Tasks. This mirrors the greenlet buffer-reuse optimization by keeping per-thread StackInfo slots and per-task coroutine FrameStack buffers alive across samples, reducing allocator churn and native heap growth in asyncio services with many long-lived tasks.

Testing

  • scripts/lint style tests/profiling/collector/test_asyncio_buffer_reuse.py && scripts/lint cformat && scripts/lint spelling releasenotes/notes/perf-profiling-unwind-asyncio-tasks-buffer-reuse-4f6e2a8b9c1d0e3f.yaml
  • scripts/run-tests --venv 95f8b96 tests/profiling/collector/test_asyncio_buffer_reuse.py -- -- tests/profiling/collector/test_asyncio_buffer_reuse.py -k test_asyncio_unwind_tasks_rss_stable
  • scripts/run-tests --venv 95f8b96 tests/profiling/collector/test_stack_asyncio_basic.py -- -- tests/profiling/collector/test_stack_asyncio_basic.py -k test_asyncio_basic

Risks

Low. The change preserves existing stack-rendering behavior while reusing cleared buffers between samples. Potential risk is stale task stack reuse; mitigated by resetting active counts at unwind entry and erasing coroutine-stack entries for tasks that are no longer present.

Additional Notes

Release note included.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

ddtrace/internal/datadog/profiling/stack/echion/echion/threads.h        @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/src/echion/threads.cc          @DataDog/profiling-python
releasenotes/notes/perf-profiling-unwind-asyncio-tasks-buffer-reuse-4f6e2a8b9c1d0e3f.yaml  @DataDog/apm-python
tests/profiling/collector/test_asyncio_buffer_reuse.py                  @DataDog/profiling-python

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 8 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741491-d2b8243-musllinux_1_2_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

View all 8 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 27fc4ed | Docs | Datadog PR Page | Give us feedback!

@taegyunkim taegyunkim changed the base branch from 1.x to main June 10, 2026 20:20
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.

1 participant