Repository navigation
refactor(profiling): key native span links by execution unit - #21621
Conversation
SpanLinks maps a thread id to its active span. Change the key to a (domain, identifier) pair with Thread, AsyncioTask and Greenlet domains, so that later changes can give each asyncio task and greenlet its own span next to the thread's. Only thread keys are written for now: existing methods and callers change only to build a thread key, and behavior is unchanged.
Dependency direction analysis
|
Codeowners resolved asResolved from the full PR diff against |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cecff1c269
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
More details
Existing span-link writers and renderers consistently use matching thread-domain keys, preserving lookup and cleanup behavior. Task and greenlet attribution remains deferred to follow-up changes.
🤖 Bits Code Review · Commit cecff1c
BenchmarksBenchmark execution time: 2026-11-09 21:47:38 Comparing candidate commit cecff1c in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 586 metrics, 9 unstable metrics, 1 flaky benchmarks without significant changes.
|
KowalskiThomas
left a comment
There was a problem hiding this comment.
Makes sense to me; I assume more will come for other kinds of execution units!
Description
JIRA: PROF-16348
The stack profiler stores each thread's active span in
SpanLinks, keyed by thread id. All asyncio tasks and gevent greenlets on one thread share that entry, so their samples all get the span that was activated last on the thread. The xfail tests intests/profiling/collector/test_stack_asyncio_endpoint_labels.py(#21236) show this for asyncio.This PR keys
SpanLinksby execution unit instead: a(domain, identifier)pair, where the domain isThread,AsyncioTaskorGreenlet. Follow-up PRs will write task and greenlet keys, so each one carries its own span.This PR only changes the existing methods and their callers:
link_span,unlink_spanandget_active_span(renamed fromget_active_span_from_thread_id, since it no longer takes a thread id) take aSpanLinkKey.stack.cppandstack_renderer.cpppassSpanLinkKey::thread(id).Testing
SpanLinksC++ tests now pass thread keys.KeysWithEqualIdentifiersInDifferentDomainsAreSeparate: a thread key and a task key with the same id don't affect each other.stack_testsuite, and clang-tidy with CI's checks on the changed files.Risks
None. Only thread keys are written, and each method does the same thing for them as before.
Additional Notes
No release note: an internal refactor with no user-visible change.