Commit Graph

10110 Commits

Author SHA1 Message Date
Clément Grégoire
1c26daa3ac Detect unreliable TSC on Linux via perf timestamp probe.
Linux exposes time_zero/time_mult/time_shift on the perf_event mmap
page for converting sample timestamps back to TSC cycles, gated by
cap_user_time_zero. That flag only states the conversion math is
valid; on Ryzen the kernel can leave it set while TSC silently drifts
between cores, before the clocksource watchdog catches it. We've had
user reports of this surfacing as garbage timestamps in traces.

CheckLinuxPerfTscConsistency() first looks at the current clocksource
in sysfs, then opens a dummy PERF_COUNT_SW_DUMMY event and verifies
that a PR_SET_NAME-triggered PERF_RECORD_COMM timestamp inverts back
into the rdtsc-sandwiched window with ~1 ms of slack. Modeled on
tools/perf/tests/perf-time-to-tsc.c.

Wired into CheckHardwareSupportsInvariantTSC() so a failing probe
calls InitFailure in non-fallback builds and routes GetTime() to
clock_gettime in TRACY_TIMER_FALLBACK builds. Inconclusive cases
(perf blocked, no COMM record, etc) return true to avoid penalising
sandboxed environments. Gated on TRACY_HAS_SYSTEM_TRACING so we only
probe when Tracy would actually open perf events.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 16:11:39 +02:00
Bartosz Taudul
6957f968a4 Include trace time span in llm system message. 2026-05-22 02:06:58 +02:00
Bartosz Taudul
896cdc9462 Fade-out outdated assistant replies.
The "outdated" concept is strictly for chain of assistant replies with
nothing in between, i.e.:

"I will check this..."      <- outdated
<tool call>                 <- not displayed
"Now I will do that..."     <- outdated
<tool call>                 <- not displayed
"Let me consider..."        <- outdated
<reasoning>                 <- not displayed
"Now I have the answer..."

The first three messages are at this point considered outdated, as the
model provided a more recent message.

Note that in chain such as below there are NO outdated messages:

"How can I help..."
<user input>
"Ah, I see..."
<user input>
"You may try to..."

Similarly, if the tool calls or reasoning sections are explicitly enabled
in the chat UI, the messages are also not considered outdated.
2026-05-21 21:23:14 +02:00
Bartosz Taudul
efc33a09d9 Fix potential issue with last chat turn detection. 2026-05-21 20:51:58 +02:00
Bartosz Taudul
61875e1bd0 Add LLM tool for listing sampling statistics. 2026-05-21 20:27:54 +02:00
Bartosz Taudul
e003885946 Merge pull request #1369 from siliceum/feature/no-sys-param-for-bsd
Drop sys/param.h dependency for BSD detection
2026-05-21 17:57:16 +02:00
Bartosz Taudul
d40806caff Merge pull request #1368 from siliceum/fix/timeline-depth
Prevent unlimited recursion leading to stack overflow
2026-05-21 17:50:58 +02:00
Clément Grégoire
e7c71c991c Drop sys/param.h dependency for BSD detection
Replace `#ifdef BSD` (which requires including `<sys/param.h>` first) with explicit checks for `__FreeBSD__`, `__NetBSD__`, `__OpenBSD__` and `__DragonFly__`, matching how these BSDs are already enumerated elsewhere in the codebase (OS name strings, thread id helpers, etc.).

This also avoids leaking the `sys/param.h` requirement through public headers (`TracySysTime.hpp`, `TracyCallstack.h`), where consumers would otherwise need it to correctly see `TRACY_HAS_SYSTIME` / `TRACY_HAS_CALLSTACK`.
`libbacktrace/config.h` is left as-is — it's third-party and only included from .c files where the `BSD` macro can still be picked up locally.

Note: for `setsockopt( m_sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&val, sizeof( val ) );` I added `__APPLE__` too since this was the only place where it was not checked explicitely.
2026-05-21 10:18:30 +02:00
Clément Grégoire
69855a1416 Prevent unlimited recursion leading to stack overflow
This can happen notably when the user does not call ZoneEnd.

