chore(profiling): require on-CPU frame state when matching running asyncio task #22107
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 194 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.315
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #22107"
general
weight: 0.35
gyuheon0h
Description
On Python 3.14+,
ThreadInfo::unwind_tasksreadsasyncio_running_taskbefore snapshotting tasks withget_all_tasks. If the running task suspends in between (or is betweencoro.send()returning andleave_task()), its coroutine snapshot is already suspended (is_on_cpu == false). Matchingorigin == running_taskwithout checkingis_on_cpuskipped stitchingpython_stackyet still charged the tick's CPU time to the task's suspended stack.Now the 3.14+ branch also requires
is_on_cpu, so a suspended snapshot falls through to the CPU-only thread sample withpython_stackintact.This also widens
task_outside_burnintest_asyncio_cpu_time.pyby 20 ms (two 10 ms ticks) so legitimate boundary ticks outsideburndo not flaketest_asyncio_cpu_time_taskgroup.Customer impact
None beyond unreleased #22050, which already carries the release note for asyncio CPU time attribution.
Testing
ThreadInfoTaskTraversalTest.SuspendedRunningTaskDoesNotClaimCpuTime(fails without thethreads.ccchange, passes with it).stackCTest on Python 3.15: 91/91 passed.df5925a36345): 14/14 asyncio profiler tests passed; across 60 repeated runs oftaskgroupandgather,asyncio.sleepCPU misattributions dropped from 12/90 to 0/60.scripts/lint checks,typing, andprofiling-native-checkpassed.Risks
None. When a task suspends mid-snapshot, CPU time goes to a CPU-only thread sample holding
python_stack.Additional Notes
Follow-up to #22050.