WIP: perf(host): a finished command recording is handed over instead of copied (HOS_NVN_REC_HANDOFF=0 to copy) #1780

Draft
snaildev99 wants to merge 4 commits from snaildev99/Longshot:perf/rec-handoff into main
Contributor

Summary

Every time the game finishes recording a batch of drawing commands, Longshot copies that batch once more on the game's own thread before the renderer gets it: about 750,000 recordings in a 75-second run of Castle Town's Market. docs/cpu-profile.md lists this copy as candidate 4, at 2.6 % of a core with 1.3 % on the serial threads. This PR hands a large finished recording over as it is and gives the command buffer a fresh segment instead, so that copy is no longer made. It is on by default; HOS_NVN_REC_HANDOFF=0 copies every recording as before.

The goal is less work on the game's threads for the same result. Frame rate is the check that nothing got slower, and where the processor sets the frame it rises: the Market ran 4.4 % faster standing still and 4.1 % faster turning the camera on main a433db32 (three interleaved runs a side), and +4.3 % / +2.2 % as the mean of eight on/off pairs in a 48-run matrix, with no memory growth.

How: rec_begin starts a recording after room for a copy's prefix; rec_end turns a recording that fills at least half of its segment into the handle (the prefix written in its room) and gives the command buffer a fresh segment; anything smaller goes through flatten as before. A handed-over block is laid out and freed exactly as a copy (free_dead_copies, release_copies, the sweep). Why half: copies live until their control memory is added again (about 53,000 live in the Market), and a segment is at least 64 KB, so handing over small recordings would multiply memory; at half full the block is at most twice the recording, the bound the pool's power-of-two classes already give a copy. Since 0f94b30c the nvn: line written every 50,000 recordings also says how many of those were handed off (the rest copied) and how many blocks the recording pool took from the heap since the last line, so a log shows how often the hand-off acts on a PC and whether its fresh segments come from the pool.

Read first: host/nvn_native.c (rec_handoff_on, read with env_on_or(..., 1); rec_begin, rec_end, and their calls in BeginRecording and EndRecording); tests/test_nvn_rec_handoff.py; the row in gpu/vk/switches.def.

See #1504 (the same function on Linux, from the lock side); #1034 touches its write marks. Neither is this change.

Testing

