Expand description
Perf traces as the contract hands them to agents (ADR-0046 §7): the
frames’ records a session kept, read as a stream (PerfRead), summed
up (summary), and written as JSON lines (lines).
run --perf answers a PerfSummary, and with --perf-out writes
every kept frame as a line; the MCP server’s perf tool answers the
records since a number.
In a debug build of a game’s tool program each record has the heap’s
counts too (FrameRecord::heap), from the program’s own heap counter
(shuyi_alloc_count::global), and the summary sums them up
(HeapSummary). The counter counts the whole program: every thread’s
allocations. Where it counts by memory tag, run --perf takes a heap
snapshot before its script and one after its last frame, and the
summary has what held the heap and what grew (add_heap); the trace
file ends with the two snapshots and their diff (heap_lines).
Structs§
- Heap
Summary - How the heap’s counts add up over a trace’s records, in bytes asked for.
- Perf
Read - The records a session kept from a number on: a read of its stream.
- Perf
Summary - What a trace’s records add up to.
- Span
Summary - A span’s name and how its time adds up over the records.
Constants§
- HEAP_
ROWS - How many of a snapshot’s rows, and of a diff’s, a
PerfSummarykeeps. - HEAP_
THREADS - The limit of heap counts from this program’s own counter while it ran another thread beside the game’s.
- HEAP_
UNCOUNTED - The limit of records measured with no heap counts.
- HEAP_
UNTAGGED - The limit of heap counts with no snapshot by tag: the heap was counted, but not by memory tag.
- RESET
- The limit of a read whose
sinceis past itsnext. - TEXT_
CHANGES - How many of a diff’s changes the line for people names.
- TIMES
- The limit every answer with perf has: what its times are.
- TOP_
SPANS - How many of the spans with the most time a
PerfSummarynames.
Functions§
- add_
heap - Adds the heap snapshots
first(before a run) andlast(after it) tosummary:last’s firstHEAP_ROWSrows, and the diff fromfirsttolastwith its firstHEAP_ROWS. - dropped_
limit - The limit of a trace that dropped
droppedearlier frames. - heap_
limits - The limits of
records’ heap counts: none counted, or counted by this program’s own counter (process) while another thread ran (other_threads). - heap_
lines - The heap snapshots
firstandlastas a trace’s last lines: aPerfLine::Snapshoteach, then thePerfLine::Diffbetween them. - heap_
summary - How the heap’s counts add up over the records that have them, or
Nonefor none. - heap_
text diff’s line for people:heap grew 120.0 KB from frame 0 to 600: update +96.0 KB, image +24.0 KB, ai +4.0 KB, itsTEXT_CHANGESlargest changes;heap shrank …for fewer bytes,heap held its size …for as many;Nonewhen nothing changed.- lines
recordsas a trace: aPerfLine::Frameeach, as JSON, a line each, oldest first.- millis
usmicroseconds as milliseconds with one decimal, rounded to the nearest tenth, in integers:1250is1.3.- note_
other_ thread - Notes that this program runs a thread beside the game’s, from now on.
- other_
threads - Whether this program ran a thread beside the game’s
(
note_other_thread). - summary
- What
recordsadd up to, orNonefor no records; nothing dropped and no file. - text
summary’s line for people:perf: 600 frames, frame p50 1.2 ms p99 3.4 ms worst 8.0 ms; span ai 0.8 ms mean; heap peak 4.1 MB, then what grew in the heap (heap_text) and the trace file’s.- unmeasured_
limit - The limit of a session that measured nothing after
framesframes.