Repository navigation
refactor(profiling): key native span links by execution unit - #21297
taegyunkim wants to merge 7 commits into
Conversation
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 15991fb | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-11-09 21:20:26 Comparing candidate commit 15991fb in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 588 metrics, 9 unstable metrics, 1 flaky benchmarks without significant changes.
|
…ministic Bind the entry's optional to a local before dereferencing it so bugprone-unchecked-optional-access can see the has_value() check. The contention test relied on two threads overlapping on the mutex, which valgrind's serialized scheduler never produced. Move the try-lock-then-hook logic into run_locked and test it with a mutex that another thread holds until the hook runs.
1b28267 to
3ea6750
Compare
|
Closing in favor of #21621. |
Description
The stack profiler stores one active span per OS thread in the native
SpanLinksmap. That's wrong when the span changes on the same thread: asyncio tasks, greenlets, and thread pool workers (see thexfailtests from #21236).This PR reworks only the native storage so later PRs can link spans per thread, task, or greenlet. Nothing calls the new operations yet. The existing thread-only operations behave as before.
retargetmoves links to the parent when a span finishes. Links to aContext, like a thread pool worker's copied context, stay put.birthnumber keeps the sampler from mixing up a freed task with a new one at the same address.Testing
New
SpanLinksKeyedtests. Span link tests pass under ASan+UBSan, TSan, and valgrind, andtests/profilingpasses on CPython 3.12.Risks
link_spanandunlink_finished_spanare on the hot path and reimplemented here. Existing tests cover them.Additional Notes
Python bindings follow in a stacked PR.