Tested: Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X. In the game: this change at its pre-rebase head in a test tree on main a433db32 (test/perf-prs @ be5623e0 on my fork, built from scratch twice, 0 failed): 15 hands-free Market runs, 6 with the switch on; in a v3.0.0 test tree, 24 Market runs with it on (15 s standing, 40 s turning each); before that two dozen hands-free runs in the Market and Hyrule Field with the first version on main 544229a2. No not a live recording, no FATAL and no frame of 50 ms or more in any log. The rebase onto main 068fb8eb (#1802) changed no code: only docs/development.md, which #1802 removed, lost the switch's row (its row in gpu/vk/switches.def is the reference now). The default went on in 620f3067 (env_on_or, the row a kill switch, the test run unset and =0): the code paths are the ones measured, only which is the default changed. Game-free at this head (620f3067): tests/test_nvn_rec_handoff.py (compiles the real pool, cmd_reserve_rec, flatten, rec_begin, rec_end; 3,000 recordings of 16 bytes to 1.5 MB in four command buffers, 64 handles kept, on and =0: every handle holds its bytes after later recordings and segment growth; on: 106 handed over, 2,894 copied; every block back in the pool; an end without a begin is copied as before; three controls fail it) and tests/test_switch_table.py and tests/test_env_on.py pass. tests/run_all.py on Windows at this head: 708 passed, 47 failed, 116 skipped; main 068fb8eb on this PC: 704 passed, 50 failed, 116 skipped. No failure that main does not have: main's, apart from timing tests that failed in one run only and pass when run alone (test_invalidate_vcore, test_compile_stops_on_exception, test_longshot_ctl, test_mesh_args_cleanup); test_vbytes times out at 600 s in both. Main's failures on this PC: test_appimage_player_build, test_auto_handheld, test_bug_report_defaults, test_capture_read_once, test_crash_dialog, test_crt_options, test_damage_debug_menu, test_dev_ab, test_dev_build, test_dev_migrate, test_dev_packs, test_display_startup_failure, test_dlss_feature_size, test_failed_compile_keeps_objects, test_frame_overlap, test_frame_wait_bounds, test_game_menu_mouse_buttons, test_guest_imported, test_high_fps_fixes, test_host_guest_writes, test_hud_layout_row, test_job_queue, test_libc_hooks, test_lift_cache, test_linux_preflight, test_linux_pressure, test_make_game_ngx, test_mise_build, test_missing_nup, test_mods_list, test_ngx_sdk, test_pads_after_menu, test_pending_guest_import, test_pipeline_play_cache, test_portable_builder_home, test_portable_builder_startup, test_prepare_cache_save, test_present_thread, test_profiling_mode, test_psychov35_fsr3_fg, test_readback_timeout_source, test_sdiv_overflow, test_seed_reader, test_slow_frames, test_song_note_cue, test_upscaler_rows, test_vcore_escape, test_walk_key. A Steam Deck OLED run by dukenheimer at 620f3067 (comment below; 1280x800, GPU-bound at ~21 fps): standing in the Market, off against on, two pairs: 21.65 to 21.25 fps (-1.8 %), both on runs below both off runs, 1 % low 16.0 to 14.65 fps; not yet explained (see Still to test). 0f94b30c changes only the log line's counters: tests/test_nvn_rec_handoff.py passes at it (the counters match its own counts, on and =0), and host/nvn_native.c compiles for Windows with the warnings main has.

Still to test:

  • Linux, any GPU: the Market for a few minutes, main against this PR; the game's CPU seconds with the frame rate capped at 60 on a PC that holds 60 there, and the frame times uncapped, expecting the same frame rate or better with less CPU time, the picture as on main, and no not a live recording in the log (@Beanstalk linux).
  • Linux on a Steam Deck: standing in the Market, HOS_NVN_REC_HANDOFF=0 against unset, at 0f94b30c, with the nvn: lines' hand-off and heap-block counts from both arms beside the frame times, expecting no frame rate lost on the switch (by hand).
  • An AMD or Intel GPU, any OS: the same, expecting the same (@Beanstalk amd).
  • A long play session across areas, cutscenes and the pause menu, and the other replay mode (RX_VK_ASYNC=0), expecting no fault and no not a live recording (by hand).

Measurements

Verdict: less work on the game's threads: large finished recordings are handed over, not copied. Frame rate is the check that nothing got slower, and where the processor sets the frame it rises: the Market +4.4 % standing and +4.1 % turning on main a433db32; no change in memory. Where the renderer sets the frame (Hyrule Field by day) about +1 %.

Baseline: one executable on both sides, the test tree test/perf-prs @ be5623e0 on my fork (main a433db32 with this PR and its siblings #1781 and #1782 merged, the default hot list, A64_VECFP=0 so the lifted code is main's). Before is every switch unset, which then ran main's code path (the switch was opt-in when measured; with this PR's default the same two sides are HOS_NVN_REC_HANDOFF=0 and unset); After sets only this one. Main has since moved four commits to 068fb8eb (#1802 docs, tools and the PR template; #1774 and #1807 the Insert menu's rows; #1792 dev packs): outside comments, docs and the dev tools they change the Insert menu's code (#1774, #1807) and the version string and some log texts (#1802): nothing in host/nvn_native.c, and nothing the Market runs each frame but the FPS counter's overlay, which runs alike on both sides. So the numbers hold.
Setup: Windows 11 (build 22631), GeForce RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X (12 cores), 128 GB. Child Link at the Market's save point by day; 3840x2160 full screen, frame rate cap Uncapped, no mods; the GPU wait 0.0 to 0.1 ms in every run (the processor sets the frame). Hands-free through scripts/longshot_ctl.py: the save loads, 10 s to settle, 15 s standing (the FPS counter's value once a second), then 40 s with the right stick held to one side. Three runs a side, interleaved, the median.

Before: test/perf-prs @ be5623e0, every switch unset After, HOS_NVN_REC_HANDOFF=1: test/perf-prs @ be5623e0 Δ
Market standing, fps (the three runs) 68.8 (68.9, 68.8, 68.2) 71.8 (71.8, 72.0, 71.2) +4.4 %
Market turning, fps (the three runs) 63.0 (63.0, 63.5, 62.8) 65.6 (65.1, 65.9, 65.6) +4.1 %

With its two siblings on as well, the same runs: 76.0 standing (+10.5 %) and 68.1 turning (+8.1 %). No frame of 50 ms or more, no FATAL and no not a live recording in any of the 15 logs.

The 48-run matrix

The change was measured beside every combination of #1781, #1782 and main's RX_VK_CAPTURE_NT, in one test tree test/perf-matrix @ 2c30c326 on my fork (v3.0.0 09cbdd97 with the three changes, every lifted file at -O2 so that the hot list is not a variable, built with A64_VECFP=0 and on). Sixteen variants, three interleaved runs each, 48 runs in 74 minutes with nobody at the PC. Before and After are the same executable; only this switch differs.

what else was on Before, unset: standing / turning fps After, set Δ standing Δ turning
nothing 68.5 / 63.5 71.2 / 64.5 +3.9 % +1.6 %
RX_VK_CAPTURE_NT=1 69.7 / 63.7 72.0 / 65.5 +3.3 % +2.8 %
HOS_OBJ_CACHE=16384 69.6 / 63.9 72.3 / 65.4 +3.9 % +2.3 %
both of those 70.0 / 63.8 73.1 / 65.8 +4.4 % +3.1 %
the float paths 71.5 / 65.7 74.2 / 67.1 +3.8 % +2.1 %
the float paths, RX_VK_CAPTURE_NT=1 71.2 / 65.6 75.0 / 67.7 +5.3 % +3.2 %
the float paths, HOS_OBJ_CACHE=16384 72.0 / 66.5 75.9 / 66.6 +5.4 % +0.2 %
all three 72.8 / 66.5 76.2 / 68.2 +4.7 % +2.6 %

Standing it gained in every pair (+2.3 to +3.9 fps). Peak working set over the eight pairs: 9,944 to 10,030 MB either way. The run file is docs/tested/2026-11-19-rec-handoff-snaildev99-matrix-h.md.

Offline (not a frame rate): tests/test_nvn_rec_handoff.py --bench, a recording written in records of 32 to 256 bytes plus its end, best of 7: 256 KB 72 to 24 microseconds, 1 MB 381 to 98, 2 MB 288 to 196.

unset: vk: the render thread (600 presents, 15.70 ms a frame): its jobs 12.82 ms a frame (submits 9.12, presents 1.25, others 2.45), idle 2.88
       nvn: 750000 recordings made, 52979 live copies (18.7 MB), 10687 texture copies; 2 command buffers' segments (4.1 MB)
set:   vk: the render thread (600 presents, 15.35 ms a frame): its jobs 13.02 ms a frame (submits 8.27, presents 1.28, others 3.47), idle 2.33
       nvn: 800000 recordings made, 52844 live copies (19.5 MB), 10568 texture copies; 4 command buffers' segments (4.2 MB)

The switch

HOS_NVN_REC_HANDOFF (new, run time, a kill switch): on by default, as the measurements chose (+4.4 % standing, +4.1 % turning; a gain in every standing pair of the matrix; no memory growth). HOS_NVN_REC_HANDOFF=0 copies every recording, main's path, byte for byte.

Risks

What could break: a handle read after its block was reused would draw garbage or lose the device; a handed-over block is freed by the same rule as a copy (only after the replay passed the submits made before its release). Memory: a handed-over block is at most twice its recording, as a copy's pool block is; the live copies' total did not grow in the runs (18.7 to 20.4 MB with and without). The fresh segment is cold memory, so the next recording's first writes pay the cache misses the copy's writes paid before; the frame rate above includes that.

Turning it off: HOS_NVN_REC_HANDOFF=0 (in the environment or longshot_env.txt): every recording is copied, as on main.

After updating: the hand-off is on; saves, longshot_options.ini and the caches do not change.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened. (tests/test_nvn_rec_handoff.py, new; tests/test_switch_table.py reads the new row.)
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: built and played. Linux: 620f3067 built by the Test Farm's Linux and AMD testers and on a Steam Deck, and run in the Market; 0f94b30c not yet built there.)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary Every time the game finishes recording a batch of drawing commands, Longshot copies that batch once more on the game's own thread before the renderer gets it: about 750,000 recordings in a 75-second run of Castle Town's Market. `docs/cpu-profile.md` lists this copy as candidate 4, at 2.6 % of a core with 1.3 % on the serial threads. This PR hands a large finished recording over as it is and gives the command buffer a fresh segment instead, so that copy is no longer made. It is on by default; `HOS_NVN_REC_HANDOFF=0` copies every recording as before. The goal is less work on the game's threads for the same result. Frame rate is the check that nothing got slower, and where the processor sets the frame it rises: the Market ran 4.4 % faster standing still and 4.1 % faster turning the camera on main a433db32 (three interleaved runs a side), and +4.3 % / +2.2 % as the mean of eight on/off pairs in a 48-run matrix, with no memory growth. How: `rec_begin` starts a recording after room for a copy's prefix; `rec_end` turns a recording that fills at least half of its segment into the handle (the prefix written in its room) and gives the command buffer a fresh segment; anything smaller goes through `flatten` as before. A handed-over block is laid out and freed exactly as a copy (`free_dead_copies`, `release_copies`, the sweep). Why half: copies live until their control memory is added again (about 53,000 live in the Market), and a segment is at least 64 KB, so handing over small recordings would multiply memory; at half full the block is at most twice the recording, the bound the pool's power-of-two classes already give a copy. Since 0f94b30c the `nvn:` line written every 50,000 recordings also says how many of those were handed off (the rest copied) and how many blocks the recording pool took from the heap since the last line, so a log shows how often the hand-off acts on a PC and whether its fresh segments come from the pool. Read first: `host/nvn_native.c` (`rec_handoff_on`, read with `env_on_or(..., 1)`; `rec_begin`, `rec_end`, and their calls in BeginRecording and EndRecording); `tests/test_nvn_rec_handoff.py`; the row in `gpu/vk/switches.def`. See #1504 (the same function on Linux, from the lock side); #1034 touches its write marks. Neither is this change. ## Testing **Tested:** Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X. In the game: this change at its pre-rebase head in a test tree on main a433db32 (`test/perf-prs` @ be5623e0 on my fork, built from scratch twice, 0 failed): 15 hands-free Market runs, 6 with the switch on; in a v3.0.0 test tree, 24 Market runs with it on (15 s standing, 40 s turning each); before that two dozen hands-free runs in the Market and Hyrule Field with the first version on main 544229a2. No `not a live recording`, no `FATAL` and no frame of 50 ms or more in any log. The rebase onto main 068fb8eb (#1802) changed no code: only `docs/development.md`, which #1802 removed, lost the switch's row (its row in `gpu/vk/switches.def` is the reference now). The default went on in 620f3067 (`env_on_or`, the row a `kill` switch, the test run unset and `=0`): the code paths are the ones measured, only which is the default changed. Game-free at this head (620f3067): `tests/test_nvn_rec_handoff.py` (compiles the real pool, `cmd_reserve_rec`, `flatten`, `rec_begin`, `rec_end`; 3,000 recordings of 16 bytes to 1.5 MB in four command buffers, 64 handles kept, on and `=0`: every handle holds its bytes after later recordings and segment growth; on: 106 handed over, 2,894 copied; every block back in the pool; an end without a begin is copied as before; three controls fail it) and `tests/test_switch_table.py` and `tests/test_env_on.py` pass. `tests/run_all.py` on Windows at this head: 708 passed, 47 failed, 116 skipped; main 068fb8eb on this PC: 704 passed, 50 failed, 116 skipped. No failure that main does not have: main's, apart from timing tests that failed in one run only and pass when run alone (`test_invalidate_vcore`, `test_compile_stops_on_exception`, `test_longshot_ctl`, `test_mesh_args_cleanup`); `test_vbytes` times out at 600 s in both. Main's failures on this PC: `test_appimage_player_build`, `test_auto_handheld`, `test_bug_report_defaults`, `test_capture_read_once`, `test_crash_dialog`, `test_crt_options`, `test_damage_debug_menu`, `test_dev_ab`, `test_dev_build`, `test_dev_migrate`, `test_dev_packs`, `test_display_startup_failure`, `test_dlss_feature_size`, `test_failed_compile_keeps_objects`, `test_frame_overlap`, `test_frame_wait_bounds`, `test_game_menu_mouse_buttons`, `test_guest_imported`, `test_high_fps_fixes`, `test_host_guest_writes`, `test_hud_layout_row`, `test_job_queue`, `test_libc_hooks`, `test_lift_cache`, `test_linux_preflight`, `test_linux_pressure`, `test_make_game_ngx`, `test_mise_build`, `test_missing_nup`, `test_mods_list`, `test_ngx_sdk`, `test_pads_after_menu`, `test_pending_guest_import`, `test_pipeline_play_cache`, `test_portable_builder_home`, `test_portable_builder_startup`, `test_prepare_cache_save`, `test_present_thread`, `test_profiling_mode`, `test_psychov35_fsr3_fg`, `test_readback_timeout_source`, `test_sdiv_overflow`, `test_seed_reader`, `test_slow_frames`, `test_song_note_cue`, `test_upscaler_rows`, `test_vcore_escape`, `test_walk_key`. A Steam Deck OLED run by dukenheimer at 620f3067 (comment below; 1280x800, GPU-bound at ~21 fps): standing in the Market, off against on, two pairs: 21.65 to 21.25 fps (-1.8 %), both on runs below both off runs, 1 % low 16.0 to 14.65 fps; not yet explained (see Still to test). 0f94b30c changes only the log line's counters: `tests/test_nvn_rec_handoff.py` passes at it (the counters match its own counts, on and =0), and `host/nvn_native.c` compiles for Windows with the warnings main has. **Still to test:** - Linux, any GPU: the Market for a few minutes, main against this PR; the game's CPU seconds with the frame rate capped at 60 on a PC that holds 60 there, and the frame times uncapped, expecting the same frame rate or better with less CPU time, the picture as on main, and no `not a live recording` in the log (@Beanstalk linux). - Linux on a Steam Deck: standing in the Market, `HOS_NVN_REC_HANDOFF=0` against unset, at 0f94b30c, with the `nvn:` lines' hand-off and heap-block counts from both arms beside the frame times, expecting no frame rate lost on the switch (by hand). - An AMD or Intel GPU, any OS: the same, expecting the same (@Beanstalk amd). - A long play session across areas, cutscenes and the pause menu, and the other replay mode (`RX_VK_ASYNC=0`), expecting no fault and no `not a live recording` (by hand). ## Measurements **Verdict:** less work on the game's threads: large finished recordings are handed over, not copied. Frame rate is the check that nothing got slower, and where the processor sets the frame it rises: the Market +4.4 % standing and +4.1 % turning on main a433db32; no change in memory. Where the renderer sets the frame (Hyrule Field by day) about +1 %. Baseline: one executable on both sides, the test tree `test/perf-prs` @ be5623e0 on my fork (main a433db32 with this PR and its siblings #1781 and #1782 merged, the default hot list, `A64_VECFP=0` so the lifted code is main's). Before is every switch unset, which then ran main's code path (the switch was opt-in when measured; with this PR's default the same two sides are `HOS_NVN_REC_HANDOFF=0` and unset); After sets only this one. Main has since moved four commits to 068fb8eb (#1802 docs, tools and the PR template; #1774 and #1807 the Insert menu's rows; #1792 dev packs): outside comments, docs and the dev tools they change the Insert menu's code (#1774, #1807) and the version string and some log texts (#1802): nothing in `host/nvn_native.c`, and nothing the Market runs each frame but the FPS counter's overlay, which runs alike on both sides. So the numbers hold. Setup: Windows 11 (build 22631), GeForce RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X (12 cores), 128 GB. Child Link at the Market's save point by day; 3840x2160 full screen, frame rate cap Uncapped, no mods; the GPU wait 0.0 to 0.1 ms in every run (the processor sets the frame). Hands-free through `scripts/longshot_ctl.py`: the save loads, 10 s to settle, 15 s standing (the FPS counter's value once a second), then 40 s with the right stick held to one side. Three runs a side, interleaved, the median. | | Before: test/perf-prs @ be5623e0, every switch unset | After, `HOS_NVN_REC_HANDOFF=1`: test/perf-prs @ be5623e0 | Δ | |---|---|---|---| | Market standing, fps (the three runs) | 68.8 (68.9, 68.8, 68.2) | 71.8 (71.8, 72.0, 71.2) | +4.4 % | | Market turning, fps (the three runs) | 63.0 (63.0, 63.5, 62.8) | 65.6 (65.1, 65.9, 65.6) | +4.1 % | With its two siblings on as well, the same runs: 76.0 standing (+10.5 %) and 68.1 turning (+8.1 %). No frame of 50 ms or more, no `FATAL` and no `not a live recording` in any of the 15 logs. ### The 48-run matrix The change was measured beside every combination of #1781, #1782 and main's `RX_VK_CAPTURE_NT`, in one test tree `test/perf-matrix` @ 2c30c326 on my fork (v3.0.0 09cbdd97 with the three changes, every lifted file at -O2 so that the hot list is not a variable, built with `A64_VECFP=0` and on). Sixteen variants, three interleaved runs each, 48 runs in 74 minutes with nobody at the PC. Before and After are the same executable; only this switch differs. | what else was on | Before, unset: standing / turning fps | After, set | Δ standing | Δ turning | |---|---|---|---|---| | nothing | 68.5 / 63.5 | 71.2 / 64.5 | +3.9 % | +1.6 % | | `RX_VK_CAPTURE_NT=1` | 69.7 / 63.7 | 72.0 / 65.5 | +3.3 % | +2.8 % | | `HOS_OBJ_CACHE=16384` | 69.6 / 63.9 | 72.3 / 65.4 | +3.9 % | +2.3 % | | both of those | 70.0 / 63.8 | 73.1 / 65.8 | +4.4 % | +3.1 % | | the float paths | 71.5 / 65.7 | 74.2 / 67.1 | +3.8 % | +2.1 % | | the float paths, `RX_VK_CAPTURE_NT=1` | 71.2 / 65.6 | 75.0 / 67.7 | +5.3 % | +3.2 % | | the float paths, `HOS_OBJ_CACHE=16384` | 72.0 / 66.5 | 75.9 / 66.6 | +5.4 % | +0.2 % | | all three | 72.8 / 66.5 | 76.2 / 68.2 | +4.7 % | +2.6 % | Standing it gained in every pair (+2.3 to +3.9 fps). Peak working set over the eight pairs: 9,944 to 10,030 MB either way. The run file is `docs/tested/2026-11-19-rec-handoff-snaildev99-matrix-h.md`. Offline (not a frame rate): `tests/test_nvn_rec_handoff.py --bench`, a recording written in records of 32 to 256 bytes plus its end, best of 7: 256 KB 72 to 24 microseconds, 1 MB 381 to 98, 2 MB 288 to 196. ``` unset: vk: the render thread (600 presents, 15.70 ms a frame): its jobs 12.82 ms a frame (submits 9.12, presents 1.25, others 2.45), idle 2.88 nvn: 750000 recordings made, 52979 live copies (18.7 MB), 10687 texture copies; 2 command buffers' segments (4.1 MB) set: vk: the render thread (600 presents, 15.35 ms a frame): its jobs 13.02 ms a frame (submits 8.27, presents 1.28, others 3.47), idle 2.33 nvn: 800000 recordings made, 52844 live copies (19.5 MB), 10568 texture copies; 4 command buffers' segments (4.2 MB) ``` ### The switch `HOS_NVN_REC_HANDOFF` (new, run time, a `kill` switch): on by default, as the measurements chose (+4.4 % standing, +4.1 % turning; a gain in every standing pair of the matrix; no memory growth). `HOS_NVN_REC_HANDOFF=0` copies every recording, main's path, byte for byte. ## Risks **What could break:** a handle read after its block was reused would draw garbage or lose the device; a handed-over block is freed by the same rule as a copy (only after the replay passed the submits made before its release). Memory: a handed-over block is at most twice its recording, as a copy's pool block is; the live copies' total did not grow in the runs (18.7 to 20.4 MB with and without). The fresh segment is cold memory, so the next recording's first writes pay the cache misses the copy's writes paid before; the frame rate above includes that. **Turning it off:** `HOS_NVN_REC_HANDOFF=0` (in the environment or `longshot_env.txt`): every recording is copied, as on main. **After updating:** the hand-off is on; saves, `longshot_options.ini` and the caches do not change. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. (`tests/test_nvn_rec_handoff.py`, new; `tests/test_switch_table.py` reads the new row.) - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: built and played. Linux: 620f3067 built by the Test Farm's Linux and AMD testers and on a Steam Deck, and run in the Market; 0f94b30c not yet built there.) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nvnCommandBufferEndRecording copies the recording (BEGIN to END) out of the command buffer's segment
into a pooled block that becomes the handle (flatten). In a timed profile of the Market that copy was
2.8 % of the main thread's samples and 3.6 % in Hyrule Field by day (RTX 3090, Ryzen 9 5900X), and
about as much again on the module workers: docs/cpu-profile.md's candidate 4.

With HOS_NVN_REC_HANDOFF=1 a recording starts after room for a copy's prefix (rec_begin, which marks
the room), and at its end (rec_end) a recording that fills at least half of its segment is handed over:
the prefix is written in front of it, the segment is the handle, and the command buffer takes a fresh
segment of the same size from the pool. A smaller recording, and any end whose segment does not carry
rec_begin's mark, is copied as before. The handed-over block is freed as a copy is, by the pool class in
its prefix. Unset, the recording code is main's.

