perf(game): mark unmapped descriptor and event NVN2 pools CPU_NO_ACCESS #2902

Merged
HumanBean merged 1 commit from siantm/Longshot:perf/pc-phase-d-engine-sites into main 2026-12-01 00:39:40 +00:00
Contributor

Summary

Specializes two boot-time NVN2 pool-creation sites on PC (HOS_POOL_FLAGS_SITES, enabled by default) via declarative worker-thread replace hooks in game/sites/:

  1. pool.descFlags (f_80966440 +0x130 mov w1, #0x22): sets CPU_NO_ACCESS | GPU_CACHED (0x21) instead of 0x22 for the unmapped descriptor pool (verified zero nvnMemoryPoolMap/nvnBufferMap callers).
  2. pool.eventFlags (f_80f69040 +0x24c mov w1, #0x12, Site 1 for the 4 KB NVNevent pool; Site 2 +0x3e4 nvnBufferMap is kept untouched via 8-word signature disambiguation): sets CPU_NO_ACCESS | GPU_UNCACHED (0x11).

In KokiriForest_Child (1280x720, 4 interleaved runs), Avg FPS improves from 90.21 (92.48 warm) to 93.59 (+3.7% all / +1.2% warm), 1% Low improves from 35.80 (42.81 warm) to 43.92 (+22.7% / +2.6% warm), 0.1% Low improves from 20.01 (27.31 warm) to 28.92 (+44.5% / +5.9% warm), and memsync_csv_mean drops -6.6% (0.711 -> 0.664 ms) with 0 warnings and 0 left-out CPU R/W. Read first: game/sites/sites.toml, game/sites/e0f3ccfaf50065ae4ea01eb5aeb13b1a45da3348/locations.toml, game/sites.def, game/oot_sites.c, and HOS_POOL_FLAGS_SITES in gpu/vk/switches.def.

Testing

Tested: Windows 11, Intel Core i7-9700 (8C/8T), NVIDIA GeForce RTX 4060 (driver 621.40), built cleanly via cargo test -p sites, dev.py pack, and dev.py rt. Ran 4 interleaved 35 s A/B runs (BASE_1, POOL_1, POOL_2, BASE_2, 3,090–3,296 frames/run, 1280x720, RX_VK_IMMEDIATE=1, RX_VK_FRAME_TRACE=1) plus an earlier 4-run bisect confirming pool.descFlags + pool.eventFlags (POOL_1 95.05 Avg / 45.22 1% Low) outperforms adding hot write-before-flush invalidate replace hooks (93.21 / 42.95 due to Ctx sync overhead) vs warm BASE_2 (92.02 / 42.62), with 0 warnings and CPU reads or writes of one left out: 0. Tests: cargo test -p sites (49 unit + 4 repository tests passed); tests/run_all.py: 2 passed (test_site_chain.py, test_doc_anchors.py), 1 failed pre-existing on origin/main @ 28cb22b9e (test_switch_table.py: upstream LONGSHOT_LAUNCHER_STARTUP in host/launcher_startup.h:9; HOS_POOL_FLAGS_SITES passed).

Still to test:

  • @Beanstalk linux: build on Linux and run cargo test -p sites and python -I -B tests/run_all.py, expecting clean site placement and test_site_chain / test_doc_anchors pass (@Beanstalk linux).
  • @Beanstalk windows: run full CI check suite and smoke-test KokiriForest_Child + save load/event sync, expecting zero NVN event regressions (@Beanstalk windows).

Measurements

Verdict: Improves Avg FPS from 90.21 (92.48 warm) to 93.59 (+3.7% all / +1.2% warm), P50 FPS from 95.71 to 97.23 (+1.6%), 1% Low FPS from 35.80 to 43.92 (+22.7%, P99 21.08 -> 18.39 ms), 0.1% Low FPS from 20.01 to 28.92 (+44.5%), and cuts memsync_csv_mean by -6.6% (0.711 -> 0.664 ms). HOS_POOL_FLAGS_SITES ships enabled (1).

Setup: Windows 11, i7-9700, RTX 4060 (621.40); KokiriForest_Child (kokiri-start), 1280x720 (resolution=0, HOS_RES_SCALE=1.0, quality_preset=6), RX_VK_IMMEDIATE=1, frame_generation=0, HOS_FPS_MAX=1000, HOS_AUDIO=0, RX_VK_FRAME_TRACE=1 (frames.csv), 4 interleaved 35 s runs after 8 s settle toggling HOS_POOL_FLAGS_SITES=0 vs 1.
Baseline: origin/main @ 28cb22b9e (this PR @ df65e1c47 with HOS_POOL_FLAGS_SITES=0).

Before: main eq. (0) @ df65e1c47 After: this PR (1) @ df65e1c47 Δ
Average FPS (BASE 87.93, 92.48 vs POOL 93.35, 93.82) 90.21 93.59 +3.7%
P50 FPS (BASE 94.88, 96.53 vs POOL 97.18, 97.28) 95.71 97.23 +1.6%
1% Low FPS (BASE 28.79, 42.81 vs POOL 41.15, 46.69) 35.80 43.92 +22.7%
0.1% Low FPS (BASE 12.71, 27.31 vs POOL 27.42, 30.42) 20.01 28.92 +44.5%
P99 frame time (ms) 21.08 18.39 -12.8%
memsync_csv_mean (ms) 0.711 0.664 -6.6%

Risks

If the game ever reads back on CPU from either the f_80966440 descriptor pool or f_80f69040 Site 1 ([x22+168] 4 KB NVNevent pool) without going through host NVNevent/nvn_gpu_write, marking them CPU_NO_ACCESS (0x1) would omit write-back diffs. Both hooks are guarded by HOS_POOL_FLAGS_SITES=0 (runtime kill switch restoring original 0x22/0x12), and pool.eventFlags uses an 8-word signature so Site 2 (nvnBufferMap) is never matched. No changes to vk_api.h, saves, or pipeline caches.

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.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • 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.
## Summary Specializes two boot-time NVN2 pool-creation sites on PC (`HOS_POOL_FLAGS_SITES`, enabled by default) via declarative worker-thread `replace` hooks in `game/sites/`: 1. `pool.descFlags` (`f_80966440` `+0x130` `mov w1, #0x22`): sets `CPU_NO_ACCESS | GPU_CACHED` (`0x21`) instead of `0x22` for the unmapped descriptor pool (verified zero `nvnMemoryPoolMap`/`nvnBufferMap` callers). 2. `pool.eventFlags` (`f_80f69040` `+0x24c` `mov w1, #0x12`, Site 1 for the 4 KB `NVNevent` pool; Site 2 `+0x3e4` `nvnBufferMap` is kept untouched via 8-word signature disambiguation): sets `CPU_NO_ACCESS | GPU_UNCACHED` (`0x11`). In `KokiriForest_Child` (`1280x720`, 4 interleaved runs), Avg FPS improves from `90.21` (`92.48` warm) to `93.59` (`+3.7%` all / `+1.2%` warm), 1% Low improves from `35.80` (`42.81` warm) to `43.92` (`+22.7%` / `+2.6%` warm), 0.1% Low improves from `20.01` (`27.31` warm) to `28.92` (`+44.5%` / `+5.9%` warm), and `memsync_csv_mean` drops `-6.6%` (`0.711 -> 0.664 ms`) with `0` warnings and `0` left-out CPU R/W. Read first: `game/sites/sites.toml`, `game/sites/e0f3ccfaf50065ae4ea01eb5aeb13b1a45da3348/locations.toml`, `game/sites.def`, `game/oot_sites.c`, and `HOS_POOL_FLAGS_SITES` in `gpu/vk/switches.def`. ## Testing **Tested:** Windows 11, Intel Core i7-9700 (8C/8T), NVIDIA GeForce RTX 4060 (driver `621.40`), built cleanly via `cargo test -p sites`, `dev.py pack`, and `dev.py rt`. Ran 4 interleaved 35 s A/B runs (`BASE_1`, `POOL_1`, `POOL_2`, `BASE_2`, `3,090–3,296` frames/run, `1280x720`, `RX_VK_IMMEDIATE=1`, `RX_VK_FRAME_TRACE=1`) plus an earlier 4-run bisect confirming `pool.descFlags` + `pool.eventFlags` (`POOL_1` `95.05` Avg / `45.22` 1% Low) outperforms adding hot write-before-flush `invalidate` `replace` hooks (`93.21` / `42.95` due to `Ctx` sync overhead) vs warm `BASE_2` (`92.02` / `42.62`), with `0` warnings and `CPU reads or writes of one left out: 0`. Tests: `cargo test -p sites` (`49` unit + `4` repository tests passed); `tests/run_all.py`: `2 passed` (`test_site_chain.py`, `test_doc_anchors.py`), `1 failed` pre-existing on `origin/main @ 28cb22b9e` (`test_switch_table.py`: upstream `LONGSHOT_LAUNCHER_STARTUP` in `host/launcher_startup.h:9`; `HOS_POOL_FLAGS_SITES` passed). **Still to test:** - `@Beanstalk linux`: build on Linux and run `cargo test -p sites` and `python -I -B tests/run_all.py`, expecting clean site placement and `test_site_chain` / `test_doc_anchors` pass (`@Beanstalk linux`). - `@Beanstalk windows`: run full CI check suite and smoke-test `KokiriForest_Child` + save load/event sync, expecting zero NVN event regressions (`@Beanstalk windows`). ## Measurements **Verdict:** Improves **Avg FPS** from `90.21` (`92.48` warm) to **`93.59`** (`+3.7%` all / `+1.2%` warm), **P50 FPS** from `95.71` to **`97.23`** (`+1.6%`), **1% Low FPS** from `35.80` to **`43.92`** (`+22.7%`, `P99` `21.08 -> 18.39 ms`), **0.1% Low FPS** from `20.01` to **`28.92`** (`+44.5%`), and cuts `memsync_csv_mean` by **`-6.6%`** (`0.711 -> 0.664 ms`). `HOS_POOL_FLAGS_SITES` ships enabled (`1`). Setup: Windows 11, i7-9700, RTX 4060 (`621.40`); `KokiriForest_Child` (`kokiri-start`), `1280x720` (`resolution=0`, `HOS_RES_SCALE=1.0`, `quality_preset=6`), `RX_VK_IMMEDIATE=1`, `frame_generation=0`, `HOS_FPS_MAX=1000`, `HOS_AUDIO=0`, `RX_VK_FRAME_TRACE=1` (`frames.csv`), 4 interleaved 35 s runs after 8 s settle toggling `HOS_POOL_FLAGS_SITES=0` vs `1`. Baseline: `origin/main @ 28cb22b9e` (`this PR @ df65e1c47` with `HOS_POOL_FLAGS_SITES=0`). | | Before: main eq. (`0`) @ df65e1c47 | After: this PR (`1`) @ df65e1c47 | Δ | |---|---|---|---| | Average FPS (`BASE` 87.93, 92.48 vs `POOL` 93.35, 93.82) | 90.21 | 93.59 | +3.7% | | P50 FPS (`BASE` 94.88, 96.53 vs `POOL` 97.18, 97.28) | 95.71 | 97.23 | +1.6% | | 1% Low FPS (`BASE` 28.79, 42.81 vs `POOL` 41.15, 46.69) | 35.80 | 43.92 | +22.7% | | 0.1% Low FPS (`BASE` 12.71, 27.31 vs `POOL` 27.42, 30.42) | 20.01 | 28.92 | +44.5% | | P99 frame time (ms) | 21.08 | 18.39 | -12.8% | | `memsync_csv_mean` (ms) | 0.711 | 0.664 | -6.6% | ## Risks If the game ever reads back on CPU from either the `f_80966440` descriptor pool or `f_80f69040` Site 1 (`[x22+168]` 4 KB `NVNevent` pool) without going through host `NVNevent`/`nvn_gpu_write`, marking them `CPU_NO_ACCESS` (`0x1`) would omit write-back diffs. Both hooks are guarded by `HOS_POOL_FLAGS_SITES=0` (runtime kill switch restoring original `0x22`/`0x12`), and `pool.eventFlags` uses an 8-word signature so Site 2 (`nvnBufferMap`) is never matched. No changes to `vk_api.h`, saves, or pipeline caches. ## 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] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [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.
perf(game): mark unmapped descriptor and event NVN2 pools CPU_NO_ACCESS
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 8s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/linux 0/1 pass, 0 running, 0 queued
beanstalk/windows+nvidia 0/1 pass, 0 running, 0 queued
beanstalk/amd 0/1 pass, 0 running, 0 queued
beanstalk/intel 0/1 pass, 0 running, 0 queued
df65e1c47a
Assisted-by: Antigravity
Author
Contributor

Tested in game: Windows 11, i7-9700, RTX 4060 (621.40), KokiriForest_Child 1280x720: HOS_POOL_FLAGS_SITES=1 improves Avg FPS +3.7% (90.21 -> 93.59, warm 92.48 -> 93.59), 1% Low +22.7% (35.80 -> 43.92), 0.1% Low +44.5% (20.01 -> 28.92), memsync -6.6%, 0 warnings, 0 left-out CPU R/W.

Tested in game: Windows 11, i7-9700, RTX 4060 (621.40), KokiriForest_Child 1280x720: HOS_POOL_FLAGS_SITES=1 improves Avg FPS +3.7% (90.21 -> 93.59, warm 92.48 -> 93.59), 1% Low +22.7% (35.80 -> 43.92), 0.1% Low +44.5% (20.01 -> 28.92), memsync -6.6%, 0 warnings, 0 left-out CPU R/W.
Member

Possibly related, for context:

  • PR #2858 perf(vk): honor NVN2 CPU_NO_ACCESS pool flags and add AVX2 mirror_sync — Overlapping pool-flag optimizations; same author and likely shared flag-hook code
  • issue #1516 Pools made with no CPU access are learned as GPU-only at run time, though their flags say so at creation — Open proposal to use CPU_NO_ACCESS pool flags for GPU-only handling
Possibly related, for context: - PR #2858 perf(vk): honor NVN2 CPU_NO_ACCESS pool flags and add AVX2 mirror_sync — Overlapping pool-flag optimizations; same author and likely shared flag-hook code - issue #1516 Pools made with no CPU access are learned as GPU-only at run time, though their flags say so at creation — Open proposal to use CPU_NO_ACCESS pool flags for GPU-only handling
Owner

@review
@beanstalk

@review @beanstalk
Member

Beanstalk test farm · 🔄 testing (0 of 4 reports so far)

Commit df65e1c · approved by HumanBean (reviewed) · dashboard

⚠️ Note: The farm cannot run the requested unit tests or full CI suite through this plan, or directly measure memsync CSV time, 0.1% lows, or omitted CPU reads and writes.
⚠️ Note: The default-enabled hooks are compared with main; the kill-switch-off configuration is not separately measured.

Done (started 00:31 UTC). Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
linux ⏳ queued 0 of 1 — — —
windows+nvidia ⏳ queued 0 of 1 — — —
amd ⏳ queued 0 of 1 — — —
intel ⏳ queued 0 of 1 — — —
What was tested

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

The farm will compare main and the pull request over three starts per side on Linux and Windows NVIDIA, as well as AMD and Intel GPUs. From the Kokiri save it will measure uncapped frame times in Kokiri Forest and the Market for 35 seconds each, with warm-up and stationary picture comparisons. Crashes, substantial frame-time regressions or picture differences beyond the allowed tolerance fail the pull request; the runs also exercise save loading and scene transitions.

  • Where: linux (1-2 reports), windows+nvidia (1-2 reports), amd (1-2 reports), intel (1-2 reports).
  • pool-flags-gameplay: from the repository's save kokiri-start (settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switches HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0), then teleport to Kokiri Forest, take the picture kokiri to compare with main, measure kokiri for 35 s (after 10 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 35 s (after 10 s warm-up); 3 runs on each side.
  • Measured: crashes, frame times, stutters and hitches, load times.
  • The PR fails if: it crashes; or a picture differs from main by more than 25%; or longest load is more than 20% above main; or median frame time is more than 15% above main; or frame time (p99) is more than 15% above main; or frame time (worst 1%) is more than 15% above main.
  • Time: about 40 min of game runs per tester (6 game starts), plus the two builds.
<!-- beanstalk:sticky --> ### Beanstalk test farm · 🔄 testing (0 of 4 reports so far) Commit `df65e1c` · approved by HumanBean (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2902) ⚠️ **Note:** The farm cannot run the requested unit tests or full CI suite through this plan, or directly measure memsync CSV time, 0.1% lows, or omitted CPU reads and writes. ⚠️ **Note:** The default-enabled hooks are compared with main; the kill-switch-off configuration is not separately measured. Done (started 00:31 UTC). Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `linux` | ⏳ queued | 0 of 1 | — | — | — | | `windows+nvidia` | ⏳ queued | 0 of 1 | — | — | — | | `amd` | ⏳ queued | 0 of 1 | — | — | — | | `intel` | ⏳ queued | 0 of 1 | — | — | — | <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) The farm will compare main and the pull request over three starts per side on Linux and Windows NVIDIA, as well as AMD and Intel GPUs. From the Kokiri save it will measure uncapped frame times in Kokiri Forest and the Market for 35 seconds each, with warm-up and stationary picture comparisons. Crashes, substantial frame-time regressions or picture differences beyond the allowed tolerance fail the pull request; the runs also exercise save loading and scene transitions. - **Where:** linux (1-2 reports), windows+nvidia (1-2 reports), amd (1-2 reports), intel (1-2 reports). - **pool-flags-gameplay:** from the repository's save `kokiri-start` (settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switches `HOS_OUTPUT_RES=1280x720`, `RX_VK_AUTO_TUNE=0`), then teleport to Kokiri Forest, take the picture kokiri to compare with main, measure kokiri for 35 s (after 10 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 35 s (after 10 s warm-up); 3 runs on each side. - **Measured:** crashes, frame times, stutters and hitches, load times. - **The PR fails if:** it crashes; or a picture differs from main by more than 25%; or longest load is more than 20% above main; or median frame time is more than 15% above main; or frame time (p99) is more than 15% above main; or frame time (worst 1%) is more than 15% above main. - **Time:** about 40 min of game runs per tester (6 game starts), plus the two builds. </details>
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The reported performance gain is within the run-to-run spread and has no confirmed mechanism in the host pool tracking path. Recommend approval; not approved on the forge.

The change marks two boot-time pools as CPU-inaccessible, with the aim of reducing synchronization work. It adds two game-specific hooks and a default-on kill switch, but the host still registers both pools for the same tracking regardless of their flags.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1 game/oot_sites.c:781: The claimed FPS and synchronization gain is not separated from run-to-run variation, and the changed flag does not alter pool tracking in the host initialization path. (more on the line) Do: Run longer interleaved comparisons of the actual base and PR at player settings, including a heavy scene, and record the pool-specific synchronization work and RAM/VRAM on affected Tier 1 systems. (@fix does its part first: Instrument pool-specific synchronization work so the run can identify whether these flags change it.)
  • L2 game/oot_sites.c:787: The event pool's CPU access semantics change on every supported platform, but the reported run does not cover the event and save-load paths on the other Tier 1 systems. (more on the line) Do: Run event synchronization and save-load smoke tests on the affected Tier 1 Windows and Linux hardware, including Steam Deck.

@fix can do L1.

Questions (2) (not confirmed from the code; they don't hold the recommendation)

  • What host path uses these pool flags to reduce synchronization work, given that pool registration tracks both flag values identically?
  • game/oot_sites.c:775: Can these two pool-creation sites execute concurrently before either callback has initialized the cached switch?

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven. The reported average FPS ranges overlap: 87.93–92.48 before and 93.35–93.82 after, while the warm comparison is only +1.2%. The 1% low ranges also overlap, and the comparison uses the PR with its switch off rather than a separate base build.

Other systems: Pool initialization and event synchronization run on Windows and Linux and across GPU vendors. Only Windows with an RTX 4060 was reported; Linux, AMD and Steam Deck behavior and event synchronization remain untested. Pool tracking is enabled independently of the changed flags.

Switches: HOS_POOL_FLAGS_SITES is added, default on; 0 restores the original pool flags. Its row is present, but the measurements do not establish that the default benefits all supported systems.

Reviewed: df65e1c47a against 28cb22b9ed: Read the diff, commit, repository rules, PR template, standards, hook documentation, changed callbacks and their pool and event handling paths. The large site tables and switch table were skimmed; the complete changed files were not all read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • Both worker replace sites have engine and outcome declarations.
  • The switch has a table row and its off path restores the original constants.
  • The commit records AI assistance; no renderer API or generated shader files changed.

Testing: Read-only review; no builds or tests were run. CI is still running. The requested Test Farm run could not be submitted: no Test Farm tool was available and the network is closed.

Overlaps and merge order: Unknown; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The reported performance gain is within the run-to-run spread and has no confirmed mechanism in the host pool tracking path. Recommend approval; not approved on the forge. The change marks two boot-time pools as CPU-inaccessible, with the aim of reducing synchronization work. It adds two game-specific hooks and a default-on kill switch, but the host still registers both pools for the same tracking regardless of their flags. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1** `game/oot_sites.c:781`: The claimed FPS and synchronization gain is not separated from run-to-run variation, and the changed flag does not alter pool tracking in the host initialization path. (more on the line) **Do:** Run longer interleaved comparisons of the actual base and PR at player settings, including a heavy scene, and record the pool-specific synchronization work and RAM/VRAM on affected Tier 1 systems. *(`@fix` does its part first: Instrument pool-specific synchronization work so the run can identify whether these flags change it.)* - **L2** `game/oot_sites.c:787`: The event pool's CPU access semantics change on every supported platform, but the reported run does not cover the event and save-load paths on the other Tier 1 systems. (more on the line) **Do:** Run event synchronization and save-load smoke tests on the affected Tier 1 Windows and Linux hardware, including Steam Deck. `@fix` can do L1. **Questions (2)** (not confirmed from the code; they don't hold the recommendation) - What host path uses these pool flags to reduce synchronization work, given that pool registration tracks both flag values identically? - `game/oot_sites.c:775`: Can these two pool-creation sites execute concurrently before either callback has initialized the cached switch? **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The reported average FPS ranges overlap: 87.93–92.48 before and 93.35–93.82 after, while the warm comparison is only +1.2%. The 1% low ranges also overlap, and the comparison uses the PR with its switch off rather than a separate base build. **Other systems:** Pool initialization and event synchronization run on Windows and Linux and across GPU vendors. Only Windows with an RTX 4060 was reported; Linux, AMD and Steam Deck behavior and event synchronization remain untested. Pool tracking is enabled independently of the changed flags. **Switches:** HOS_POOL_FLAGS_SITES is added, default on; 0 restores the original pool flags. Its row is present, but the measurements do not establish that the default benefits all supported systems. **Reviewed:** df65e1c47ade against 28cb22b9ed23: Read the diff, commit, repository rules, PR template, standards, hook documentation, changed callbacks and their pool and event handling paths. The large site tables and switch table were skimmed; the complete changed files were not all read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - Both worker replace sites have engine and outcome declarations. - The switch has a table row and its off path restores the original constants. - The commit records AI assistance; no renderer API or generated shader files changed. **Testing:** Read-only review; no builds or tests were run. CI is still running. The requested Test Farm run could not be submitted: no Test Farm tool was available and the network is closed. **Overlaps and merge order:** Unknown; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -772,0 +778,4 @@
/* pool.descFlags (replace mov w1, #0x22 in f_80966440): unmapped descriptor pool becomes CPU_NO_ACCESS (0x21). */
int hos_site_pool_desc_flags(Ctx *A64_NOESC c) {
c->x[1] = hos_pool_flags_sites_on() ? 0x21ULL : 0x22ULL;
Member

L1 (should fix): The claimed FPS and synchronization gain is not separated from run-to-run variation, and the changed flag does not alter pool tracking in the host initialization path.

When: nvnMemoryPoolInitialize calls hos_gpu_track and rx_nvn_pool_created for these pools regardless of their CPU access flags; the reported before and after 1% low ranges overlap. Players therefore have no demonstrated reduction in the tracking work this change is intended to save.

Do: Run longer interleaved comparisons of the actual base and PR at player settings, including a heavy scene, and record the pool-specific synchronization work and RAM/VRAM on affected Tier 1 systems.

**L1** (should fix): The claimed FPS and synchronization gain is not separated from run-to-run variation, and the changed flag does not alter pool tracking in the host initialization path. *When:* nvnMemoryPoolInitialize calls hos_gpu_track and rx_nvn_pool_created for these pools regardless of their CPU access flags; the reported before and after 1% low ranges overlap. Players therefore have no demonstrated reduction in the tracking work this change is intended to save. **Do:** Run longer interleaved comparisons of the actual base and PR at player settings, including a heavy scene, and record the pool-specific synchronization work and RAM/VRAM on affected Tier 1 systems.
@ -772,0 +784,4 @@
/* pool.eventFlags (replace mov w1, #0x12 in f_80f69040): 4 KB NVNevent pool becomes CPU_NO_ACCESS (0x11). */
int hos_site_pool_event_flags(Ctx *A64_NOESC c) {
c->x[1] = hos_pool_flags_sites_on() ? 0x11ULL : 0x12ULL;
Member

L2 (should fix): The event pool's CPU access semantics change on every supported platform, but the reported run does not cover the event and save-load paths on the other Tier 1 systems.

When: The new flag makes nvnMemoryPoolMap return null for this pool and changes the flags visible to the game; an event or save-load path using those semantics on Linux, AMD or Steam Deck has not been exercised.

Do: Run event synchronization and save-load smoke tests on the affected Tier 1 Windows and Linux hardware, including Steam Deck.

**L2** (should fix): The event pool's CPU access semantics change on every supported platform, but the reported run does not cover the event and save-load paths on the other Tier 1 systems. *When:* The new flag makes nvnMemoryPoolMap return null for this pool and changes the flags visible to the game; an event or save-load path using those semantics on Linux, AMD or Steam Deck has not been exercised. **Do:** Run event synchronization and save-load smoke tests on the affected Tier 1 Windows and Linux hardware, including Steam Deck.
HumanBean deleted branch perf/pc-phase-d-engine-sites 2026-12-01 00:39:40 +00:00
Author
Contributor

Follow-up now that this is merged (19f9da05e, 1 Dec), answering BeanBot's two questions and saying where the testing stands.

Farm: the @beanstalk run HumanBean started on df65e1c never produced a result. The PR was merged about ten minutes later and every job was cancelled (dashboard: 0 of 4 reports). The only measurement is still my own four-run A/B on one PC (i7-9700 / RTX 4060). BeanBot read those numbers correctly: the before and after FPS and 1 % low ranges overlap (average 87.93–92.48 vs 93.35–93.82, warm +1.2 %), so they don't show a gain.

Q1: which host path uses these flags to cut sync work? On main @ b4d56f526 there is no such path in the renderer's tracking. You're right: nvnMemoryPoolInitialize registers every pool the same way whatever its flags (host/nvn_native.c:343, hos_gpu_track(o->gpu, o->size, 1), then rx_nvn_pool_created). Only three places read CPU_NO_ACCESS:

  • nvnMemoryPoolMap returns 0 for such a pool (host/nvn_native.c:398).
  • nvnMemoryPoolInvalidateMappedRange and nvnBufferInvalidateMappedRange skip rx_nvn_invalidate for it (host/nvn_native.c:414 and :562). These skips came with #2899, after this PR was measured.

So when I measured this PR, the flag change alone could not reduce write-watch scans, captures or write-backs. The memsync_csv_mean −6.6 % and the FPS change are run-to-run spread, not an effect of the flags. The tracking and write-back path that would use the flags is #2858 (HOS_POOL_FLAGS / RX_VK_POOL_FLAGS), which is still open. HumanBean's port of that path, measured alone on an RTX 3090 / Linux PC, came out −0.9 %, also within spread (#2886 comment). I should not have reported this PR as a measured speedup, and I'm correcting that here. I'm leaving HOS_POOL_FLAGS_SITES on, as merged. No system has shown it slower, and the flags are correct for these two pools: neither is mapped by the CPU (the descriptor pool has no nvnMemoryPoolMap/nvnBufferMap caller, and the event pool's mapped site 2 keeps its flags). They are groundwork for #2858, not a speedup by themselves.

Q2: can the two sites race on the cached switch? In the C version that merged, yes. hos_pool_flags_sites_on() used a plain static int v = -1 with no synchronization, so two pool-creation threads could both read -1 and both write env_on_or(...). Both would write the same value, so the outcome could not differ, but it was formally a data race. Since #2822 moved the hooks to Rust, the switch is a std::sync::OnceLock<bool> read with get_or_init (game/crates/game-core/src/engine.rs:358-361), so there is no race now. Nothing to change.

Testing before merging (L1, L2): neither has run on any other system. The farm run was cancelled, and I can't test Linux, AMD or Steam Deck here. L2's event and save-load smoke test on other Tier 1 systems still needs the farm or a tester. L1's per-pool sync instrumentation would only show a change once #2858's path is in. Until then there is nothing for these flags to change in the tracking, so I'll measure them as part of #2858 rather than here.

Follow-up now that this is merged (19f9da05e, 1 Dec), answering BeanBot's two questions and saying where the testing stands. **Farm:** the `@beanstalk` run HumanBean started on `df65e1c` never produced a result. The PR was merged about ten minutes later and every job was cancelled ([dashboard](https://beanstalk.magicbean.dev/prs/2902): 0 of 4 reports). The only measurement is still my own four-run A/B on one PC (i7-9700 / RTX 4060). BeanBot read those numbers correctly: the before and after FPS and 1 % low ranges overlap (average 87.93–92.48 vs 93.35–93.82, warm +1.2 %), so they don't show a gain. **Q1: which host path uses these flags to cut sync work?** On `main` @ `b4d56f526` there is no such path in the renderer's tracking. You're right: `nvnMemoryPoolInitialize` registers every pool the same way whatever its flags (`host/nvn_native.c:343`, `hos_gpu_track(o->gpu, o->size, 1)`, then `rx_nvn_pool_created`). Only three places read `CPU_NO_ACCESS`: - `nvnMemoryPoolMap` returns 0 for such a pool (`host/nvn_native.c:398`). - `nvnMemoryPoolInvalidateMappedRange` and `nvnBufferInvalidateMappedRange` skip `rx_nvn_invalidate` for it (`host/nvn_native.c:414` and `:562`). These skips came with #2899, after this PR was measured. So when I measured this PR, the flag change alone could not reduce write-watch scans, captures or write-backs. The `memsync_csv_mean` −6.6 % and the FPS change are run-to-run spread, not an effect of the flags. The tracking and write-back path that would use the flags is #2858 (`HOS_POOL_FLAGS` / `RX_VK_POOL_FLAGS`), which is still open. HumanBean's port of that path, measured alone on an RTX 3090 / Linux PC, came out −0.9 %, also within spread ([#2886 comment](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2886)). I should not have reported this PR as a measured speedup, and I'm correcting that here. I'm leaving `HOS_POOL_FLAGS_SITES` on, as merged. No system has shown it slower, and the flags are correct for these two pools: neither is mapped by the CPU (the descriptor pool has no `nvnMemoryPoolMap`/`nvnBufferMap` caller, and the event pool's mapped site 2 keeps its flags). They are groundwork for #2858, not a speedup by themselves. **Q2: can the two sites race on the cached switch?** In the C version that merged, yes. `hos_pool_flags_sites_on()` used a plain `static int v = -1` with no synchronization, so two pool-creation threads could both read -1 and both write `env_on_or(...)`. Both would write the same value, so the outcome could not differ, but it was formally a data race. Since #2822 moved the hooks to Rust, the switch is a `std::sync::OnceLock<bool>` read with `get_or_init` (`game/crates/game-core/src/engine.rs:358-361`), so there is no race now. Nothing to change. **Testing before merging (L1, L2):** neither has run on any other system. The farm run was cancelled, and I can't test Linux, AMD or Steam Deck here. L2's event and save-load smoke test on other Tier 1 systems still needs the farm or a tester. L1's per-pool sync instrumentation would only show a change once #2858's path is in. Until then there is nothing for these flags to change in the tracking, so I'll measure them as part of #2858 rather than here.
Member

@siantm this PR is closed or unknown to the farm.

@siantm this PR is closed or unknown to the farm.
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 8s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/linux 0/1 pass, 0 running, 0 queued
beanstalk/windows+nvidia 0/1 pass, 0 running, 0 queued
beanstalk/amd 0/1 pass, 0 running, 0 queued
beanstalk/intel 0/1 pass, 0 running, 0 queued
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!2902
No description provided.