|
| 1 | +# Profiling Backends |
| 2 | + |
| 3 | +The repository supports multiple profiling backends through CMake. |
| 4 | + |
| 5 | +## Backend Selection |
| 6 | + |
| 7 | +Use: |
| 8 | + |
| 9 | +```bash |
| 10 | +-DCORTEX_PROFILING_BACKEND=NONE |
| 11 | +-DCORTEX_PROFILING_BACKEND=TRACY |
| 12 | +-DCORTEX_PROFILING_BACKEND=PERFETTO |
| 13 | +``` |
| 14 | + |
| 15 | +### `NONE` |
| 16 | + |
| 17 | +No profiling backend is enabled. |
| 18 | + |
| 19 | +### `TRACY` |
| 20 | + |
| 21 | +Uses the interactive Tracy client/profiler flow. |
| 22 | + |
| 23 | +If `CORTEX_ENABLE_TRACY` is not explicitly configured, the build falls back to the `DEFAULT` Tracy preset. |
| 24 | + |
| 25 | +What you need: |
| 26 | + |
| 27 | +- an instrumented build with `-DCORTEX_PROFILING_BACKEND=TRACY` |
| 28 | +- the Tracy Profiler GUI |
| 29 | +- a live connection between the running process and the profiler |
| 30 | + |
| 31 | +Important: |
| 32 | + |
| 33 | +- Tracy is mainly an interactive workflow |
| 34 | +- traces are not written automatically to disk by the client |
| 35 | +- if you want a saved trace, connect with the profiler and save the session from the UI |
| 36 | + |
| 37 | +Typical usage: |
| 38 | + |
| 39 | +```bash |
| 40 | +cmake -S . -B build \ |
| 41 | + -DWITH_TESTS=ON \ |
| 42 | + -DCORTEX_PROFILING_BACKEND=TRACY \ |
| 43 | + -DCORTEX_ENABLE_TRACY=DEFAULT |
| 44 | +cmake --build build --target tests |
| 45 | +./build/tests/tests "[SYNCHRONIZATION][GRAPH]" |
| 46 | +``` |
| 47 | + |
| 48 | +Tracy options are OFF, ON, DEFAULT, MEDIUM, EXTRA, WSL, WSL_EXTRA |
| 49 | + |
| 50 | +### `PERFETTO` |
| 51 | + |
| 52 | +Uses Perfetto's in-process backend and writes an offline trace file automatically at process exit. |
| 53 | + |
| 54 | +What you need: |
| 55 | + |
| 56 | +- an instrumented build with `-DCORTEX_PROFILING_BACKEND=PERFETTO` |
| 57 | +- a generated `.pftrace` file |
| 58 | +- either the web UI at `https://ui.perfetto.dev/` or another Perfetto-compatible viewer |
| 59 | + |
| 60 | +Typical usage: |
| 61 | + |
| 62 | +```bash |
| 63 | +cmake -S . -B build-perfetto \ |
| 64 | + -DWITH_TESTS=ON \ |
| 65 | + -DCORTEX_PROFILING_BACKEND=PERFETTO |
| 66 | +cmake --build build-perfetto --target tests |
| 67 | +export CORTEX_PERFETTO_TRACE_FILE=.artifacts/output.pftrace |
| 68 | +./build-perfetto/tests/tests "[SYNCHRONIZATION][GRAPH]" |
| 69 | +``` |
| 70 | + |
| 71 | +The trace file path can be overridden with: |
| 72 | + |
| 73 | +```bash |
| 74 | +export CORTEX_PERFETTO_TRACE_FILE=/path/to/output.pftrace |
| 75 | +``` |
| 76 | + |
| 77 | +If not set, the default output path is: |
| 78 | + |
| 79 | +```text |
| 80 | +.artifacts/perfetto/<executable>-<pid>-<timestamp>.pftrace |
| 81 | +``` |
| 82 | + |
| 83 | +relative to the process working directory. |
| 84 | + |
| 85 | +The generated trace file can be opened with: |
| 86 | + |
| 87 | +- https://ui.perfetto.dev/ |
| 88 | +- the standalone Perfetto UI / trace processor tools |
| 89 | + |
| 90 | +Recommended flow on this repository: |
| 91 | + |
| 92 | +1. Run the instrumented binary or test. |
| 93 | +2. Wait for the process to exit cleanly. |
| 94 | +3. Open `https://ui.perfetto.dev/`. |
| 95 | +4. Use `Open trace file` and load the `.pftrace`. |
| 96 | + |
| 97 | +Notes: |
| 98 | + |
| 99 | +- Perfetto is the better fit for offline captures that you want to inspect later. |
| 100 | +- The trace is flushed on shutdown, so if the process is killed hard you may lose the file. |
| 101 | +- The current instrumentation covers graph, RT, CRDT, bootstrap, and synchronization paths. |
0 commit comments