Repository navigation
fix(profiling): correlate AnyIO worker profiles - #19556
taegyunkim merged 1 commit into
Conversation
Circular import analysis
|
Codeowners resolved asResolved from the full PR diff against |
This comment has been minimized.
This comment has been minimized.
65af43a to
39c9f71
Compare
7f285d6 to
8eae04c
Compare
39c9f71 to
4dc91bf
Compare
8eae04c to
d4cf68d
Compare
4dc91bf to
b5d8e2d
Compare
Dependency direction analysis
|
BenchmarksBenchmark execution time: 2026-08-17 19:37:09 Comparing candidate commit 6c7ea9a in PR branch Found 0 performance improvements and 6 performance regressions! Performance is the same for 616 metrics, 10 unstable metrics.
|
d4cf68d to
6a57deb
Compare
b5d8e2d to
435c1db
Compare
6a57deb to
1550a86
Compare
86707b6 to
34de381
Compare
3750446 to
94e436d
Compare
34de381 to
5240d90
Compare
94e436d to
61588e2
Compare
3718a42 to
607f5c9
Compare
08220b6 to
f0490a5
Compare
607f5c9 to
4fdd955
Compare
f0490a5 to
5c53913
Compare
4fdd955 to
1f5977f
Compare
5c53913 to
ed14a06
Compare
1f5977f to
6c7ea9a
Compare
6c7ea9a to
6b510d0
Compare
ed14a06 to
5ecd359
Compare
|
Superseded by #19737 after reordering the stack to asyncio, then AnyIO, then gevent. GitHub marked this PR merged when its old base branch was restacked above its head; no code was merged to main. |
Description
Problem
AnyIO copies the active tracing context when
anyio.to_thread.run_syncoffloads synchronous work, but entering that copied context does not emit a tracing activation event. The profiler therefore associates the request span with the asyncio task while worker-thread samples remain unattributed.Solution
Wrap the callable submitted through AnyIO's public thread-offload API. On worker entry, publish the inherited profiler span metadata to the physical thread after validating its generation and span lifetime. Clear the physical mapping unconditionally when the callable exits so pooled workers cannot retain attribution across requests.
This reuses the existing native physical-thread mapping and finished-span cleanup. It does not change tracing semantics or add native code.
Review stack
Please review this stack in order:
Testing
388 passed, 46 skipped, 2 xpassedtest_anyio_to_thread_span_linksregression passedscripts/lint cformatscripts/lint checksgit diff --checkRisks
finallyblock, preventing pooled workers from retaining stale attribution.Additional Notes
The focused regression covers positive endpoint/span attribution and cleanup when the same AnyIO worker is reused outside the trace. The profiling Riot lockfiles are regenerated for the added AnyIO dependency. The merged base includes #19529's hardened reused-worker sampling assertion.
Release note:
fix-anyio-worker-profile-attribution-abbf595ce67e6ad1.yaml.Pre-review checklist