Commit Graph

42 Commits

Author SHA1 Message Date
Bartosz Taudul
03227f7ae1 Update identify.cpp build instructions. 2026-05-24 15:35:43 +02:00
Bartosz Taudul
32b46a3b90 Cleanup. 2026-05-23 23:53:22 +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
Alan Tse
9a7233ced5 Add MCP server for AI-assisted trace analysis (#1347)
* Add MCP server for AI-assisted trace analysis.

Introduce an optional Model Context Protocol (MCP) server that lets AI
assistants analyze Tracy captures and live sessions through Tracy's own
server engine. The server runs as a Python sidecar and talks to the
existing C++ analysis code through new pybind11 bindings.

- python/bindings/ServerModule.cpp: TracyServerBindings module exposing
  Worker, file I/O, zones, GPU zones, frame data, plots, messages, locks,
  source locations, and summary statistics (zone/GPU child stats, frame
  timing, etc.).
- python/CMakeLists.txt: builds and installs TracyServerBindings alongside
  TracyClientBindings.
- extra/mcp/tracy_mcp.py: FastMCP SSE singleton with dynamic port
  discovery, PID-file based singleton detection, session-isolated worker
  instances, synchronous and background eval, task polling, and a
  shutdown tool to release the .pyd lock during development.
- extra/mcp/start_mcp.sh, .gitignore: launcher with local override hook;
  ignores generated port/pid files.
- manual/tracy.md: documents building, running, and integrating the
  server with an AI assistant.

* Improve Tracy MCP cold-start guidance.

Cold-start usability testing showed an LLM agent burned ~7 exploratory
calls discovering the ctx object model, time-unit conventions, and join
keys before producing useful analysis. Surface that information up front
through MCP resources and entry-point tool guidance.

- extra/mcp/eval_guide.md: new bindings-layer reference covering the
  Worker object graph (zone / GPU zone / frame / thread / message /
  plot / lock / memory entry points), nanosecond time units, ZoneStats
  field semantics including self-time via get_child_zone_stats, the
  opaque 'name (addr)[arch] <srcloc_id>' key format, and worked
  examples translating common queries into ctx Python.
- extra/mcp/tracy_mcp.py: expose system.prompt.md and eval_guide.md as
  MCP resources (tracy://prompt and tracy://eval-guide) so external
  agents and Tracy Assist share the same guidance source. Resource
  content is re-read per request — edits propagate without a server
  restart.
- Point load_capture and live_connect return values plus the eval tool
  description at the resources, so the agent reads them before its
  first eval rather than introspecting blind.
- Expand load_capture docstring: name the path parameter explicitly,
  show Windows path syntax, and direct agents to list_captures plus
  TRACY_CAPTURES_DIR for capture discovery.
- Probe is_connected() briefly after Worker construction in
  live_connect and surface an actionable error on silent handshake
  failures (typically a Tracy client/server version mismatch or
  TRACY_ON_DEMAND) instead of returning misleading success.

Reduces a fresh agent's cold-start overhead from 7 exploratory calls
to 4, where the remaining 4 are unavoidable harness/schema-fetch
overhead, not API-design friction.

* Detect Tracy protocol mismatches via UDP broadcast pre-flight.

Tracy clients announce themselves on UDP port 8086 every ~3 seconds with
a BroadcastMessage carrying the protocol version, listen port, and
program name (public/common/TracyProtocol.hpp). The Tracy GUI reads this
and refuses to attempt a TCP connection on protocol mismatch, surfacing
a precise error. live_connect previously had no equivalent check, so a
mismatch produced an opaque 2-second handshake timeout with no
diagnostic about what was wrong.

- Add a broadcast parser handling versions 0-3, with variable-length
  programName (Tracy sends only the actual name + null terminator on
  the wire, not the full 64-byte buffer).
- Add a non-blocking UDP listener that binds 8086 with SO_REUSEADDR
  and waits up to 3.5s — enough to guarantee catching at least one
  beat at the 3s broadcast cadence.
- Read our bindings' ProtocolVersion at startup by parsing
  TracyProtocol.hpp, so the comparison stays in sync with the build
  without new C++ wiring.
- live_connect runs the broadcast pre-flight before constructing
  Worker. On a matched listen_port with a differing protocol_version,
  it returns a single-line error naming the program, both versions,
  and the remediation, without ever opening a TCP connection. If no
  matching broadcast arrives, it falls through to the existing
  handshake probe, which now reports any other broadcasts seen as a
  hint (helpful when the target uses a non-default port).

* Add MCP Server section to LaTeX manual.

The markdown manual is auto-generated from the LaTeX source; add the
corresponding \subsection{MCP Server} so the two stay in sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove hand-written MCP section from tracy.md.

tracy.md is generated from tracy.tex via latex2md.sh. The MCP section
was previously written by hand directly in the markdown; now that the
LaTeX source has been updated, the markdown section should be
regenerated by running latex2md.sh rather than maintained manually.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 16:17:55 +02:00
Bartosz Taudul
73694c7a24 Cleanup enums. 2026-01-24 01:50:11 +01:00
Clément Grégoire
eba268ad9d Fix #996 Remove any need for python during build
We are now using only CMake to generate `GitRef.hpp`. This should make it easier to build on Windows.
We use git's pretty formatting instead of rev-parse to output the full file in a single command, then CMake's `copy_if_different` to avoid unnecessary rebuilds.

Trick is to use %n for newlines and %x22 for quotes. See https://git-scm.com/docs/pretty-formats

We also output "unknown" and a warning when git is not available.
2025-05-24 01:16:08 +02:00
Bartosz Taudul
87285cfcaa Add support for using other rev than HEAD in git-ref.py. 2024-09-20 22:04:25 +02:00
Bartosz Taudul
5934f5da9a Generate git revision to a header file. 2024-09-08 14:18:52 +02:00
Bartosz Taudul
bb1e717026 Update magic string to look for in tracy files. 2024-06-02 14:32:33 +02:00
Bartosz Taudul
6e14d1ff45 Add summary printer for robin hood. 2024-05-25 00:03:23 +02:00
Bartosz Taudul
535a2c8504 Add pretty-printer for ZoneEvent. 2024-05-24 23:45:16 +02:00
Bartosz Taudul
b405370af9 Add lldb pretty printers for ShortPtr, Vector, Int24, Int48. 2024-05-23 23:32:10 +02:00
Bartosz Taudul
4b14d961f0 Add LLDB summary for Vector. 2024-05-12 19:23:18 +02:00
Bartosz Taudul
657bf7d44c Add images for more proper zigzag mip chain.
1x1 and 2x2 paths are 16 px wide.
4x4 path is 8 px wide.
8x8 path is 4 px wide.
16x16 path is 2 px wide.
32x32 path is 1.5 px wide.
2023-04-29 12:47:29 +02:00
Bartosz Taudul
f7b12e2dda Add zigzag bitmap. 2023-04-27 23:17:34 +02:00
Kirk Klobe
70afa6c62c update make-build.sh to change meson.build version 2023-03-23 07:55:03 -05:00
Bartosz Taudul
be392a76fb Move TracyVersion.hpp to common. 2022-08-27 16:05:36 +02:00
Bartosz Taudul
1d60c0cd5b Remove leftovers. 2022-08-18 13:18:39 +02:00
Bartosz Taudul
06c7984a16 Move all client headers and sources to public/ directory. 2022-07-17 15:47:38 +02:00
Bartosz Taudul
468add6799 Update identify.cpp build instructions. 2022-04-18 14:01:56 +02:00
Bartosz Taudul
d0a234bbf5 Add tracy dump mime type definition. 2022-04-13 23:01:06 +02:00
Bartosz Taudul
9013d71d70 Steal desktop entry definition from AUR repository. 2022-04-13 21:55:14 +02:00
Bartosz Taudul
aed1360a9c Update to MSVC 2022. 2021-11-13 00:49:26 +01:00
Bartosz Taudul
2544b891de Add goodness color generator. 2021-05-23 12:49:20 +02:00
Bartosz Taudul
6d8abfe640 Add utility for trace version identification. 2021-05-18 02:49:41 +02:00
Bartosz Taudul
d6fa6da0ed Add build automation script. 2021-02-06 23:57:14 +01:00
bjacob
dfdf70aea3 Fix shutdown with TRACY_NO_EXIT=1 on Android. (#134) 2020-11-26 20:33:54 +01:00
Bartosz Taudul
322cc3bf12 Add missing op description list definition. 2020-11-07 00:15:58 +01:00
Bartosz Taudul
da036bf322 Save asm op description. 2020-11-06 23:56:26 +01:00
Bartosz Taudul
c9352ce228 Check for more throughput values. 2020-11-06 23:43:47 +01:00
Bartosz Taudul
81dc6c216e Add version printer. 2020-09-10 20:38:22 +02:00
Bartosz Taudul
3992eb0542 Move RDO threshold logic to tables. 2020-06-11 14:09:19 +02:00
Bartosz Taudul
9488ee0f9e Add micro architecture data processing utility. 2020-04-27 00:59:49 +02:00
Bartosz Taudul
0850a5e4a3 Use a proper build script. 2019-09-27 00:06:45 +02:00
Bartosz Taudul
6094d69479 Manually load required symbols. 2019-09-27 00:05:41 +02:00
Bartosz Taudul
9de2d312a3 Tiny binary. 2019-09-26 23:54:08 +02:00
Bartosz Taudul
6f5dd44f1f Helper for reading data from kernel more efficiently. 2019-09-26 22:55:02 +02:00
Bartosz Taudul
bdfb568742 Fix div tables for max range on all channels. 2019-07-01 12:31:06 +02:00
Bartosz Taudul
b73f428739 Add DXT1 div table generator. 2019-06-29 11:49:52 +02:00
Bartosz Taudul
d593e5dfa9 DXT1 SIMD color index table generator. 2019-06-28 21:57:38 +02:00
Bartosz Taudul
e87abfa7bc X11 colors conversion program. 2018-07-04 18:26:57 +02:00
Bartosz Taudul
ca0053d4d4 Add memory decay color table creation program. 2018-07-04 18:24:56 +02:00