fix(dev): a Tracy build captures at full rate again (fibres off unless asked for), and the game-code zones give a valid capture #1546
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1546
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/tracy-game-zones"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: fix · Risk: low · Tested on: Linux, RTX 3090 (NVIDIA 620.70) · Needs: none beyond #1543's (Windows, a build with the option on)
TL;DR
The Tracy profiler build that came in with #1543 captured at a fraction of the game's frame rate (10 to 19 fps in a scene that runs at 65), and its zones in the game's own code stopped a capture within milliseconds. This PR fixes both: the same scene now captures at 36 fps with every zone on, and a 20 s capture with the game-code zones is valid (723 frames, 11.0 million zones). Only builds made with
LONGSHOT_TRACY=1change; a player's build compiles none of it.Breakdown
LONGSHOT_TRACY_FIBERS=1); the lifted code carries its zone as 16 bytes of the host's own; the game-code zones are on by default in a Tracy build again.LONGSHOT_TRACY=1, apart from one row's text in the switch table.Why
#1543 was merged with two faults that only a capture shows. First, its last commits added
TRACY_FIBERSwhile a failing capture was being chased; fibers turned out to have nothing to do with it, and the define costs most of the frame rate while a capture is taken. Second, the zones in the game's own code (HOS_TRACY_GAME=1, off by default there because they did not work) stopped a capture with "Invalid order of zone begin and end events". This is a regression fix for that PR; no issue is open for it.How to reproduce
Seen on: Linux, RTX 3090, NVIDIA 620.70
Settings and switches: a build of
main@ef6038abmade withLONGSHOT_TRACY=1; for the second fault alsoHOS_TRACY_GAME=1Steps: start the game, go into play (Kokiri Forest), run
tracy-capture -a 127.0.0.1 -o run.tracyfor 20 sExpected: the game keeps most of its frame rate while the capture is taken; the capture runs until it is stopped
Actual: 10 to 19 fps while capturing against 65 before; with
HOS_TRACY_GAME=1the capture ends after a few milliseconds ("Invalid order of zone begin and end events"), ortracy-capturecrashes while savingWhat changed
Two fixes in the Tracy build and the defaults that follow from them.
nx2/build.py):TRACY_FIBERSis defined only withLONGSHOT_TRACY_FIBERS=1;host/hos_tracy.h'sHT_FIBER_ENTER/HT_FIBER_LEAVEare empty without it. The fiber switch inhost/hos_thread.cstill logs the first five switches that happen with a game zone open, which is when the option would be needed; none was seen.host/hos_tracy_game.c,nx2/tracy_funcs.py): Tracy's zone context is 16 bytes withTRACY_ON_DEMANDand 8 without. The header the job loops' chunk is compiled with now declares the zone asHtCallZone, 16 bytes of the host's own, and the host copies Tracy's context in and out of it (hos_tracy_call_begin/hos_tracy_call_end, with a_Static_asserton the size); the chunk includes nothing of Tracy.HOS_TRACY_GAMEis on again in a Tracy build (=0none,funcsorcallsone kind); the row ingpu/vk/switches.defsays so.docs/development/tracy.md(fibers as a sub-option and why, the capture's cost, the game-code zones as working, the samples' names as not yet).tests/test_tracy_funcs.pyfollows the header's new zone type.Measurements
Verdict: it helps: the same headless scene captures at 36 fps instead of 10 to 19, with more zones recorded.
Hardware: Linux, RTX 3090, NVIDIA 620.70, Ryzen 9 7900X.
Scene: Kokiri Forest, headless at 2048x1152, the camera turning; frame rate cap 240; about 65 fps before a capture starts.
Method: one session each;
tracy-capturefor 20 s on a port of its own; frames, zones and file size astracy-capturereports them, the zone counts from the capture's statistics. Other jobs ran on the PC beside these, so the frame rates are rough: single runs, not medians.How to reproduce: a pack built with
LONGSHOT_TRACY=1, the game started headless into play,timeout -s INT 20 tracy-capture -a 127.0.0.1 -p <port> -o run.tracy -f.The clean capture with the game-code zones (After, last row): 1,469,461
game callzones (73,800 a second, about 2,000 a frame), the 11 listed functions with counts that fit a frame (the frame's body, the actor batch and the frame wait 719 to 721 times in 723 frames; the two job loops 12,960 and 18,488 times), no zone left open, no failure, and the file reads back.Flags and settings
One new build sub-option; one switch's default changes. Both exist only for builds made with
LONGSHOT_TRACY=1.LONGSHOT_TRACY_FIBERS=1HOS_TRACY_GAME=1on, broken)=0off;funcs,calls)Testing
Tested: Linux, RTX 3090, NVIDIA 620.70, Ryzen 9 7900X: the headless captures above, in the game, in Kokiri Forest; the After capture read back with a summary of its threads, zones and open zones. Game-free checks:
tests/run_all.py --changedthrough the PC's queue (result in the first comment);tests/test_tracy_funcs.pypasses.Not tested: a played (not headless) session on this PR's build; a capture longer than 20 s with the game-code zones; the names of the lifted code's samples (they show as
[unknown] + address: not fixed here); the viewer GUI; AMD and Intel GPUs.Must be tested:
LONGSHOT_TRACY=1(never compiled there); the game-code zones are Linux's (ELF objects) and are left out on Windows bynx2/build.py(Test Farm: @Beanstalk windows, a build with LONGSHOT_TRACY=1 and a start of the game).Risks
What could break: nothing in a build without the option. In a Tracy build: a zone open across a fiber's move to another thread would stop a capture ("Invalid order of zone begin and end events"); the log then has
tracy: a fiber switch ... with N game call zones open, andLONGSHOT_TRACY_FIBERS=1is the build for it.Turning it off:
HOS_TRACY_GAME=0for the game-code zones; revert the commit for the rest.Compatibility: Nothing changes for a player: the switch table's row for
HOS_TRACY_GAMEhas a new text, nothing else of a build without the option is touched.Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). (only--changedrun; see the first comment)third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Tested in game: RTX 3090, NVIDIA 620.70, Ryzen 9 7900X, Linux, headless in Kokiri Forest with tracy-capture on a port of its own: with fibers told to Tracy (main's setting) 203 to 382 frames in 20 s while capturing (10 to 19 fps; 65 before the capture); without, and with the game-code zones on (HOS_TRACY_GAME=1 set by hand, on the build one edit before this one), 723 frames in 19.9 s, 11.01 million zones, 1,469,461 game call zones, no failure, the file reads back; a 70 s capture with the per-draw zones off: 2,118 frames, 16.6 million zones, 177 MB. Game-free checks, run_all.py --changed through the queue: 59 pass, 6 fail (test_dev_packs, test_failed_compile_keeps_objects, test_link_skip, test_linux_preflight, test_linux_update, test_switch_table), all six among the 36 that fail on a clean checkout of main on this PC. This PR's exact code is built; its own 20 s capture with the default environment is queued and will be a comment here.
WIP: fix(dev): a Tracy build captures at full rate again (fibres off unless asked for), and the game-code zones give a valid captureto fix(dev): a Tracy build captures at full rate again (fibres off unless asked for), and the game-code zones give a valid captureThis PR's exact code (
d379fbaf), built as a pack and run headless in Kokiri Forest on Linux, RTX 3090, NVIDIA 620.70, with the default environment (the game-code zones and the per-draw zones on, Tracy's sampler on) and a quieter PC than the runs in the description: 1,205 frames in 20 s while capturing (60 fps, against about 65 before a capture), 19.2 million zones (961,000 a second), 2,458,703game callzones, a 132 MB file, no failure, no zone left open, and the file reads back. A single run.