-
-
Notifications
You must be signed in to change notification settings - Fork 983
Thread wakeup visualization #1021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR does the following things: - Allow to lock the highlighted thread using left mouse click or lane popup menu - Add more descriptions for wait reasons in View::DecodeContextSwitchReason - Stores the Wakeup CPU so that we may display it in the CPU data view - `QueueThreadWakeup` now contains cpu and adjust info (currently unused). Fits in the padding, no struct size change. - `QueueContextSwitch` now also contains thread priorities information (windows+linux) and CState (windows), but currently unused by the profiler. Fits in the padding, no struct size change. - Fixes Linux `EventWakeup` which tries to remove PERF_SAMPLE_CALLCHAIN on the wrong member. Set the whole `perf_event_attr` explicitely instead. - Fixes Windows ReadyThread event being dropped if triggered before the thread switches out (this is confirmed to be normal behaviour, probably due to thread being switched out but context switch actually happening later) - Bumps tracy file version and protocol versions
|
Please update the manual to explain the changes you've made. As it now is I don't really know what the screenshots show. Having a proper writeup will help with code review. |
|
I added a new paragraph and illustration to the manual (pages 78-79 for me). |
|
Fixed the latest comments (I think), and also added
|
|
Selecting a thread on the CPU data list hijacks the highlight functionality. Threads hovered over with the mouse will not be highlighted until the selection is removed. These should be two separate things. |
…o always unsigned delta results)
We were never drawing the wakeup of the very first known context switch.
…the cpu data timeline
|
It seems that there are subtle differences between sched_wakeup and sched_waking (there's also sched_wakeup_new) and that the origin CPU might not be the one of the wakee depending on various things ... See https://perfetto.dev/docs/data-sources/cpu-scheduling I'll investigate a bit more. Note that on windows, it is possible that a thread seemingly unrelated readies (wakes up) another if it triggers the scheduler by calling any kind of synchronization or syscall. (this mostly happens when thread was already ready to be scheduled). From what I saw on windows, we're now displaying the same things as WPA and Pix. |
I suppose I could make it unslect as long as you click anything else than a thread in the cpu timeline then? But then you would un select the thread when clicking zones, I'm not sure this is the behavior we want. And I don't think we have an easy way to know we clicked on an empty space as of now? I'll add an "unselect" in the lane pop-up menu of the currently selected thread in the meantime |
The behavior should be consistent, and currently it isn't. With https://github.com/wolfpld/tracy/pull/1021/files#r2036164986 it is possible to select a thread, but there's no way to unselect it. |
`sched_wakeup` notifies about the kernel saying it will be waking up the thread, not the reason for the actual wakeup. This only allows to measure the scheduling latency, not the full wake up latency. Instead, use `sched_waking` which is triggered on the ring of the CPU and thread responsible for the wakeup. `target_cpu` contains the cpu on which the thread will be woken up.
…the CPU data timeline, and can unselect from the thread timeline menu
|
On my PC it I had a different issue, the marker was not covering the bottom line, while on your screenshot it's the top line. Could it be something related to inverted Y-axis on some renderers ? Anyway, I added +1 to the end of the line Y since |
In the end it seems that
Instead, I replaced This was confirmed by analysing the ftrace output (for example here using |
…readHighlight` can be set when hovering, and thus clicking, a thread lane name)
|
…s called `HandleTimelineMouse` did the following - `m_highlight.active = true` when clicked - update range while dragging - `m_highlight.active = false` when not dragging This causes issues when `IsMouseClickReleased` is called somewhere else as - `mousePotentialClickRelease` is set to true on click - At beginning of frame, `mouseDragging` is set to `false` as long as `mousePotentialClickRelease` is `true` and mouse delta is under the drag threshold - This means that if the mouse didn't move enough in the duration of a frame, highlight would immediately stop, even though we were still holding the mouse button down Instead, it now only stops highlighting once the mouse is no longer down (ie: has been "released", cursor having moved or not)
|
I think with this last fix there should not be any pending issues anymore (as far as I'm concerned). Do you need me to address anything else for this PR ? |
|
I'll try to take a look. |
|
Thanks! |
|
can we add support wakeup vis for |


















This PR does the following things:
QueueThreadWakeupnow contains cpu and adjust info (currently unused). Fits in the padding, no struct size change.QueueContextSwitchnow also contains thread priorities information (windows+linux) and CState (windows), but currently unused by the profiler. Fits in the padding, no struct size change.EventWakeupwhich tries to remove PERF_SAMPLE_CALLCHAIN on the wrong member. Set the wholeperf_event_attrexplicitely instead.Screenshots of the wakeup viz:
In the future we should be able to retrieve the readying thread information, such as its callstack, by iterating the per-core context switch data. Ideally we would also have a way to draw an arrow between the thread lanes and not just the CPU cores data ?