Repository navigation
fix(profiling): drop asyncio creator links for fire-and-forget tasks - #22110
taegyunkim wants to merge 1 commit into
Conversation
Tasks created with asyncio.create_task and never awaited were stitched under their creator, so their samples included the creator's frames, often on-CPU frames the creator ran at sample time. Render them as their own root task instead, on every Python version. Await, gather, wait, shield and TaskGroup links are unchanged.
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
BenchmarksBenchmark execution time: 2026-11-26 00:17:05 Comparing candidate commit 4ffc78f in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 572 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.
|
Description
The stack profiler linked each
asyncio.create_taskchild to its creator and drew it under the creator when nothing awaited it. Each child sample then carried whatever the creator was running at that moment, including the creator's own on-CPU frames.This removes creator links on every Python version: the
create_taskhook,weak_link_tasks, and the sampler's weak-link map. A task nothing awaits now shows as its own root, as in CPython 3.15's sampling profiler. Links from await, gather, wait, as_completed, shield and TaskGroup are unchanged.Customer impact
Fire-and-forget tasks appear as separate roots in flame graphs instead of under their creator, without the creator's frames. Release note included.
Testing
test_asyncio_fire_and_forget.pyfails on main and passes here.test_asyncio_churn_links.pynow churns gather links and runs under uvloop.Risks
Users lose the grouping of background tasks under their creator.
Additional Notes
PROF-16348. Not benchmarked; the change only removes work.