Commit Graph

274 Commits

Author SHA1 Message Date
Bartosz Taudul
ec1c2d4267 Display aggregation counts in bottom / up sample trees. 2026-05-24 14:23:59 +02:00
Bartosz Taudul
60247b68d3 Merge pull request #1364 from siliceum/fix/zone-runtime
Fix and refactor zone running time
2026-05-20 19:29:29 +02:00
Clément Grégoire
91c0b1e42b Fix and refactor zone running time
Many of the zones would have a negative running time due to a missing `cs->IsEndValid()` check.
This could end reporting context switches before the zone start, due to `cs->End()` returning -1.

This happened when systrace dropped event, or when using Fibers and `TracyFiberEnter` is called on the new thread once the fiber has been scheduled. (The manual actually does not really hint this is wrong, we should probably fix the manual or the server code.)

In both cases, we assume runtime to be 0 for that context switch. Since we have no actual information. Both options (counting full runtime or no runtime) are wrong, and most of the code handling `!cs->IsEndValid()` uses `Start` instead so that's what I did. This is still a net improvement over displaying negative values. If we want to change this handling, we'd need to review the other places that do `it->IsEndValid() ? it->End() : it->Start()` as well.

It also seems two different concepts were being mixed:
1. Do we have any context switch data at all ? (`it != ctx->v.end()` ie `count != 0`)
2. Do we have complete data for the last context switch (`eit != ctx->v.end()`)

This led to some places of the code not displaying or counting running time at all, notably when hovering a zone.

I think most of the time we wanted 1, as it reports correctly and assumes the last context switch is still running, which is a fair assumption if we didn't see one putting the thread to sleep.

