Metal GPU Trace
v0.33.0Measure Wine and macOS GPU use on Apple silicon (Metal System Trace) and Windows (PresentMon)
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
perf_record Record a program
Records `program` (an .exe under Wine, or a macOS binary with wine="native") or a test `workload` for `seconds` with Metal System Trace and returns its summary: GPU ms per frame, frame intervals, FPS, Metal and resident memory. It then stops every program of that Wine prefix (wineserver -k), or with native the program it launched and its children. tier sets memory and counters together; compare recordings of the same tier.
| Parameter | Type | Description |
|---|---|---|
label * | string | run name: letters, digits, '.', '_', '-' |
api | string | with workload: mtl, mtl-x64 (Metal under Rosetta), vk (needs METAL_TRACE_MOLTENVK), d3d11 or d3d12 (under wine) |
args | string | program arguments as in a shell |
background | boolean | macOS, default false; true throttles the program hard and unevenly (taskpolicy -b): repeat the run |
counters | boolean | default false; true adds gpu_counters; not on Windows; about 40 s of read-back per second |
dim | integer | with drawstress: cube grid side, dim^3 draws per frame |
env | string | NAME=VALUE pairs separated by spaces; MTL_SHADER_VALIDATION=1 or MTL_DEBUG_LAYER=1 adds `validation` |
example | string | with a workload that lists examples: the one to run |
fields | array | result paths to keep, dotted: common.frame_pacing |
fingerprint_paths | array | files to hash into the summary; compare shows changes |
memory | boolean | default true; false skips the slowest table, Metal memory (no metal_mib_peak) |
memory_free_pct | integer | macOS, 20 to 60: holds the whole Mac at this % RAM free while recording; lower can freeze it |
prefix | string | Wine prefix, default WINEPREFIX or ~/.wine; ignored with native |
program | string | path of the .exe, or of the macOS binary with wine=native |
seconds | integer | seconds, default 20; 30 under Wine (start-up eats part); the export takes minutes under Wine |
size | string | with drawstress: window size, such as 1920x1080 |
tier | string | default standard. light: no memory or counters; standard: memory; deep: also counters and a kept .trace (macOS). memory and counters given alone override |
wine | string | Wine directory holding bin/wine, or native |
workdir | string | directory to start in, default the program's own |
workload | string | a test program from workload_list (fetch it first) instead of program |
perf_baseline_record Record a reference
Records the same program `count` times with perf_record's arguments and saves the runs as the reference `name` for perf_check, returning the range each number spans. Runs are `name`-1, `name`-2, ... Each takes its seconds plus about a minute of read-back.
| Parameter | Type | Description |
|---|---|---|
name * | string | name: letters, digits, '.', '_', '-' |
api | string | |
args | string | |
background | boolean | |
cooldown_s | number | seconds to rest between recordings, 0 to 600, default 0; 60 on a laptop is a start, thermal_state_share says if it throttled |
count | integer | equal recordings to make, default 3 |
counters | boolean | |
dim | integer | |
env | string | |
example | string | |
fields | array | result paths to keep, dotted: common.frame_pacing |
memory | boolean | |
memory_free_pct | integer | |
prefix | string | |
program | string | |
seconds | integer | |
size | string | |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them; perf_check applies the same cut |
tier | string | |
wine | string | |
workdir | string | |
workload | string |
perf_sweep Record one run per value of a variable
Records the same program once per value of one variable and returns, per value, the median FPS, 1 % low, GPU ms per frame and stutter; with 3 or more numeric values also the line GPU ms follows (fixed ms plus ms per unit) with its r2. With rounds above 1 the values run in reverse every other round, so drift hits all alike. Runs are `name`-<value number>-r<round>; each takes its seconds plus about a minute of read-back. `metric` app_metrics.<column> adds that telemetry column per value, with a fit.
| Parameter | Type | Description |
|---|---|---|
name * | string | name: letters, digits, '.', '_', '-' |
values * | array | 2 to 8 values of the variable, such as [10, 20, 30] for dim |
variable * | string | what changes: dim, example, api, size, or env:NAME |
api | string | |
args | string | |
background | boolean | |
cooldown_s | number | seconds to rest between recordings, 0 to 600, default 0; 60 on a laptop is a start, thermal_state_share says if it throttled |
counters | boolean | |
dim | integer | |
env | string | |
example | string | |
fields | array | result paths to keep, dotted: common.frame_pacing |
memory | boolean | |
memory_free_pct | integer | |
metric | string | app_metrics.<column>, a column of the program's telemetry |
prefix | string | |
program | string | |
rounds | integer | default 1, at most 5 and 24 recordings in all |
seconds | integer | |
size | string | |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them |
tier | string | |
wine | string | |
workdir | string | |
workload | string |
perf_ab Record two settings in A B B A order
Records the same program with two environments in the order A B B A (`rounds` times) and says per metric whether B is better, worse or the same as A, with every value behind it. Runs are `name`-a1, `name`-b1, ... Each takes its seconds plus about a minute of read-back. `fingerprint_paths` stops it before the next recording if one of those files changed.
| Parameter | Type | Description |
|---|---|---|
env_a * | string | NAME=VALUE pairs for side A, the reference (empty: none) |
env_b * | string | NAME=VALUE pairs for side B, the change under test (empty: none) |
name * | string | name: letters, digits, '.', '_', '-' |
api | string | |
args | string | |
background | boolean | |
cooldown_s | number | seconds to rest between recordings, 0 to 600, default 0; 60 on a laptop is a start, thermal_state_share says if it throttled |
counters | boolean | |
dim | integer | |
example | string | |
fields | array | result paths to keep, dotted: common.frame_pacing |
fingerprint_paths | array | files to hash into the summary; compare shows changes |
memory | boolean | |
memory_free_pct | integer | |
prefix | string | |
program | string | |
rounds | integer | A B B A rounds, default 1 (4 recordings), at most 5 |
seconds | integer | |
size | string | |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them |
tier | string | |
wine | string | |
workdir | string | |
workload | string |
perf_cold_warm Record a run twice to find first-seen shader stutter
Records the same program twice and says what the first run suffers that the second does not: shader-compile hitches (first minus second, never below 0), each run's hitch count and compiler time. macOS only. Runs are `name`-first and `name`-second.
| Parameter | Type | Description |
|---|---|---|
name * | string | name: letters, digits, '.', '_', '-' |
api | string | |
args | string | |
background | boolean | |
counters | boolean | |
dim | integer | |
env | string | |
example | string | |
fields | array | result paths to keep, dotted: common.frame_pacing |
memory | boolean | |
memory_free_pct | integer | |
prefix | string | |
program | string | |
seconds | integer | |
size | string | |
tier | string | |
wine | string | |
workdir | string | |
workload | string |
perf_attach Record a running program
Records a program that is already running, by pid or by a name in its command line, for `seconds`, and returns perf_record's summary; the program keeps running. For games from Steam, CrossOver or any launcher: start the game first.
| Parameter | Type | Description |
|---|---|---|
label * | string | name: letters, digits, '.', '_', '-' |
process * | string | pid, or a name in the program's command line such as Game.exe |
fields | array | result paths to keep, dotted: common.frame_pacing |
seconds | integer | recording length, default 20 |
project_info Show the active project
Says which project is active: its name, baseline and format, the folder its recordings go to and where that folder comes from (the project file, METAL_TRACE_OUT or the default ./perf-runs). Without a project file, project and baseline are null.
| Parameter | Type | Description |
|---|---|---|
fields | array | result paths to keep, dotted: common.frame_pacing |
perf_runs List recordings
Lists the saved recordings, newest first, with frames, FPS, GPU ms per frame, memory peaks and the translation layer each ran on; project names the project they belong to.
| Parameter | Type | Description |
|---|---|---|
fields | array | result paths to keep, dotted: common.frame_pacing |
limit | integer | default 50, at most 500 |
offset | integer | default 0 |
perf_compare Compare two recordings
Compares two saved recordings, a the reference and b the run after a change: headline numbers (FPS, GPU ms, frame pacing, memory), then the GPU work: encoders and command buffers per frame, share of short encoders, idle time, and each encoder label's change, largest first. `layer` says whether both ran on the same translation layer; `measure` marks Windows against Metal (use FPS, lows, stutter, jitter); runs under 100 frames are flagged. `screen`, `noisy_environment` flag runs that do not compare; `suggested_actions` says what to call next.
| Parameter | Type | Description |
|---|---|---|
a * | string | run name from perf_runs: the reference, such as the run before a change |
b * | string | run name from perf_runs: the run to compare against a |
fields | array | result paths to keep, dotted: common.frame_pacing |
markdown | boolean | also return the numbers as Markdown tables, default false |
short_us | integer | an encoder under this GPU time counts as short: 10, 25 (default), 50, 100, 250, 500 or 1000 |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them |
perf_baseline Name a reference
Names a reference for perf_check, or lists them. With name and runs (equal runs of one program) it saves their summaries as the reference, replacing a previous one, and returns each number's range and `spread_pct`: the noise a change must exceed. With name alone it shows that reference; with nothing it lists them.
| Parameter | Type | Description |
|---|---|---|
fields | array | result paths to keep, dotted: common.frame_pacing |
name | string | reference name; alone, shows that reference |
runs | array | run names to save as this reference, ideally 3 or more equal runs |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them; perf_check applies the same cut |
perf_check Check a run against a reference
Judges a recording against a reference from perf_baseline: regressed when FPS falls under the reference's lowest, or GPU ms per frame rises over its highest, by more than margin_pct, or encoders or command buffers per frame exceed its highest; improved when a number leaves the range the other way and none regressed; same otherwise. Windows against Metal is judged on FPS alone. Returns the reasons and perf_compare's comparison.
| Parameter | Type | Description |
|---|---|---|
baseline * | string | a reference name from perf_baseline |
run * | string | a run name from perf_runs |
fields | array | result paths to keep, dotted: common.frame_pacing |
margin_pct | number | how far outside the reference's range FPS or GPU ms per frame may fall before counting, default 3 |
perf_export_trace Export frames to Perfetto
Writes a recording's GPU frames as `<run>.chrome-trace` in the runs directory, for ui.perfetto.dev and chrome://tracing: one slice per GPU frame. Returns the file name and the number of frames.
| Parameter | Type | Description |
|---|---|---|
run * | string | a run name from perf_runs |
fields | array | result paths to keep, dotted: common.frame_pacing |
perf_gate Check a run against budgets
Checks a recording against budgets and says pass or fail: FPS and 1% low floors, ceilings for stutter rate, p95 GPU ms per frame, hitches and peak Metal MiB. Give at least one. A number the recording lacks fails its budget (value null), and so does a run that stopped presenting (`unpresented`). Returns each budget with its limit, value and whether it held.
| Parameter | Type | Description |
|---|---|---|
run * | string | a run name from perf_runs |
fields | array | result paths to keep, dotted: common.frame_pacing |
fps_1pct_low_min | number | the 1% low FPS must be at least this |
fps_min | number | the FPS must be at least this |
gpu_ms_p95_max | number | the p95 GPU ms per frame at most this |
hitches_max | number | the number of hitches at most this |
metal_mib_max | number | the peak Metal memory in MiB at most this |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them |
stutter_rate_pct_max | number | the share of stutter frames, in %, at most this |
perf_history Follow a number across runs
Lists the recordings whose name starts with `prefix`, oldest first, with FPS, 1% low, GPU ms, stutter, hitches and peak Metal MiB, and the change from first to last. A trend is real only above the spread_pct of perf_baseline. Windows and Metal runs in one series are flagged.
| Parameter | Type | Description |
|---|---|---|
prefix * | string | the start of the run names to follow: letters, digits, '.', '_', '-' |
fields | array | result paths to keep, dotted: common.frame_pacing |
limit | integer | newest runs to keep, default 50 |
skip_s | number | seconds to leave out at the start (shaders compile, resources load), default 0; GPU numbers, hitches and Metal memory are recomputed without them |
perf_diagnose Diagnose encoder use
Says whether a saved recording splits its GPU work into too many short encoders (the pattern of translation layers such as DXMT, Mullion or MoltenVK), with the numbers: encoders and command buffers per frame, share of short encoders, labels with the most GPU time, idle time (read with the FPS: vsync idles too). `suggested_actions` says what to call next.
| Parameter | Type | Description |
|---|---|---|
run * | string | a run name from perf_runs |
fields | array | result paths to keep, dotted: common.frame_pacing |
min_encoders | integer | encoders per frame (median) from which the verdict can be yes, default 4 |
short_share | number | share of short encoders from which the verdict is yes, default 0.25 |
short_us | integer | an encoder under this GPU time counts as short: 10, 25 (default), 50, 100, 250, 500 or 1000 |
perf_memory_breakdown Break down Metal allocations by type
Breaks down the Metal allocations of a saved recording by type (texture, buffer, heap...): allocated, still live and `gone` per type. A small live share of a large allocated size is churn, the pattern behind a memory spike or a stall. Also totals, live memory by mode, allocation rate and peak. Needs a Metal recording above tier light.
| Parameter | Type | Description |
|---|---|---|
run * | string | a run name from perf_runs |
fields | array | result paths to keep, dotted: common.frame_pacing |
top | integer | how many resource types to keep, the largest allocated first, default 10 |
trace_tables List a trace's tables
Lists the data tables of a recording: those of its .trace when kept, else those its tables file stored.
| Parameter | Type | Description |
|---|---|---|
trace * | string | a run name from perf_runs with trace_kept or tables_kept true, or a .trace path |
fields | array | result paths to keep, dotted: common.frame_pacing |
trace_count Count a trace's rows
Counts the rows of tables of a recording, in all and per process: a table with 0 rows needs another instrument or Xcode, not a bigger page. Reads the .trace when kept, else the tables file.
| Parameter | Type | Description |
|---|---|---|
trace * | string | a run name from perf_runs with trace_kept or tables_kept true, or a .trace path |
fields | array | result paths to keep, dotted: common.frame_pacing |
tables | array | table names from trace_tables; default the tables that matter for a translation layer |
trace_query Read a trace table
Returns one page of rows of one table of a recording as {column: value}, optionally one process's. With window_ms the page holds time windows instead ({start_ms, count}, plus duration_ms when the table has a duration column). Rows come from the .trace when kept, else from the tables file; where, columns, order_by with descending, and group_by with aggregates filter and summarize the tables file (never SQL) and need it.
| Parameter | Type | Description |
|---|---|---|
schema * | string | a table name that trace_tables lists, such as metal-gpu-intervals |
trace * | string | a run name from perf_runs with trace_kept or tables_kept true, or a .trace path |
aggregates | array | tables file only: {fn, column}, fn count, sum, avg, min or max; named fn_column |
columns | array | tables file only: keep these columns |
descending | boolean | with order_by, largest first |
fields | array | result paths to keep, dotted: common.frame_pacing |
group_by | array | tables file only: group rows by these columns (each group gets its count) |
limit | integer | default 50, at most 500 |
offset | integer | default 0 |
order_by | string | tables file only: a column, or with group_by an aggregate name such as count or sum_duration |
pid | integer | keep only this process's rows |
where | array | tables file only, joined by AND: {column, op, value}, op one of = != < <= > >=; a time or size column holds its number as text: compare with a number |
window_ms | integer | 1 to 3600000: time windows of this many ms instead of rows (needs a start or time column) |
capture_summary Summarize a capture
Reads a Metal .gputrace capture without Xcode: command buffers, encoders, draws, debug groups, and the 100 most frequent call ids out of calls_total.
| Parameter | Type | Description |
|---|---|---|
capture * | string | a .gputrace bundle inside METAL_TRACE_OUT or METAL_TRACE_READ |
fields | array | result paths to keep, dotted: common.frame_pacing |
capture_diff Compare two captures
Compares two .gputrace captures by their confirmed Metal calls: totals per call (a, b, delta) and the 100 debug groups with the largest change. Needs no Xcode.
| Parameter | Type | Description |
|---|---|---|
a * | string | the first .gputrace (usually the one before a change) |
b * | string | the second .gputrace |
fields | array | result paths to keep, dotted: common.frame_pacing |
capture_records Read a capture's records
Returns one page of the records of a .gputrace command stream, with their Metal call names when known.
| Parameter | Type | Description |
|---|---|---|
capture * | string | a .gputrace bundle inside METAL_TRACE_OUT or METAL_TRACE_READ |
fields | array | result paths to keep, dotted: common.frame_pacing |
limit | integer | default 50, at most 500 |
offset | integer | default 0 |
screenshots_check Flag black, flat, frozen or flickering screenshots
Flags screenshots that show nothing useful: black, uniform (one flat colour) and, with `sequence` (the folder's PNGs in name order are frames of one run), frozen (3 identical frames in a row) and flicker. `ignore_rects` leaves out areas that change alone, such as a clock. Returns {"frames", "ok", "findings": [{"file", "problem"}]}.
| Parameter | Type | Description |
|---|---|---|
path * | string | a PNG, or a folder of PNGs (in a readable folder), 100 at most |
fields | array | result paths to keep, dotted: common.frame_pacing |
ignore_rects | array | areas to leave out, [x0, y0, x1, y1] as fractions 0 to 1 |
sequence | boolean | true: the PNGs, in name order, are frames of one run; adds frozen and flicker |
wine_log_census Count what a Wine log says is missing or wrong
Counts what a Wine debug log says is missing or wrong, by level, channel and message (numbers, paths and quoted text removed so repeats group), plus HRESULTs and the longest silence between +timestamp lines. No raw line leaves.
| Parameter | Type | Description |
|---|---|---|
path * | string | a Wine debug log, or a folder of logs (in a readable folder), 50 at most |
fields | array | result paths to keep, dotted: common.frame_pacing |
top | integer | messages to list, 1 to 100, default 15 |
gpu_family Apple GPU family facts
Apple's published facts for one GPU family ("Apple7") or chip ("M1 Pro"): its chips, what it adds, its limits, the limits shared by all families, footnotes and source URLs.
| Parameter | Type | Description |
|---|---|---|
name * | string | a family (Apple7 to Apple10) or a chip (M1 Pro, M2, M4 Max, A17 Pro) |
fields | array | result paths to keep, dotted: common.frame_pacing |
workload_list List test programs
Lists the test programs workload_fetch can download, such as bgfx's drawstress: what each measures, its size, license and APIs, and whether it is already downloaded.
| Parameter | Type | Description |
|---|---|---|
fields | array | result paths to keep, dotted: common.frame_pacing |
workload_fetch Download a test program
Downloads a test program from this project's GitHub releases once, checks its SHA-256 against the one this package pins, and keeps it in ~/Library/Caches/metal-gpu-trace; later calls reuse it. The programs are built from source by the project's workloads workflow. A workload with `downloads` (Godot) also fetches each of those zip files from its own publisher, checks its SHA-512 against the one data/workloads.json pins and unzips it into the workload's folder.
| Parameter | Type | Description |
|---|---|---|
name * | string | a workload name from workload_list, such as drawstress |
fields | array | result paths to keep, dotted: common.frame_pacing |
presentmon_install Install PresentMon (Windows)
Windows only: downloads Intel's PresentMon console application (MIT) from its GitHub release, checks its SHA-256 against the one this package pins, and keeps it in %LOCALAPPDATA%\metal-gpu-trace, where perf_record and perf_attach find it; later calls reuse it. It needs administrator rights or the Performance Log Users group to run.
| Parameter | Type | Description |
|---|---|---|
fields | array | result paths to keep, dotted: common.frame_pacing |