tests/test_nvn_rec_handoff.py compiles the pool, cmd_reserve_rec, flatten, rec_begin and rec_end from
the source and records 3000 recordings of 16 bytes to 1.5 MB in four command buffers with both settings:
every handle holds its bytes, also after later recordings and a segment that grew; set, half-full
recordings are their segment and the rest are copies; every block returns to the pool and copy_bytes
to 0; an end without a begin is copied as before. Controls (no fresh segment, the mark ignored, the
prefix's byte count off) each fail it. --bench (not a frame rate): a recording and its end, 256 KB
72 -> 24 us, 1 MB 381 -> 98 us, 2 MB 288 -> 196 us on the 5900X.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(tested): the recording hand-off's Market matrix run
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval waiting for a BigBean's 👍 on the request
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
d1f9f73926
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X: 24 hands-free runs in the child Market with HOS_NVN_REC_HANDOFF=1 (15 s standing, then 40 s turning the camera), in a test build of v3.0.0 with this change (test/perf-matrix @ 2c30c326 on my fork). No "not a live recording", no FATAL and no frame of 50 ms or more in any log; +2.3 to +3.9 fps standing in all eight on/off pairs. Not built or played at this head on current main yet: that is why this is WIP.

Tested in game: Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X: 24 hands-free runs in the child Market with HOS_NVN_REC_HANDOFF=1 (15 s standing, then 40 s turning the camera), in a test build of v3.0.0 with this change (test/perf-matrix @ 2c30c326 on my fork). No "not a live recording", no FATAL and no frame of 50 ms or more in any log; +2.3 to +3.9 fps standing in all eight on/off pairs. Not built or played at this head on current main yet: that is why this is WIP.
Member

Possibly related, for context:

  • PR #766 perf(nvn): recording threads wait less on the recordings' copy lock — Earlier optimization in the same NVN recording-copy path; removes lock overhead, not the copy this PR eliminates.
Possibly related, for context: - PR #766 perf(nvn): recording threads wait less on the recordings' copy lock — Earlier optimization in the same NVN recording-copy path; removes lock overhead, not the copy this PR eliminates.
Author
Contributor

Built and played at this head. The test tree is test/perf-prs @ be5623e0 on my fork: main a433db32 with #1780, #1781 and #1782 merged, the default hot list, built from scratch twice (A64_VECFP=0, where the lifted code is main's, and the float paths on). Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X, 3840x2160 uncapped, the child Market: 15 s standing, then 40 s turning the camera; five variants, three interleaved runs each, nobody at the PC, medians.

standing fps (the three runs) turning fps (the three runs) standing turning
nothing on 68.8 (68.9, 68.8, 68.2) 63.0 (63.0, 63.5, 62.8)
HOS_NVN_REC_HANDOFF=1 (#1780) 71.8 (71.8, 72.0, 71.2) 65.6 (65.1, 65.9, 65.6) +4.4 % +4.1 %
HOS_OBJ_CACHE=16384 (#1781) 70.2 (69.5, 70.2, 70.2) 64.6 (63.8, 64.7, 64.6) +2.0 % +2.5 %
the float paths (#1782) 71.2 (70.5, 71.2, 72.3) 66.2 (65.2, 66.2, 66.3) +3.5 % +5.1 %
all three 76.0 (75.9, 76.1, 76.0) 68.1 (68.1, 68.4, 68.0) +10.5 % +8.1 %

No frame of 50 ms or more, no FATAL and no not a live recording in any of the 15 logs; the object cache missed 0.69 % of 22 million lookups.

Build cost of the float paths on a default build (both from scratch, 23 jobs): the lifted files' compiler time 7,374 s to 7,646 s (+3.7 %), the compile's wall time 458 s to 422 s (the slowest hot piece sets it, and it is not slower), lifted objects 679 to 687 MB.

The description has these numbers; the full 16-variant matrix on v3.0.0 is still its first table.

Built and played at this head. The test tree is `test/perf-prs` @ be5623e0 on my fork: main a433db32 with #1780, #1781 and #1782 merged, the default hot list, built from scratch twice (`A64_VECFP=0`, where the lifted code is main's, and the float paths on). Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X, 3840x2160 uncapped, the child Market: 15 s standing, then 40 s turning the camera; five variants, three interleaved runs each, nobody at the PC, medians. | | standing fps (the three runs) | turning fps (the three runs) | standing | turning | |---|---|---|---|---| | nothing on | 68.8 (68.9, 68.8, 68.2) | 63.0 (63.0, 63.5, 62.8) | | | | `HOS_NVN_REC_HANDOFF=1` (#1780) | 71.8 (71.8, 72.0, 71.2) | 65.6 (65.1, 65.9, 65.6) | +4.4 % | +4.1 % | | `HOS_OBJ_CACHE=16384` (#1781) | 70.2 (69.5, 70.2, 70.2) | 64.6 (63.8, 64.7, 64.6) | +2.0 % | +2.5 % | | the float paths (#1782) | 71.2 (70.5, 71.2, 72.3) | 66.2 (65.2, 66.2, 66.3) | +3.5 % | +5.1 % | | all three | 76.0 (75.9, 76.1, 76.0) | 68.1 (68.1, 68.4, 68.0) | +10.5 % | +8.1 % | No frame of 50 ms or more, no `FATAL` and no `not a live recording` in any of the 15 logs; the object cache missed 0.69 % of 22 million lookups. Build cost of the float paths on a default build (both from scratch, 23 jobs): the lifted files' compiler time 7,374 s to 7,646 s (+3.7 %), the compile's wall time 458 s to 422 s (the slowest hot piece sets it, and it is not slower), lifted objects 679 to 687 MB. The description has these numbers; the full 16-variant matrix on v3.0.0 is still its first table.
Author
Contributor

@Beanstalk linux: build this branch and play a few minutes in the Market with HOS_NVN_REC_HANDOFF=1 set, expecting the picture as without it and no "not a live recording" in the log. This is the one box left before ready: the host code has only been built on Windows.

@Beanstalk linux: build this branch and play a few minutes in the Market with HOS_NVN_REC_HANDOFF=1 set, expecting the picture as without it and no "not a live recording" in the log. This is the one box left before ready: the host code has only been built on Windows.
Member

@snaildev99 only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for d1f9f73, and the PR has changed since (b8e3bbb), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@snaildev99 only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `d1f9f73`, and the PR has changed since (`b8e3bbb`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
snaildev99 force-pushed perf/rec-handoff from d1f9f73926
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval waiting for a BigBean's 👍 on the request
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to b8e3bbbe47
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-20 00:48:11 +00:00
Compare
Author
Contributor

Rebased onto main 068fb8eb (b8e3bbbe). #1802 removed docs/development.md, which held this switch's row; its row in gpu/vk/switches.def is the reference now, so that edit is dropped and no code changed. The description now uses the new template, and says plainly what this PR is for: less work on the game's threads (large recordings handed over, not copied), with frame rate as the check that nothing got slower.

Why the numbers still hold on 068fb8eb: they were measured on main a433db32, and the four commits since (#1802 docs, tools and the PR template; #1774 and #1807 the Insert menu's rows; #1792 dev packs): outside comments, docs and the dev tools they change the Insert menu's code (#1774, #1807) and the version string and some log texts (#1802): nothing in host/nvn_native.c, and nothing the Market runs each frame but the FPS counter's overlay, which runs alike on both sides. So the numbers hold.

The farm request is reworded below, to measure the game's CPU time at a frame cap besides the frame times. A ~4 % change is close to what two runs a side can resolve, and the point of the change is less CPU time for the same frames.

Rebased onto main 068fb8eb (b8e3bbbe). #1802 removed `docs/development.md`, which held this switch's row; its row in `gpu/vk/switches.def` is the reference now, so that edit is dropped and no code changed. The description now uses the new template, and says plainly what this PR is for: less work on the game's threads (large recordings handed over, not copied), with frame rate as the check that nothing got slower. Why the numbers still hold on 068fb8eb: they were measured on main a433db32, and the four commits since (#1802 docs, tools and the PR template; #1774 and #1807 the Insert menu's rows; #1792 dev packs): outside comments, docs and the dev tools they change the Insert menu's code (#1774, #1807) and the version string and some log texts (#1802): nothing in `host/nvn_native.c`, and nothing the Market runs each frame but the FPS counter's overlay, which runs alike on both sides. So the numbers hold. The farm request is reworded below, to measure the game's CPU time at a frame cap besides the frame times. A ~4 % change is close to what two runs a side can resolve, and the point of the change is less CPU time for the same frames.
Author
Contributor

@Beanstalk linux, and amd: the Market for a few minutes, HOS_NVN_REC_HANDOFF=1 against unset. Measure the game's CPU seconds with the frame rate capped at 60 (on a PC that holds 60 there), and the frame times uncapped. Expect the same frame rate or better with less CPU time, the picture as without the switch, and no "not a live recording" in the log.

@Beanstalk linux, and amd: the Market for a few minutes, HOS_NVN_REC_HANDOFF=1 against unset. Measure the game's CPU seconds with the frame rate capped at 60 (on a PC that holds 60 there), and the frame times uncapped. Expect the same frame rate or better with less CPU time, the picture as without the switch, and no "not a live recording" in the log.
Member

@snaildev99 only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for b8e3bbb, and the PR has changed since (620f306), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@snaildev99 only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `b8e3bbb`, and the PR has changed since (`620f306`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
snaildev99 changed title from WIP: perf(host): a finished command recording is handed over instead of copied (HOS_NVN_REC_HANDOFF, opt-in) to WIP: perf(host): a finished command recording is handed over instead of copied (HOS_NVN_REC_HANDOFF=0 to copy) 2026-11-20 01:38:55 +00:00
perf(host): the recording hand-off on by default; HOS_NVN_REC_HANDOFF=0 copies every recording as before
Some checks reported errors
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/linux 0/1 pass, 2 error
beanstalk/amd 0/1 pass, 2 error
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
620f306785
The measurements chose on (the Market +4.4 % standing and +4.1 % turning on main
a433db32, a gain in all eight standing pairs of the matrix, no memory growth), and a
switch ships at the value its measurements chose (docs/dev/standards.md, "Switches").
Read with env_on_or(..., 1); the row becomes a kill switch; tests/test_nvn_rec_handoff.py
runs it unset (on) and =0 (off).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

The hand-off is now on by default (620f3067): docs/dev/standards.md says a switch ships at the value its measurements chose, and never off just because it is new or unmeasured, and the measurements here choose on (the Market +4.4 % standing and +4.1 % turning on main a433db32, a gain in every standing pair of the matrix, no memory growth). HOS_NVN_REC_HANDOFF=0 copies every recording, main's path, byte for byte. The switch is read with env_on_or(..., 1), its row is now a kill switch, and tests/test_nvn_rec_handoff.py runs it unset (on) and =0 (off). Only the default changed: both code paths are the ones measured. The Linux and AMD / Intel runs below are now main against this PR.

The hand-off is now on by default (620f3067): docs/dev/standards.md says a switch ships at the value its measurements chose, and never off just because it is new or unmeasured, and the measurements here choose on (the Market +4.4 % standing and +4.1 % turning on main a433db32, a gain in every standing pair of the matrix, no memory growth). `HOS_NVN_REC_HANDOFF=0` copies every recording, main's path, byte for byte. The switch is read with `env_on_or(..., 1)`, its row is now a `kill` switch, and `tests/test_nvn_rec_handoff.py` runs it unset (on) and `=0` (off). Only the default changed: both code paths are the ones measured. The Linux and AMD / Intel runs below are now main against this PR.
Author
Contributor

@Beanstalk linux, and amd: main against this PR in the Market for a few minutes (the hand-off is on by default now). Measure the game's CPU seconds with the frame rate capped at 60 (on a PC that holds 60 there), and the frame times uncapped. Expect the same frame rate or better with less CPU time, the picture as on main, and no "not a live recording" in the log.

@Beanstalk linux, and amd: main against this PR in the Market for a few minutes (the hand-off is on by default now). Measure the game's CPU seconds with the frame rate capped at 60 (on a PC that holds 60 there), and the frame times uncapped. Expect the same frame rate or better with less CPU time, the picture as on main, and no "not a live recording" in the log.
Member

@snaildev99 only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@snaildev99 only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Owner

@Beanstalk

@Beanstalk
Member
Beanstalk test farm · an earlier run: commit 620f306 (the newer results are in a comment below)

Commit 620f306 · tier reviewed · approved by HumanBean · dashboard

What will be tested · AI plan (gpt-6.1-terra)

On Linux and AMD PCs, the plan compares main with the PR in the child Market at capped and uncapped frame rates. Alternating runs take about 22 minutes per target and measure CPU time, memory, frame performance and pictures before and after a camera turn. Crashes, recording errors, substantial CPU or frame-time regressions, or picture differences fail the plan; CPU savings are measured but not required.

  • Where: linux (1-2 reports), amd (1-2 reports).
  • Matrix: 2 cells, each on main and the PR: frame_rate_cap 0 or 6.
  • market: from the repository's save kokiri-start, then teleport to Market, measure standing for 30 s (after 10 s warm-up), take the picture market-standing to compare with main, move the stick, measure after-turn for 30 s (after 5 s warm-up), take the picture market-after-turn to compare with main; 2 runs on each side for each of 2 cells (1 game start a run).
  • Measured: crashes, frame times, stutters and hitches, draws and frame rate, memory and CPU time, the game's log.
  • The PR fails if: CPU time is more than 10% above main; or it crashes; or frame rate is more than 5% below main; or a picture differs from main by more than 5%; or peak memory is more than 10% above main; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0.
  • Time: about 30 min of game runs per tester (4 game starts), plus the two builds.

Done (started 08:12 UTC). Comment @Beanstalk to run it again.

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
linux 0/1 — — — error
amd 0/1 — — — error
Scenario · matrix cell Target Frame p99 (ms) vs main Result
market · frame_rate_cap=0 linux — —
market · frame_rate_cap=0 amd — —
market · frame_rate_cap=6 linux — —
market · frame_rate_cap=6 amd — —
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>620f306</code> (the newer results are in a comment below)</summary> Commit `620f306` · tier **reviewed** · approved by HumanBean · [dashboard](https://beanstalk.magicbean.dev/prs/1780) **What will be tested** · AI plan (`gpt-6.1-terra`) On Linux and AMD PCs, the plan compares main with the PR in the child Market at capped and uncapped frame rates. Alternating runs take about 22 minutes per target and measure CPU time, memory, frame performance and pictures before and after a camera turn. Crashes, recording errors, substantial CPU or frame-time regressions, or picture differences fail the plan; CPU savings are measured but not required. - **Where:** linux (1-2 reports), amd (1-2 reports). - **Matrix:** 2 cells, each on main and the PR: frame_rate_cap `0` or `6`. - **market:** from the repository's save `kokiri-start`, then teleport to Market, measure standing for 30 s (after 10 s warm-up), take the picture market-standing to compare with main, move the stick, measure after-turn for 30 s (after 5 s warm-up), take the picture market-after-turn to compare with main; 2 runs on each side for each of 2 cells (1 game start a run). - **Measured:** crashes, frame times, stutters and hitches, draws and frame rate, memory and CPU time, the game's log. - **The PR fails if:** CPU time is more than 10% above main; or it crashes; or frame rate is more than 5% below main; or a picture differs from main by more than 5%; or peak memory is more than 10% above main; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0. - **Time:** about 30 min of game runs per tester (4 game starts), plus the two builds. Done (started 08:12 UTC). Comment `@Beanstalk` to run it again. | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | linux | 0/1 | — | — | — | error | | amd | 0/1 | — | — | — | error | | Scenario · matrix cell | Target | Frame p99 (ms) vs main | Result | | --- | --- | --- | --- | | market · `frame_rate_cap=0` | linux | — | — | | market · `frame_rate_cap=0` | amd | — | — | | market · `frame_rate_cap=6` | linux | — | — | | market · `frame_rate_cap=6` | amd | — | — | </details>
HumanBean added this to the WIP project 2026-11-20 08:12:02 +00:00
Contributor

Tested #1780 at 620f3067 on main 068fb8eb plus a local stand-in for #1815 in both arms. Steam Deck OLED, 1280×800, fullscreen Game Mode, HDR on, GPU held at peak clocks as main does on Deck.

Standing in the Market, I alternated HOS_NVN_REC_HANDOFF=0 and 1; #1814 and #1810 stayed off. Two pairs, 60 s per run. Medians, off → on:

  • 21.65 → 21.25 fps (−1.8%); both on runs were below both off runs.
  • 1% low: 16.0 → 14.65 fps; p99 frame time: 62.5 → 68 ms.
  • Frames over 50 ms: 14.55% → 17.95%.

I didn't see a standing gain. Two pairs are a first check, not enough to call a regression. There's no hand-off counter: I know the switch was on, not how often a hand-off happened.

Moving, the Field walk was main → all three on (2 pairs): 21.85 → 22.7 fps (+3.9%), 1% low 12.45 → 14.7 fps, p99 80 → 68 ms, and frames over 50 ms 16.3% → 8.55%. There was no moving run with only #1780 on.

Tested #1780 at `620f3067` on main `068fb8eb` plus a local stand-in for #1815 in both arms. Steam Deck OLED, 1280×800, fullscreen Game Mode, HDR on, GPU held at peak clocks as main does on Deck. Standing in the Market, I alternated `HOS_NVN_REC_HANDOFF=0` and `1`; #1814 and #1810 stayed off. Two pairs, 60 s per run. Medians, off → on: - 21.65 → 21.25 fps (−1.8%); both on runs were below both off runs. - 1% low: 16.0 → 14.65 fps; p99 frame time: 62.5 → 68 ms. - Frames over 50 ms: 14.55% → 17.95%. I didn't see a standing gain. Two pairs are a first check, not enough to call a regression. There's no hand-off counter: I know the switch was on, not how often a hand-off happened. Moving, the Field walk was **main → all three on** (2 pairs): 21.85 → 22.7 fps (+3.9%), 1% low 12.45 → 14.7 fps, p99 80 → 68 ms, and frames over 50 ms 16.3% → 8.55%. There was no moving run with only #1780 on.
perf(host): the recordings' log line counts hand-offs and the pool's heap blocks
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 9s
0f94b30ccf
The nvn: line written every 50,000 recordings now also says how many of
those were handed off (and their MB), the rest being copies, and how many
blocks the recording pool had none of and took from the heap since the
last line (and their MB). With the switch on and =0 the two lines show
how often the hand-off happens on a given PC and whether its fresh
segments come from the pool or from the heap (new pages to fault in).
A Steam Deck run asked for it: the switch was on, but how often it
acted was not in the log.

The counters are added only on paths that already do a heap allocation
or replace a whole recording's copy. tests/test_nvn_rec_handoff.py
checks them against its own counts, on and off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member

Beanstalk test farm

Commit 0f94b30 · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `0f94b30` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/1780) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
Author
Contributor

Thanks for running this, and for the careful write-up. At ~21 fps the Deck is GPU-bound, so the hand-off (less CPU work when a recording ends) isn't expected to raise the frame rate there, but it must not cost frames, and your standing pairs lean that way. One way it could cost more on Linux than on the Windows PC it was measured on: a handed-off recording keeps its whole segment, and the command buffer takes a fresh one, from the heap whenever the pool is empty, which on Linux can mean new pages faulted in.

0f94b30c adds the counter you asked for to the nvn: line (written every 50,000 recordings): how many of those were handed off, the rest copied, and how many blocks the recording pool took from the heap since the last line. If you have time, the same standing pairs at 0f94b30c with those lines from both arms would show whether the hand-off acts as often as on Windows and whether it pays in fresh heap blocks.

Thanks for running this, and for the careful write-up. At ~21 fps the Deck is GPU-bound, so the hand-off (less CPU work when a recording ends) isn't expected to raise the frame rate there, but it must not cost frames, and your standing pairs lean that way. One way it could cost more on Linux than on the Windows PC it was measured on: a handed-off recording keeps its whole segment, and the command buffer takes a fresh one, from the heap whenever the pool is empty, which on Linux can mean new pages faulted in. 0f94b30c adds the counter you asked for to the `nvn:` line (written every 50,000 recordings): how many of those were handed off, the rest copied, and how many blocks the recording pool took from the heap since the last line. If you have time, the same standing pairs at 0f94b30c with those lines from both arms would show whether the hand-off acts as often as on Windows and whether it pays in fresh heap blocks.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 9s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/rec-handoff:snaildev99-perf/rec-handoff'
git switch 'snaildev99-perf/rec-handoff'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1780
No description provided.