I used 256 arbitrarily as it seemed higher values would just make the UI freeze anyway due to perf reasons.
I added a warning in the notification area so that users can locate it.
2026-05-21 09:38:43 +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
Bartosz Taudul
b48ef9a2ab Merge pull request #1366 from siliceum/fix/ondemand-no-callstack-hang
Fix ProfilerWorker hang when TRACY_HAS_CALLSTACK is not defined
2026-05-20 18:05:42 +02:00
Clément Grégoire
e59601cf1c Fix ProfilerWorker hang when TRACY_HAS_CALLSTACK is not defined 2026-05-20 17:51:42 +02:00
Bartosz Taudul
43472f1226 Merge pull request #1365 from siliceum/feature/fiber-tests
Add fiber to test app
2026-05-20 12:34:45 +02:00
Clément Grégoire
c1177a0cde Add fiber to test app
This simulates fibers on different threads. Was used to discover an issue reported on discord which led to #1364
2026-05-20 12:07:05 +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
14a1a3227e Add guidance about function context. 2026-05-20 02:26:14 +02:00
Bartosz Taudul
8582715fa5 Add information about addresses in callstacks. 2026-05-20 02:26:14 +02:00
Bartosz Taudul
d51634ad24 Include ip and base addr in json callstack frames. 2026-05-20 02:26:14 +02:00
Bartosz Taudul
4bbfe5edbd Add tool for getting symbol parent calls. 2026-05-20 02:26:14 +02:00
Bartosz Taudul
55c5348fad Make GetCallstackJson public. 2026-05-20 00:41:20 +02:00
Bartosz Taudul
5b4dcd4655 Add support for parent callstacks to GetCallstackJson. 2026-05-20 00:27:24 +02:00
Bartosz Taudul
a380046e17 Switch symbol disassembly tool to use symbol address parameter. 2026-05-19 23:52:20 +02:00
Bartosz Taudul
6494285283 Include hex address ofthe symbol in disassembly json. 2026-05-19 23:41:36 +02:00
Bartosz Taudul
ec92f2fac3 Update NEWS. 2026-05-19 22:50:11 +02:00
Bartosz Taudul
07b2600c08 Do not spam wikipedia. 2026-05-19 21:58:15 +02:00
Bartosz Taudul
562a120087 Merge pull request #1362 from alandtse/feature/mcp-save-trace
Add save_trace MCP tool for snapshotting live or loaded captures
2026-05-19 12:21:46 +02:00
Alan Tse
33fe84532e Add save_trace MCP tool for snapshotting live or loaded captures.
- save_worker binding: wraps Worker::Write under
  Worker::ObtainLockForMainThread() so live instances yield their
  receive thread cooperatively for the save's duration — the same
  pattern View::Save uses in the GUI.
- save_trace MCP tool: defaults to async_mode=True for multi-GB
  traces; reuses the existing Task/executor machinery so callers
  poll via the task tool. Path resolution mirrors load_capture.
- manual/tracy.tex: add save_trace bullet to the MCP tool list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 01:23:31 -07:00
Bartosz Taudul
1f1738c221 Make glow bigger. 2026-05-18 01:00:38 +02:00
Bartosz Taudul
eb411b1138 Merge pull request #1361 from rmehri01/patch-2
fix: header definition of start/end sampling profiling
2026-05-17 21:57:22 +02:00
Bartosz Taudul
cf5325032e Make the symbol view hotness indicators more chonky.
The previous uniform glow rectangle was not appropriate anymore, so the
glow was changed to be a proper gradient.
2026-05-17 21:53:06 +02:00
Ryan Mehri
f74a452b89 fix: header definition of start/end sampling profiling 2026-05-17 15:16:45 -04:00
Bartosz Taudul
365c99e601 Restore frameData->imageName.Active() checks. 2026-05-17 18:58:29 +02:00
Bartosz Taudul
b8f68e3fae Add local call stacks to sample statistics inlines list. 2026-05-17 18:13:52 +02:00
Bartosz Taudul
5d4ba366ba DrawSourceTooltip reports if source was printed. 2026-05-17 17:58:22 +02:00
Bartosz Taudul
a7937d2710 Move local callstack printing to a separate function. 2026-05-17 17:56:14 +02:00
Bartosz Taudul
efd7ec262d Set default LLM address to llama.cpp port. 2026-05-17 17:50:33 +02:00
Bartosz Taudul
f0f579172b Force inline fast check. 2026-05-17 16:06:56 +02:00
Bartosz Taudul
4c6157d249 Remember last retrieved external check result. 2026-05-17 15:43:26 +02:00
Bartosz Taudul
6ae6fb741e Check if image is external once, before checking subframe filenames.
Cache is shared between image names and source file names, because the
underlying StringIdx storage makes indices unique. Both name sets should
be completely separate, but if you have conflicts here, you have much
more pressing problems to solve.
2026-05-17 15:30:03 +02:00
Bartosz Taudul
4ab7ef301e Split IsFrameExternalImpl into image + filename parts. 2026-05-17 15:30:03 +02:00
Bartosz Taudul
41f1172774 Change order of IsFrameExternal checks.
Check image first, then perform the expensive filename check.
2026-05-17 14:30:45 +02:00
Bartosz Taudul
b18d81cbbe Explicitly state which code paths are important to consider. 2026-05-17 14:08:54 +02:00
Bartosz Taudul
03e60c902f Clamp max percentage bar width. 2026-05-16 13:30:51 +02:00
Bartosz Taudul
0b88cbaa3c Fix z/x keys in source view when the child panes (src/asm) are focused. 2026-05-16 13:29:26 +02:00
Bartosz Taudul
5b180fdd5f Restore const qualifiers dropped in 744bd21 for global cache. 2026-05-14 22:59:10 +02:00
Bartosz Taudul
03f737a923 Use local external frame cache in BuildFlameGraph.
In terms of how much BuildFrameGraph execution time was spent in
IsFrameExternal:

1. no cache: 67%
2. global + shared_mutex: 84%
3. global + mutex: 80%
4. local: 41% (this commit)
2026-05-14 22:44:59 +02:00
Bartosz Taudul
4e0259148f Change IsFrameExternal interface to work with external cache.
Locks are dominating the execution time, making the global cache non-viable.
2026-05-14 22:29:51 +02:00
Bartosz Taudul
a3cadb2fce Protect against localtime failures. 2026-05-14 22:06:22 +02:00
Bartosz Taudul
6789e7d6f9 Cosmetics. 2026-05-14 20:36:55 +02:00
Bartosz Taudul
c3e3ea98ad Add basic information about the profiling session to system prompt. 2026-05-14 19:51:42 +02:00