I also fixed a case where we were overcounting runtime when range start was during a sleep.
2026-05-20 12:02:38 +02:00
Bartosz Taudul
b90e44a5f1 Add raw data accessor to StringIdx. 2026-05-14 19:33:21 +02:00
Bartosz Taudul
73694c7a24 Cleanup enums. 2026-01-24 01:50:11 +01:00
Clément Grégoire
1e61dc88de Add source and severity to the server's MessageData + bump minor version for serialization
Note this does not change `sizeof(MessageData)` as there were 5 bytes left due to alignment. (now 3)
2025-12-28 14:50:38 +01:00
Eric Eaton
9caa91f06f Move the annotations data to the GPU context 2025-07-16 16:02:54 -07:00
Eric Eaton
3fce5c1280 Use a map to record counter values
This removes the limitation of 10 counters.
2025-07-11 17:17:05 -07:00
Eric Eaton
a754db16f8 Show counter name in GUI 2025-07-11 17:16:00 -07:00
Eric Eaton
2e49bdf4cb Add counter value collection 2025-07-11 17:16:00 -07:00
Clément Grégoire
296a3bb590 Add a comment about where to find KWAIT_REASON 2025-04-09 17:15:31 +02:00
Clément Grégoire
31859042bd Remove ContextSwitchData SetStartCpu and SetEndReasonState 2025-04-09 17:02:51 +02:00
Clément Grégoire
6486d8147d Fix formating issues 2025-04-08 13:48:50 +02:00
Clément Grégoire
df76b376a7 Thread wakeup visualization
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
2025-04-08 11:02:27 +02:00
Bartosz Taudul
84718101fe Use proper name for inline frames in flame graph. 2024-10-27 19:44:40 +01:00
Bartosz Taudul
9d2f874b02 Calculate flame graph begin times. 2024-10-27 11:58:23 +01:00
Bartosz Taudul
346d8a45c6 Cache flame graph. 2024-09-29 00:26:00 +02:00
Bartosz Taudul
717605065a Mark comparators const. 2024-09-26 14:04:20 +02:00
Bartosz Taudul
28a9750f8a Process thread group hints. 2024-08-03 20:10:36 +02:00
Bartosz Taudul
7d69103444 Add plot type "power" and Watt format.
Note that this technically breaks backwards compatibility of trace files
for 0.9.2 builds. But, whatever, as it's not yet released.
2023-03-10 01:25:41 +01:00
Bartosz Taudul
23705fd84c Add a reminder to keep interfaces in sync. 2023-03-10 01:07:06 +01:00
Bartosz Taudul
b481bb367c Switch plot drawing to the timeline items system. 2022-09-03 17:51:33 +02:00
Daniel
dc74b8adfd Using push/pop in all pragma pack pair to avoid potential padding bugs 2022-08-03 18:39:42 +08:00
Bartosz Taudul
b026e09a09 Include custom color in plot configuration. 2022-07-24 13:42:25 +02:00
Bartosz Taudul
b2a94cbfa2 Set plot fill using configuration message. 2022-07-24 13:10:20 +02:00
Bartosz Taudul
16627d7313 Plots may now be drawn as staircases. 2022-07-24 12:37:30 +02:00
Bartosz Taudul
efaf1df8d4 Move LockMap and LockHighlight definitions. 2022-07-23 15:54:48 +02:00
Bartosz Taudul
4d40a9cb53 Track locking thread on server side. 2022-07-18 02:06:19 +02:00
Bartosz Taudul
06c7984a16 Move all client headers and sources to public/ directory. 2022-07-17 15:47:38 +02:00
Bartosz Taudul
d8a611e952 Also calculate sample parents without inlines. 2021-11-27 17:47:09 +01:00
Bartosz Taudul
a02575322f Collect child sample addresses. 2021-11-27 02:03:59 +01:00
Bartosz Taudul
710a488af0 Handle postponed samples with SortedVector. 2021-11-14 23:48:50 +01:00
Bartosz Taudul
ffa8bf4d75 Use table instead of map to track reentrant calls. 2021-11-14 16:42:11 +01:00
Bartosz Taudul
1d7ab70199 Non-memory tree callstacks are not needed. 2021-11-13 22:09:16 +01:00
Bartosz Taudul
4f6e9bbb65 Generic callstack tree builder.
Previously this was exclusive for memory callstacks.
2021-11-13 22:06:04 +01:00
Bartosz Taudul
a2547ccf1d Rename CallstackFrameTree -> MemCallstackFrameTree. 2021-11-13 21:26:28 +01:00
Bartosz Taudul
745b795d50 Detect context switch callstack samples.
Context switch callstack samples are not included in the sampling data
statistics (as these don't represent random sampling), but are rather put into
a separate dedicated data structure.

For this to work, a complete context switch data has to be available for the
callstack timestamp. There is no guarantee it will be present at the time it
is needed, so a second structure is added to allow postponing qualification of
callstacks.
2021-11-13 02:40:32 +01:00
Bartosz Taudul
69e5cf796d Construct faux context switch data from fiber events. 2021-11-06 20:38:16 +01:00
Bartosz Taudul
3ede2a1345 Explicit tracking of fiber state in ThreadData.
This replaces the use of hard-to-track global state with well-defined accessor
functionality.
2021-11-06 18:55:29 +01:00
Bartosz Taudul
8f44f1c68b Store fiber state is ThreadData. 2021-11-02 01:45:01 +01:00
Bartosz Taudul
0bd1364c2f Calculate plot values sum. 2021-10-17 13:04:56 +02:00
xavier
e4ce9f0f41 Include threadid in SampleDataRange
TODO: maybe make lists per thread to avoid increasing the packed structure by 2 bytes?
2021-09-23 21:03:56 +02:00
Bartosz Taudul
b6db644ac6 Add hasher and comparator for StringIdx. 2021-07-11 19:43:40 +02:00
Bartosz Taudul
913463635a Cosmetics. 2021-06-23 20:37:14 +02:00
Terence Rokop
1f0b4656f4 Introduce SrcLocCountMap
Add to ThreadData a map from source location to a counter,
which will be used to keep track of the number of
appearances of zones with the corresponding source locations
on each thread's stack.
2021-06-20 17:56:14 -07:00
Bartosz Taudul
d49da69972 Count kernel samples. 2021-06-17 01:47:19 +02:00
Bartosz Taudul
5b642cad01 Implement combining sample callstacks.
This is required, because Windows will send two callstacks with the same
timestamp, one for kernel-space, second for user-space.
2021-06-15 02:25:12 +02:00
Bartosz Taudul
db1dc311b0 Add Int48 clearing function. 2021-06-15 02:04:32 +02:00
Bartosz Taudul
b7b9912b10 Handle GPU timer overflows with heuristics. 2021-06-09 21:08:47 +02:00
Bartosz Taudul
a1acea0c50 Support hw sample times on server. 2021-06-04 13:38:45 +02:00