WIP: fix(nvn): HOS_NVN_WATCH_TEX reads its switch once, keeps its chains under a lock and walks only the stack the bind runs on #1954

Draft
siantm wants to merge 5 commits from siantm/Longshot:perf/nvn-bind-fields into main
Contributor

Summary

HOS_NVN_WATCH_TEX=<handle hex> (a debugging switch, off by default) logs who binds one texture handle, as the guest
call chains that reach BindTexture(s) (watch_tex in host/nvn_native.c, called before every texture bind). On
main it had these faults, fixed here:

  • the switch was cached in a plain static that threads recording at once raced on, and a value wider than the 32 bits
    compared stayed unread and was read again at every bind. It is now read once under watch_tex_lock at the first
    texture bind; every bind tests it with one inline atomic load (watch_tex_want), the rest is a cold function
    (watch_tex_chains); a value wider than 32 bits turns it off (it could never match);
  • the chains seen were looked up and added without a lock, and once 64 were kept every unseen one was logged at every
    bind. They are looked up and added under the same lock, the lines logged outside it; after 64, one line says new ones
    are no longer logged;
  • the frame walk followed any frame link under 0x8000000000, mapped or not, into the heap, the image or another
    thread's stack, and logged the words there as callers. It now reads only whole 16-byte frames inside the guest stack
    the bind's context runs on, that are mapped, going up it: the recording thread's stack (hos_thread_stack, as
    svcQueryMemory bounds it), or, for a bind on an nn::os fiber, the fiber's own stack (new hos_ctx_stack in
    host/hos_thread.c, through fiber_of_ctx), so a fiber's chains are walked as main walked them;
  • a count out of range (which the bind then stops the game for) was read: the watch reads no handle then.

The record writer this PR started with (bind_handles writing its record field by field, so bind_handles and
RECN/rec() stay as on main) is taken out because its own benchmark showed no difference (1.83 ns a bind on both
sides), and it may come back with a profile share of the bind path that shows one.

How to see it on main: python -I -B tests/test_nvn_watch_tex.py (new) fails there in wide, match and race, and in
zero and other only because main calls getenv twice at its one read (see Testing). In the game, with the switch
set: stray "callers" from the heap or another stack, a fault on an unmapped frame link, every chain past 64 logged at
every bind, and threads recording at once reading the switch at once.

Found in review: BeanBot's 61942,
61943 and
61948; futondestroyer's
62881 and
62882; dyst's
65797 (the fiber's stack).

Read first: watch_tex and watch_tex_chains in host/nvn_native.c; hos_ctx_stack in host/hos_thread.c;
tests/test_nvn_watch_tex.py.

Overlap: #2018 (fix/nvn-bind-array-span @ 555b5160) merges with this PR without a textual conflict in either order
(git merge-tree); proposed order #2018 first, after which this PR's count check in the watch only repeats it. Its
test (tests/test_nvn_bind_span.py) cuts the watch with stubs for hos_self, hos_thread_stack and hos_mem_region;
the watch now calls hos_ctx_stack, so with both in that test needs one stub line more (static void hos_ctx_stack(Ctx *c, uint64_t *a, uint64_t *n) { (void)c; *a = 0, *n = 0; }): on the merge of the two it stops at the
missing declaration, and with that line it passes (fb3-1954-r3-light). Whichever lands second adds it. #2019 and #2020
merge with this head without a conflict. Left for a follow-up: guest_chain, which the other watches use, keeps
main's unbounded walk (one bounded walker for both, dyst's suggestion), and svcQueryMemory still bounds a fiber's
stack query by the thread's stack.

Testing

Tested: Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5; game-free checks only. This has
NOT run in the game on this PC, nor on Linux (Still to test). Rebuilt on main @ 9dd41326 without the record writer:
757053ee test, ed959f67 fix (the watch fixes of 7c5dc91c, 519f5c7e, 0c4ecdf9 and fe1dd999 without the writer),
e10e72d1 hos_ctx_stack, 3704a9b5 fiber test, 2eb5aef9 fiber fix. Each check ran in a hidden console of its own, in
one job of the PC's job queue (fb3-1954-r3-light; run on trees identical to these commits, before a commit message was
reworded):

  • python -I -B tests/test_nvn_watch_tex.py at the head 2eb5aef9, with no --cc (LONGSHOT_MINGW's clang) and
    again with CC set: "PASS: every case (unset, zero, other, wide, match, fiber, race)".
  • The same check at 757053ee (main's watch): fails in zero and other (the variable read twice at the first bind),
    wide (read again at every bind), match (the 33rd handle of a count of 33 read, the unmapped page and the allocation
    above the stack read, every chain past 64 logged) and race ("the switch was read 16 times"); at ed959f67 (the watch
    fixed, no fiber case yet): passes; at 3704a9b5 (the fiber case on the thread-bounded walk): fails in fiber only
    ("600 < 0 < ..." where "600 < d1 < d2 < ..." was expected: the walk stopped at the fiber's link register).
  • tests/test_query_memory_free.py (cuts host/hos_thread.c) at the head: passes.
  • tests/test_nvn_bind_span.py (#2018's) on the merge of this head with 555b5160: stops at "call to undeclared
    function 'hos_ctx_stack'"; with the one stub line above: "PASS: every array bind checks its count and its whole
    span before it reads the array (104 cases)".
  • python -I -B tests/run_all.py --strict --changed origin/main at the head (the checks that read a changed file, 8 at
    once, the Vulkan headers through RX_CPM; build job fb3-mxn-changed): 58 passed, 9 failed, 2 skipped
    (test_posix_thread_priority.py, test_tracy_funcs.py: Linux only). The 9 (test_crash_record, test_dev_packs,
    test_host_guest_writes, test_libc_hooks, test_mods_list, test_profiling_mode, test_slow_frames,
    test_vcore_escape, test_vcore_mask0) fail on main @ 9dd41326 too, run by name from a main worktree in the
    same job, with the same messages; none fails here alone.

Still to test:

  • Windows 11, this PC (i7-9700, RTX 4060 (NVIDIA 610.88)): Castle Town's market, 60 s, this PR and main
    interleaved, no switches set, expecting the same picture and frame times within the runs' spread (the watch's default
    path is one atomic load before a texture bind) (by hand)
  • Windows 11, this PC: the same scene with HOS_NVN_WATCH_TEX set to a handle it binds, expecting its
    nvn: texture ... bound from lines, each chain once (by hand)
  • Linux: build the host and run python3 -I -B tests/test_nvn_watch_tex.py, expecting it to pass (by hand)
  • Linux, NVIDIA and AMD (Mesa RADV), and the Steam Deck: Castle Town's market and Hyrule Field, two minutes each, this
    PR against main, expecting the same frame times as main and the same picture (the Test Farm: play Castle Town's
    market and Hyrule Field on Linux and the Steam Deck, this PR against main, comparing frame times and screenshots)
  • Windows with an AMD GPU (Tier 1): Castle Town's market, two minutes, this PR against main, expecting the same frame
    times as main and the same picture (by hand or on the farm, not run yet)

Measurements

No game measurement yet: the game runs are in Still to test. With the switch off (the default) the change leaves one
relaxed atomic load and a not-taken branch before each BindTexture(s), where main called watch_tex and read its
static; everything else runs only with the switch set. The before-and-after proof is the game-free fixture, run on
this PC (i7-9700, Windows 11, llvm-mingw clang) in fb3-1954-r3-light:

tests/test_nvn_watch_tex.py Before: main @ 9dd41326 (test commit 757053ee) After: this PR @ 2eb5aef9
unset pass pass
zero, other (getenv called once) FAIL (twice at its one read) pass
wide (switch read once, off) FAIL pass
match (count, walk, 64 chains) FAIL pass
fiber (a fiber's own stack walked) FAIL at 3704a9b5 (thread-bounded walk) pass
race (8 threads, read once, one line) FAIL pass

Verdict: every case that failed on main passes here (game-free fixture); no game measurement yet.

Risks

With the switch off nothing but the inline test runs, as above. With it set: the walk now stops at any frame outside
the stack the bind's context runs on (a chain that left the stack, as through a callback on another stack, ends
there), the first new chain after 64 logs one line and later ones none, a value wider than 32 bits turns the watch off,
and hos_ctx_stack looks the context up in the fiber list under its shared lock once per logged bind. The watch's
mapping check (hos_mem_region) is a second guard the fixture does not decide on alone (its stacks are always mapped;
the docstring says so). No switch added: a revert is enough. Players notice nothing (no saves,
longshot_options.ini or caches 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 fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • 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 `HOS_NVN_WATCH_TEX=<handle hex>` (a debugging switch, off by default) logs who binds one texture handle, as the guest call chains that reach `BindTexture(s)` (`watch_tex` in `host/nvn_native.c`, called before every texture bind). On `main` it had these faults, fixed here: - the switch was cached in a plain static that threads recording at once raced on, and a value wider than the 32 bits compared stayed unread and was read again at every bind. It is now read once under `watch_tex_lock` at the first texture bind; every bind tests it with one inline atomic load (`watch_tex_want`), the rest is a cold function (`watch_tex_chains`); a value wider than 32 bits turns it off (it could never match); - the chains seen were looked up and added without a lock, and once 64 were kept every unseen one was logged at every bind. They are looked up and added under the same lock, the lines logged outside it; after 64, one line says new ones are no longer logged; - the frame walk followed any frame link under 0x8000000000, mapped or not, into the heap, the image or another thread's stack, and logged the words there as callers. It now reads only whole 16-byte frames inside the guest stack the bind's context runs on, that are mapped, going up it: the recording thread's stack (`hos_thread_stack`, as `svcQueryMemory` bounds it), or, for a bind on an `nn::os` fiber, the fiber's own stack (new `hos_ctx_stack` in `host/hos_thread.c`, through `fiber_of_ctx`), so a fiber's chains are walked as `main` walked them; - a count out of range (which the bind then stops the game for) was read: the watch reads no handle then. The record writer this PR started with (`bind_handles` writing its record field by field, so `bind_handles` and `RECN`/`rec()` stay as on `main`) is taken out because its own benchmark showed no difference (1.83 ns a bind on both sides), and it may come back with a profile share of the bind path that shows one. How to see it on `main`: `python -I -B tests/test_nvn_watch_tex.py` (new) fails there in wide, match and race, and in zero and other only because `main` calls `getenv` twice at its one read (see Testing). In the game, with the switch set: stray "callers" from the heap or another stack, a fault on an unmapped frame link, every chain past 64 logged at every bind, and threads recording at once reading the switch at once. Found in review: BeanBot's [61942](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61942), [61943](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61943) and [61948](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61948); futondestroyer's [62881](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62881) and [62882](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62882); dyst's [65797](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-65797) (the fiber's stack). Read first: `watch_tex` and `watch_tex_chains` in `host/nvn_native.c`; `hos_ctx_stack` in `host/hos_thread.c`; `tests/test_nvn_watch_tex.py`. Overlap: #2018 (`fix/nvn-bind-array-span` @ 555b5160) merges with this PR without a textual conflict in either order (`git merge-tree`); proposed order #2018 first, after which this PR's count check in the watch only repeats it. Its test (`tests/test_nvn_bind_span.py`) cuts the watch with stubs for `hos_self`, `hos_thread_stack` and `hos_mem_region`; the watch now calls `hos_ctx_stack`, so with both in that test needs one stub line more (`static void hos_ctx_stack(Ctx *c, uint64_t *a, uint64_t *n) { (void)c; *a = 0, *n = 0; }`): on the merge of the two it stops at the missing declaration, and with that line it passes (fb3-1954-r3-light). Whichever lands second adds it. #2019 and #2020 merge with this head without a conflict. Left for a follow-up: `guest_chain`, which the other watches use, keeps `main`'s unbounded walk (one bounded walker for both, dyst's suggestion), and `svcQueryMemory` still bounds a fiber's stack query by the thread's stack. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5; game-free checks only. This has NOT run in the game on this PC, nor on Linux (Still to test). Rebuilt on `main` @ 9dd41326 without the record writer: 757053ee test, ed959f67 fix (the watch fixes of 7c5dc91c, 519f5c7e, 0c4ecdf9 and fe1dd999 without the writer), e10e72d1 `hos_ctx_stack`, 3704a9b5 fiber test, 2eb5aef9 fiber fix. Each check ran in a hidden console of its own, in one job of the PC's job queue (fb3-1954-r3-light; run on trees identical to these commits, before a commit message was reworded): - `python -I -B tests/test_nvn_watch_tex.py` at the head 2eb5aef9, with no `--cc` (`LONGSHOT_MINGW`'s clang) and again with `CC` set: "PASS: every case (unset, zero, other, wide, match, fiber, race)". - The same check at 757053ee (`main`'s watch): fails in zero and other (the variable read twice at the first bind), wide (read again at every bind), match (the 33rd handle of a count of 33 read, the unmapped page and the allocation above the stack read, every chain past 64 logged) and race ("the switch was read 16 times"); at ed959f67 (the watch fixed, no fiber case yet): passes; at 3704a9b5 (the fiber case on the thread-bounded walk): fails in fiber only ("600 < 0 < ..." where "600 < d1 < d2 < ..." was expected: the walk stopped at the fiber's link register). - `tests/test_query_memory_free.py` (cuts `host/hos_thread.c`) at the head: passes. - `tests/test_nvn_bind_span.py` (#2018's) on the merge of this head with 555b5160: stops at "call to undeclared function 'hos_ctx_stack'"; with the one stub line above: "PASS: every array bind checks its count and its whole span before it reads the array (104 cases)". - `python -I -B tests/run_all.py --strict --changed origin/main` at the head (the checks that read a changed file, 8 at once, the Vulkan headers through `RX_CPM`; build job fb3-mxn-changed): 58 passed, 9 failed, 2 skipped (`test_posix_thread_priority.py`, `test_tracy_funcs.py`: Linux only). The 9 (`test_crash_record`, `test_dev_packs`, `test_host_guest_writes`, `test_libc_hooks`, `test_mods_list`, `test_profiling_mode`, `test_slow_frames`, `test_vcore_escape`, `test_vcore_mask0`) fail on `main` @ 9dd41326 too, run by name from a `main` worktree in the same job, with the same messages; none fails here alone. **Still to test:** - Windows 11, this PC (i7-9700, RTX 4060 (NVIDIA 610.88)): Castle Town's market, 60 s, this PR and `main` interleaved, no switches set, expecting the same picture and frame times within the runs' spread (the watch's default path is one atomic load before a texture bind) (by hand) - Windows 11, this PC: the same scene with `HOS_NVN_WATCH_TEX` set to a handle it binds, expecting its `nvn: texture ... bound from` lines, each chain once (by hand) - Linux: build the host and run `python3 -I -B tests/test_nvn_watch_tex.py`, expecting it to pass (by hand) - Linux, NVIDIA and AMD (Mesa RADV), and the Steam Deck: Castle Town's market and Hyrule Field, two minutes each, this PR against `main`, expecting the same frame times as `main` and the same picture (the Test Farm: play Castle Town's market and Hyrule Field on Linux and the Steam Deck, this PR against main, comparing frame times and screenshots) - Windows with an AMD GPU (Tier 1): Castle Town's market, two minutes, this PR against `main`, expecting the same frame times as `main` and the same picture (by hand or on the farm, not run yet) ## Measurements No game measurement yet: the game runs are in Still to test. With the switch off (the default) the change leaves one relaxed atomic load and a not-taken branch before each `BindTexture(s)`, where `main` called `watch_tex` and read its static; everything else runs only with the switch set. The before-and-after proof is the game-free fixture, run on this PC (i7-9700, Windows 11, llvm-mingw clang) in fb3-1954-r3-light: | `tests/test_nvn_watch_tex.py` | Before: main @ 9dd41326 (test commit 757053ee) | After: this PR @ 2eb5aef9 | |---|---|---| | unset | pass | pass | | zero, other (`getenv` called once) | FAIL (twice at its one read) | pass | | wide (switch read once, off) | FAIL | pass | | match (count, walk, 64 chains) | FAIL | pass | | fiber (a fiber's own stack walked) | FAIL at 3704a9b5 (thread-bounded walk) | pass | | race (8 threads, read once, one line) | FAIL | pass | Verdict: every case that failed on `main` passes here (game-free fixture); no game measurement yet. ## Risks With the switch off nothing but the inline test runs, as above. With it set: the walk now stops at any frame outside the stack the bind's context runs on (a chain that left the stack, as through a callback on another stack, ends there), the first new chain after 64 logs one line and later ones none, a value wider than 32 bits turns the watch off, and `hos_ctx_stack` looks the context up in the fiber list under its shared lock once per logged bind. The watch's mapping check (`hos_mem_region`) is a second guard the fixture does not decide on alone (its stacks are always mapped; the docstring says so). No switch added: a revert is enough. Players notice nothing (no saves, `longshot_options.ini` or caches change). ## Checklist ### Ready for review - [x] 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). - [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 fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] 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(nvn): a handle bind's record is written field by field, and HOS_NVN_WATCH_TEX's test is inline
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
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
5aa17e9634
bind_handles (BindTexture(s), BindImage(s), BindSeparate*, their Deferred forms) zeroed its record and then filled it,
through rec()'s memset and a memcpy of a size known only at run time; every byte of the record is one of its fields, so
they are now stored directly, a single handle as one store. watch_tex, called before every texture bind, read its
switch through a call; its test is inline now and the chain walk cold.

tests/test_nvn_bind_handles.py: the records, their sizes and the hardware-size accounting are the bytes the old
bind_handles recorded, for every count 0 to 32 with random fields.

From a7d746ac on exp/x86-asm-sync.

Assisted-by: Claude Code
Member

Possibly related, for context:

  • issue #402 Deck: the frame is CPU-bound in the submission path, not GPU-bound (16 fps at 50% internal, GPU-bound wait 0.4 ms) — renderer submission performance context; not specific to this bind change
Possibly related, for context: - issue #402 Deck: the frame is CPU-bound in the submission path, not GPU-bound (16 fps at 50% internal, GPU-bound wait 0.4 ms) — renderer submission performance context; not specific to this bind change
BeanBot left a comment

Recommendation: Request changes. The rewritten texture watch still races across recording threads, and the new test can pass with broken command-memory accounting. The reported benchmark shows no speedup, and the full path still needs an in-game comparison.

The host writes texture, image and sampler bind records directly and moves texture-watch logging off the usual bind path. This removes redundant initialization but adds a specialized record writer whose layout must stay in sync with the reader. No player benefit has been shown.

Does it help: Unproven. The PR reports 21 interleaved Windows microbenchmark rounds on an i7-9700, comparing 8859673e with 3427c186. The medians were identical at 1.83 ns for one handle and 1.88 ns for four. The harness omitted the real allocator and texture watch. No in-game FPS or frame-time data was supplied.
Other systems: The common Vulkan replay path consumes these records on NVIDIA, AMD and Steam Deck, including synchronous and threaded replay. The current payload fields and submit-time deferred source are preserved by inspection. A recording failure can still affect textures, images and samplers on every backend. The diff leaves queue ordering, descriptor registration, renderer APIs, saves, caches, audio and input untouched.
Switches: HOS_NVN_WATCH_TEX remains a hex-handle developer diagnostic, off by default, with its existing gpu/vk/switches.def row. Off is the right default. The change moves the check into the bind path and keeps lazy initialization. No switches were added or removed.

Reviewed: 5aa17e9634 against 2e1f6c32d3: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the Forgejo PR template, the full two-file diff and commit, and all of tests/test_nvn_bind_handles.py. Read the changed parts of host/nvn_native.c and the relevant bind, allocator, thread, guest-memory, submit and replay code. Skimmed the rest of the host file, test-runner and CI setup, and profiling metadata. Read the run results quoted in the PR. There were no comments, earlier reviews, changed generated files or translations. No separate review checklist or sibling Tooling checkout was present.; nothing run (a code review).
Checked and fine:

  • For counts 0 through 32, the record is 32 plus 8 times the count in bytes, already aligned to eight. The writer sets the explicit pad to zero and preserves the header, source address and handle bytes for valid inputs.
  • The existing allocator and hardware-size formulas are preserved in production. The change adds no allocation, resource ownership or per-thread storage.
  • The patterned buffer will catch a missing pad write or wrong single-handle value. The fixture's compile and execution steps match the described test and require no game data.
  • The focused commit has its Assisted-by trailer. The diff contains no game-derived data, build output, vendor SDKs, generated files or third-party edits. No API version bump is needed.

Blocking (to change before merge)

  1. host/nvn_native.c:2166: The inline read races with the first-bind write. Two workers recording separate buffers can reach their first texture bind together, even with the switch unset. The sentinel check does not serialize initialization, and a parsed UINT64_MAX leaves it stuck at the sentinel. This race also existed on main. Initialize the handle before recorder threads start, or publish it through an atomic fast-path read and a once-only initializer.
  2. host/nvn_native.c:2173: The watch reads the array before bind_handles validates the count, and the array entry points check only its first byte. With the watch enabled, a count of 33 and 32 accessible handles can fault before the intended error. Validate the count and the entire readable span before either the watcher or recorder reads it, and skip the copy for zero handles. A fixed-size memcpy for one handle preserves the old byte-copy behavior for array arguments.
  3. host/nvn_native.c:2176: The cold frame walk still checks only alignment and the reserved guest window. A matching bind with x29 pointing into an unmapped guest page can crash while gathering diagnostics. Check that the whole 16-byte frame is readable in the current guest stack before reading either word, and stop the walk on a bad link.
  4. host/nvn_native.c:2182: The cold path retains an unsynchronized deduplication table. Two recording threads can both log the same new chain or race for the final slot. Once all 64 slots are full, an unseen chain logs on every subsequent match. Protect lookup and insertion together with a cold-path lock, log outside the lock, and define a bounded policy for a full table.
  5. tests/test_nvn_bind_handles.py:65: The allocator stubs never advance cmd_used or hw_used or set last_rec to the current record size. Both sides also call the same hw_fix, so a broken subtraction there still passes, and the fixture never asserts that writing stops at the record boundary. Cut the real allocator with its lower-level dependencies stubbed, assert independent counter deltas and expected record bytes, and check the trailing canary or a following record. Use malloc-backed storage so the fixture models the real segment's alignment and storage type.
  6. tests/test_nvn_bind_handles.py:17: The runner forces gcc, and standalone runs also default to gcc regardless of CC. On a Windows setup with only the documented llvm-mingw Clang, or a Clang-only Linux setup, the test fails to launch the compiler. Keep the explicit --cc override, honor CC, and default to the configured llvm-mingw or an available native C compiler.
  7. tests/test_nvn_bind_handles.py:108: The test never exercises the other changed behavior. Reversing the inline watch condition still passes all 20,000 cases. Add a game-free test that controls HOS_NVN_WATCH_TEX in the child environment and checks unset, matching, nonmatching and repeated binds, including concurrent first use once the initialization is fixed.
  8. tests/test_nvn_bind_handles.py:22: The new brace counter duplicates tests/srccut.py and counts braces in comments and strings. A brace added to a diagnostic comment can truncate the extracted function. Use the shared source cutter as required by the test guide, with an import that works under python -I.

Waiting on the author (a run, a measurement or a decision; no edit does it)

  • The isolated bind benchmark shows no gain and excludes the watch change. On the revised head, compare against its merge base in warmed, interleaved runs in the Market and a heavy area at the same settings. Report bind-path CPU time, average FPS, 1% lows and median and p99 frame times. Drop the performance change if the full path still shows no gain.
  • The PR opened before the required local game run. The supplied evidence covers an earlier Windows fixture and a subset of checks. Record the local game run, native Windows and Linux builds, full head checks and CI, and Tier 1 rendering results on affected setups, including AMD on Windows, which is missing from the test plan. Check that the same scene renders correctly with the watch off and that logging works with it enabled.

Suggestions (the author may take or leave)

  • Keep the record-size calculation tied to the header and handle element types, and assert the eight-byte layout invariant where the new writer skips rounding.
  • host/nvn_native.c:2176: Check that the whole 16-byte frame is readable in the guest stack. An aligned frame pointer in the reserved window can still point at an unmapped page.
  • host/nvn_native.c:2182: Protect the lookup and insertion together. Concurrent matches can duplicate a log or race for a slot, and an unseen chain logs on every match after the table fills.

Testing: Read-only review. The author reports 20,000 passing fixture cases at 7a8eb80c and a changed-file suite with 19 passes, two failures also reported on its base, and one skip. The skip is unnamed. No run was reported at 5aa17e96, and no Linux build, game run or head CI result was supplied.
Overlaps and merge order: The PR names a separate ReportCounter change from the same experiment. No sibling number or ordering dependency was visible in the checkout. The supplied base already includes #1946.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The rewritten texture watch still races across recording threads, and the new test can pass with broken command-memory accounting. The reported benchmark shows no speedup, and the full path still needs an in-game comparison. The host writes texture, image and sampler bind records directly and moves texture-watch logging off the usual bind path. This removes redundant initialization but adds a specialized record writer whose layout must stay in sync with the reader. No player benefit has been shown. **Does it help:** Unproven. The PR reports 21 interleaved Windows microbenchmark rounds on an i7-9700, comparing 8859673e with 3427c186. The medians were identical at 1.83 ns for one handle and 1.88 ns for four. The harness omitted the real allocator and texture watch. No in-game FPS or frame-time data was supplied. **Other systems:** The common Vulkan replay path consumes these records on NVIDIA, AMD and Steam Deck, including synchronous and threaded replay. The current payload fields and submit-time deferred source are preserved by inspection. A recording failure can still affect textures, images and samplers on every backend. The diff leaves queue ordering, descriptor registration, renderer APIs, saves, caches, audio and input untouched. **Switches:** HOS_NVN_WATCH_TEX remains a hex-handle developer diagnostic, off by default, with its existing gpu/vk/switches.def row. Off is the right default. The change moves the check into the bind path and keeps lazy initialization. No switches were added or removed. **Reviewed:** 5aa17e9634d5 against 2e1f6c32d30e: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the Forgejo PR template, the full two-file diff and commit, and all of tests/test_nvn_bind_handles.py. Read the changed parts of host/nvn_native.c and the relevant bind, allocator, thread, guest-memory, submit and replay code. Skimmed the rest of the host file, test-runner and CI setup, and profiling metadata. Read the run results quoted in the PR. There were no comments, earlier reviews, changed generated files or translations. No separate review checklist or sibling Tooling checkout was present.; nothing run (a code review). **Checked and fine:** - For counts 0 through 32, the record is 32 plus 8 times the count in bytes, already aligned to eight. The writer sets the explicit pad to zero and preserves the header, source address and handle bytes for valid inputs. - The existing allocator and hardware-size formulas are preserved in production. The change adds no allocation, resource ownership or per-thread storage. - The patterned buffer will catch a missing pad write or wrong single-handle value. The fixture's compile and execution steps match the described test and require no game data. - The focused commit has its Assisted-by trailer. The diff contains no game-derived data, build output, vendor SDKs, generated files or third-party edits. No API version bump is needed. **Blocking** (to change before merge) 1. host/nvn_native.c:2166: The inline read races with the first-bind write. Two workers recording separate buffers can reach their first texture bind together, even with the switch unset. The sentinel check does not serialize initialization, and a parsed UINT64_MAX leaves it stuck at the sentinel. This race also existed on main. Initialize the handle before recorder threads start, or publish it through an atomic fast-path read and a once-only initializer. 2. host/nvn_native.c:2173: The watch reads the array before bind_handles validates the count, and the array entry points check only its first byte. With the watch enabled, a count of 33 and 32 accessible handles can fault before the intended error. Validate the count and the entire readable span before either the watcher or recorder reads it, and skip the copy for zero handles. A fixed-size memcpy for one handle preserves the old byte-copy behavior for array arguments. 3. host/nvn_native.c:2176: The cold frame walk still checks only alignment and the reserved guest window. A matching bind with x29 pointing into an unmapped guest page can crash while gathering diagnostics. Check that the whole 16-byte frame is readable in the current guest stack before reading either word, and stop the walk on a bad link. 4. host/nvn_native.c:2182: The cold path retains an unsynchronized deduplication table. Two recording threads can both log the same new chain or race for the final slot. Once all 64 slots are full, an unseen chain logs on every subsequent match. Protect lookup and insertion together with a cold-path lock, log outside the lock, and define a bounded policy for a full table. 5. tests/test_nvn_bind_handles.py:65: The allocator stubs never advance cmd_used or hw_used or set last_rec to the current record size. Both sides also call the same hw_fix, so a broken subtraction there still passes, and the fixture never asserts that writing stops at the record boundary. Cut the real allocator with its lower-level dependencies stubbed, assert independent counter deltas and expected record bytes, and check the trailing canary or a following record. Use malloc-backed storage so the fixture models the real segment's alignment and storage type. 6. tests/test_nvn_bind_handles.py:17: The runner forces gcc, and standalone runs also default to gcc regardless of CC. On a Windows setup with only the documented llvm-mingw Clang, or a Clang-only Linux setup, the test fails to launch the compiler. Keep the explicit --cc override, honor CC, and default to the configured llvm-mingw or an available native C compiler. 7. tests/test_nvn_bind_handles.py:108: The test never exercises the other changed behavior. Reversing the inline watch condition still passes all 20,000 cases. Add a game-free test that controls HOS_NVN_WATCH_TEX in the child environment and checks unset, matching, nonmatching and repeated binds, including concurrent first use once the initialization is fixed. 8. tests/test_nvn_bind_handles.py:22: The new brace counter duplicates tests/srccut.py and counts braces in comments and strings. A brace added to a diagnostic comment can truncate the extracted function. Use the shared source cutter as required by the test guide, with an import that works under python -I. **Waiting on the author** (a run, a measurement or a decision; no edit does it) - The isolated bind benchmark shows no gain and excludes the watch change. On the revised head, compare against its merge base in warmed, interleaved runs in the Market and a heavy area at the same settings. Report bind-path CPU time, average FPS, 1% lows and median and p99 frame times. Drop the performance change if the full path still shows no gain. - The PR opened before the required local game run. The supplied evidence covers an earlier Windows fixture and a subset of checks. Record the local game run, native Windows and Linux builds, full head checks and CI, and Tier 1 rendering results on affected setups, including AMD on Windows, which is missing from the test plan. Check that the same scene renders correctly with the watch off and that logging works with it enabled. **Suggestions** (the author may take or leave) - Keep the record-size calculation tied to the header and handle element types, and assert the eight-byte layout invariant where the new writer skips rounding. - `host/nvn_native.c:2176`: Check that the whole 16-byte frame is readable in the guest stack. An aligned frame pointer in the reserved window can still point at an unmapped page. - `host/nvn_native.c:2182`: Protect the lookup and insertion together. Concurrent matches can duplicate a log or race for a slot, and an unseen chain logs on every match after the table fills. **Testing:** Read-only review. The author reports 20,000 passing fixture cases at 7a8eb80c and a changed-file suite with 19 passes, two failures also reported on its base, and one skip. The skip is unnamed. No run was reported at 5aa17e96, and no Linux build, game run or head CI result was supplied. **Overlaps and merge order:** The PR names a separate ReportCounter change from the same experiment. No sibling number or ordering dependency was visible in the checkout. The supplied base already includes #1946. --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -2156,2 +2170,4 @@
if (want == ~0ull)
want = watch_tex_want = getenv("HOS_NVN_WATCH_TEX") ? strtoull(getenv("HOS_NVN_WATCH_TEX"), NULL, 16) : 0;
if (!want) return;
for (int i = 0; i < n; i++) {
Member

Validate the count and full readable handle span before the watch or the recorder reads it. An oversized count can currently make the watch run past the array before the recorder rejects it.

Validate the count and full readable handle span before the watch or the recorder reads it. An oversized count can currently make the watch run past the array before the recorder rejects it.
@ -2141,2 +2141,4 @@
NV(nvnCommandBufferBindUniformBuffersDeferred) { bind_bufs_deferred(c, 0); }
NV(nvnCommandBufferBindStorageBuffersDeferred) { bind_bufs_deferred(c, 1); }
/* (longshot) The record written field by field, pad_ too, with no zeroing first (every byte is one of them) and one
handle stored as one: the memset and memcpy calls of a record of variable size were a third of a BindTexture. The
Member

Please source or remove the one-third figure. The supplied benchmark does not measure the whole BindTexture call.

Please source or remove the one-third figure. The supplied benchmark does not measure the whole BindTexture call.
@ -2156,0 +2163,4 @@
static uint64_t watch_tex_want = ~0ull;
static __attribute__((noinline, cold)) void watch_tex_chains(Ctx *c, const uint64_t *h, int n);
static inline void watch_tex(Ctx *c, const uint64_t *h, int n) {
if (__builtin_expect(watch_tex_want != 0, 0)) watch_tex_chains(c, h, n);
Member

Two recording threads can race with first-use initialization even when the watch is off. Initialize before recording or use an atomic fast-path read and once-only initialization.

Two recording threads can race with first-use initialization even when the watch is off. Initialize before recording or use an atomic fast-path read and once-only initialization.
@ -0,0 +14,4 @@
import tempfile
from pathlib import Path
RUN_ALL_ARGS = ["--cc", "gcc"]
Member

Honor CC and choose an available native compiler by default. Forcing gcc breaks an llvm-mingw-only Windows setup.

Honor CC and choose an available native compiler by default. Forcing gcc breaks an llvm-mingw-only Windows setup.
@ -0,0 +19,4 @@
ROOT = Path(__file__).resolve().parents[1]
def block(text, marker):
Member

Use tests/srccut.py. This counter treats braces in diagnostic strings and comments as C syntax.

Use tests/srccut.py. This counter treats braces in diagnostic strings and comments as C syntax.
@ -0,0 +62,4 @@
static uint8_t blk[2][4096];
static uint32_t asked[2];
/* (the recording's next bytes: cmd_alloc's, rounded to 8 as it does; the new code's block holds a pattern) */
static uint8_t *cmd_alloc(nvn_cmd *o, uint32_t size) { (void)o; asked[0] = (size + 7) & ~7u; memset(blk[0], 0xA5, sizeof blk[0]); return blk[0]; }
Member

The stub skips the real allocator's counter writes, and both sides share hw_fix. Test independent expected counter deltas and check that the writer leaves the bytes beyond the record untouched.

The stub skips the real allocator's counter writes, and both sides share hw_fix. Test independent expected counter deltas and check that the writer leaves the bytes beyond the record untouched.
@ -0,0 +105,4 @@
p.add_argument("--cc", default="gcc")
a = p.parse_args()
nvn = (ROOT / "host" / "nvn_native.c").read_text(encoding="utf-8")
cut = "\n".join(block(nvn, m) for m in ("static void put_hdr(", "static void hw_fix(", "static void bind_handles("))
Member

All cases pass if the inline watch condition is reversed. Exercise unset, matching, nonmatching and repeated binds with the child environment set explicitly.

All cases pass if the inline watch condition is reversed. Exercise unset, matching, nonmatching and repeated binds with the child environment set explicitly.
siantm force-pushed perf/nvn-bind-fields from 5aa17e9634
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
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
to 519f5c7e7d
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
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-21 02:53:51 +00:00
Compare
Author
Contributor

Thank you for the review. Pushed, rebased onto current main @ 6e1521a7 (with #1949): head 519f5c7e (was 5aa17e96). git range-diff shows the PR's own commit unchanged by the rebase; on top of it, 7c5dc91c (the test, first) and 519f5c7e (the fix).

Blocking points of the review:

  1. First-use race of the watch handle (:2166): fixed in 519f5c7e. The inline test reads watch_tex_want as an atomic (relaxed) load; the first bind reads the switch once under watch_tex_lock, re-checking it there, and stores the handle atomically. A value wider than the 32 bits compared (so ffffffffffffffff too, which stayed at the sentinel) now turns the watch off; before, such a handle could never match. Test: 8 threads binding at once for the first time read the switch once and log once; ffffffffffffffff reads it once over 1000 binds.
  2. Count and span before the read (:2173, :1745): the count part is fixed in 519f5c7e: the watch reads nothing when the count is out of 0 to 32 (bind_handles then stops the game, as before); bind_handles copies no handle for a count of 0 and copies one handle with an 8-byte memcpy, so a game array of any alignment is read as before. Test: a count of 33 whose 33rd handle matches logs nothing. The span part is not changed here: the array entry points check only the first byte of P(4) on main too, and this PR does not touch those entry lines (it changes bind_handles and the watch). Checking 8 * count bytes needs every Bind*s entry line changed, which is its own change; I list it for the owner.
  3. Cold frame walk (:2176): the walk is the same as on main, but this PR moved it into watch_tex_chains, so the fix stays in that function: 519f5c7e reads a frame only when all 16 bytes are mapped guest memory (hos_mem_region), and stops at a link that does not go up the stack. Test: a frame linking to an unmapped page in the window, a frame running past the mapped stack (neither is read) and a link to itself (the walk ends).
  4. Dedup table (:2182): likewise from main, inside the moved function, so fixed in 519f5c7e: the lookup and the insertion happen together under watch_tex_lock, and the line is logged outside it. Policy for a full table: after 64 chains, one line says new ones are no longer logged, then nothing more. Test: 64 chains, then new and repeated ones: one more line in total.
  5. Allocator stubs, counters, canary (tests:65): fixed in 7c5dc91c. The check cuts the real cmd_alloc and cmd_reserve_rec and stubs the pool below them with malloc'd blocks filled with a pattern. All 20000 binds go into one recording, which grows. Each record is checked against bytes built from the inputs alone (header, fields, pad_ 0, handles). cmd_used must grow by the record's size, and hw_used and last_rec by the hardware size given (or 16 + 4 per handle), not through hw_fix. The 64 bytes after the record must keep the pattern. The comparison with the old bind_handles stays.
  6. Honor CC (tests:17): fixed in 7c5dc91c, in the order tests/test_fpx_sticky.py uses: --cc, then $CC, then on Windows LONGSHOT_MINGW's clang (which run_all.py sets to the clone's llvm-mingw), then clang, gcc or cc on PATH. It fails, not passes, with no compiler. RUN_ALL_ARGS = ["--cc", "gcc"] is gone, so the runner no longer forces gcc.
  7. The inline watch condition (tests:108): fixed in 7c5dc91c. The check runs the fixture once per case, with HOS_NVN_WATCH_TEX set in the child's environment: unset, 0, beef (a handle no bind names), ffffffffffffffff, 1234 (new chain, repeated bind, the same chain from a four-handle bind, and the variable changed after the first bind, which is not read again) and 8 threads at once. With the condition reversed the switch would never be read, so the unset case (one read expected) and the matching case (lines expected) would fail. That is read from the code; the reversed condition was not run.
  8. Use tests/srccut.py (tests:22): fixed in 7c5dc91c: block and between from tests/srccut.py, imported as the other checks do (the check's folder put on sys.path, so it works under python -I). The brace counter is gone.

Inline :2144 (the one-third figure): removed in 519f5c7e. The micro-benchmark did not time the whole BindTexture. The comment now says only what changed (no memset, no run-time-sized memcpy for one handle).

Suggestions: taken in 519f5c7e. The record's size comes from sizeof(nvn_op_hdr), offsetof(nvn_p_bind_handles, h) and the handle's size, and a _Static_assert holds the 8-byte invariant the writer relies on (no rounding). The frame walk and the dedup suggestions are points 3 and 4.

Checked through the PC's job queue (job fb-1954-2, on this head): tests/test_nvn_bind_handles.py passes at 519f5c7e (every case: records, unset, zero, other, wide, match, race), run with no --cc and again with CC set. At the test commit 7c5dc91c (this PR's code before the fix) it fails in zero, other, wide, match and race, and records and unset pass there. tests/run_all.py --strict --changed origin/main: 19 passed, 2 failed, 1 skipped. The 2 failures (test_dev_packs.py, test_host_guest_writes.py) fail on main @ 6e1521a7 with the same messages. The description's Summary, Tested, Measurements and Risks are updated; nothing has run in the game.

"Does it help": BeanBot reads the PR's numbers right. The micro-benchmark shows no gain (1.83 ns a bind of one handle and 1.88 ns of four, on main and with this change), and nothing has been measured in play. Measurements now says so plainly. The change has no switch; HOS_NVN_WATCH_TEX stays off by default.

Waiting on the author, all pending and in Still to test (none has run): interleaved in-game runs against the merge base in the Market and a heavy area (bind-path CPU time, average fps, 1 % lows, median and p99 frame times), dropping the change if the full path shows no gain; the local game run with the watch off (same picture) and on (its lines); the Windows and Linux builds, the full checks and CI on this head; the Tier 1 runs, Windows AMD included.

Thank you for the review. Pushed, rebased onto current `main` @ 6e1521a7 (with #1949): head 519f5c7e (was 5aa17e96). `git range-diff` shows the PR's own commit unchanged by the rebase; on top of it, 7c5dc91c (the test, first) and 519f5c7e (the fix). Blocking points of the [review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61948): 1. [First-use race of the watch handle](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61942) (`:2166`): fixed in 519f5c7e. The inline test reads `watch_tex_want` as an atomic (relaxed) load; the first bind reads the switch once under `watch_tex_lock`, re-checking it there, and stores the handle atomically. A value wider than the 32 bits compared (so `ffffffffffffffff` too, which stayed at the sentinel) now turns the watch off; before, such a handle could never match. Test: 8 threads binding at once for the first time read the switch once and log once; `ffffffffffffffff` reads it once over 1000 binds. 2. [Count and span before the read](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61943) (`:2173`, `:1745`): the count part is fixed in 519f5c7e: the watch reads nothing when the count is out of 0 to 32 (`bind_handles` then stops the game, as before); `bind_handles` copies no handle for a count of 0 and copies one handle with an 8-byte `memcpy`, so a game array of any alignment is read as before. Test: a count of 33 whose 33rd handle matches logs nothing. The span part is not changed here: the array entry points check only the first byte of `P(4)` on `main` too, and this PR does not touch those entry lines (it changes `bind_handles` and the watch). Checking `8 * count` bytes needs every `Bind*s` entry line changed, which is its own change; I list it for the owner. 3. [Cold frame walk](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61948) (`:2176`): the walk is the same as on `main`, but this PR moved it into `watch_tex_chains`, so the fix stays in that function: 519f5c7e reads a frame only when all 16 bytes are mapped guest memory (`hos_mem_region`), and stops at a link that does not go up the stack. Test: a frame linking to an unmapped page in the window, a frame running past the mapped stack (neither is read) and a link to itself (the walk ends). 4. [Dedup table](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61948) (`:2182`): likewise from `main`, inside the moved function, so fixed in 519f5c7e: the lookup and the insertion happen together under `watch_tex_lock`, and the line is logged outside it. Policy for a full table: after 64 chains, one line says new ones are no longer logged, then nothing more. Test: 64 chains, then new and repeated ones: one more line in total. 5. [Allocator stubs, counters, canary](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61946) (`tests:65`): fixed in 7c5dc91c. The check cuts the real `cmd_alloc` and `cmd_reserve_rec` and stubs the pool below them with malloc'd blocks filled with a pattern. All 20000 binds go into one recording, which grows. Each record is checked against bytes built from the inputs alone (header, fields, `pad_` 0, handles). `cmd_used` must grow by the record's size, and `hw_used` and `last_rec` by the hardware size given (or 16 + 4 per handle), not through `hw_fix`. The 64 bytes after the record must keep the pattern. The comparison with the old `bind_handles` stays. 6. [Honor CC](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61944) (`tests:17`): fixed in 7c5dc91c, in the order `tests/test_fpx_sticky.py` uses: `--cc`, then `$CC`, then on Windows `LONGSHOT_MINGW`'s clang (which `run_all.py` sets to the clone's llvm-mingw), then `clang`, `gcc` or `cc` on PATH. It fails, not passes, with no compiler. `RUN_ALL_ARGS = ["--cc", "gcc"]` is gone, so the runner no longer forces gcc. 7. [The inline watch condition](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61947) (`tests:108`): fixed in 7c5dc91c. The check runs the fixture once per case, with `HOS_NVN_WATCH_TEX` set in the child's environment: unset, `0`, `beef` (a handle no bind names), `ffffffffffffffff`, `1234` (new chain, repeated bind, the same chain from a four-handle bind, and the variable changed after the first bind, which is not read again) and 8 threads at once. With the condition reversed the switch would never be read, so the unset case (one read expected) and the matching case (lines expected) would fail. That is read from the code; the reversed condition was not run. 8. [Use tests/srccut.py](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61945) (`tests:22`): fixed in 7c5dc91c: `block` and `between` from `tests/srccut.py`, imported as the other checks do (the check's folder put on `sys.path`, so it works under `python -I`). The brace counter is gone. [Inline `:2144`](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61941) (the one-third figure): removed in 519f5c7e. The micro-benchmark did not time the whole `BindTexture`. The comment now says only what changed (no `memset`, no run-time-sized `memcpy` for one handle). Suggestions: taken in 519f5c7e. The record's size comes from `sizeof(nvn_op_hdr)`, `offsetof(nvn_p_bind_handles, h)` and the handle's size, and a `_Static_assert` holds the 8-byte invariant the writer relies on (no rounding). The frame walk and the dedup suggestions are points 3 and 4. Checked through the PC's job queue (job fb-1954-2, on this head): `tests/test_nvn_bind_handles.py` passes at 519f5c7e (every case: records, unset, zero, other, wide, match, race), run with no `--cc` and again with `CC` set. At the test commit 7c5dc91c (this PR's code before the fix) it fails in zero, other, wide, match and race, and records and unset pass there. `tests/run_all.py --strict --changed origin/main`: 19 passed, 2 failed, 1 skipped. The 2 failures (`test_dev_packs.py`, `test_host_guest_writes.py`) fail on `main` @ 6e1521a7 with the same messages. The description's Summary, Tested, Measurements and Risks are updated; nothing has run in the game. "Does it help": BeanBot reads the PR's numbers right. The micro-benchmark shows no gain (1.83 ns a bind of one handle and 1.88 ns of four, on `main` and with this change), and nothing has been measured in play. Measurements now says so plainly. The change has no switch; `HOS_NVN_WATCH_TEX` stays off by default. Waiting on the author, all pending and in Still to test (none has run): interleaved in-game runs against the merge base in the Market and a heavy area (bind-path CPU time, average fps, 1 % lows, median and p99 frame times), dropping the change if the full path shows no gain; the local game run with the watch off (same picture) and on (its lines); the Windows and Linux builds, the full checks and CI on this head; the Tier 1 runs, Windows AMD included.
Author
Contributor

@Beanstalk This writes the NVN texture, image and sampler bind records field by field (host/nvn_native.c) instead of building each record and copying it, and the test of the off-by-default HOS_NVN_WATCH_TEX debug watch is inline; the bytes written must be the same. It has not run in the game here with this head yet. Please play Castle Town Market and Hyrule Field, a minute each, with a picture in each compared with main's, on Linux with NVIDIA, on Linux with AMD (RADV), on Windows with an Intel GPU and on the Steam Deck, the PR against main. The pictures must match main's (no wrong or missing textures), no crash; frame time p99 equal to main's or better, within the spread.

@Beanstalk This writes the NVN texture, image and sampler bind records field by field (host/nvn_native.c) instead of building each record and copying it, and the test of the off-by-default HOS_NVN_WATCH_TEX debug watch is inline; the bytes written must be the same. It has not run in the game here with this head yet. Please play Castle Town Market and Hyrule Field, a minute each, with a picture in each compared with main's, on Linux with NVIDIA, on Linux with AMD (RADV), on Windows with an Intel GPU and on the Steam Deck, the PR against main. The pictures must match main's (no wrong or missing textures), no crash; frame time p99 equal to main's or better, within the spread.
Member

@siantm 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 519f5c7, and the PR has changed since (fe1dd99), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm 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 `519f5c7`, and the PR has changed since (`fe1dd99`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
futondestroyer left a comment

Recommendation: Request changes. Bound the diagnostic frame walk to the recording thread’s guest stack and make the concurrency fixture safe when it observes duplicate logs. The performance gain is still unproven.

The rebase includes the renderer build fix. The revised writer preserves the record layout and submit-time deferred handles. The fixture now runs the real allocator, checks independent counter deltas and record bytes, and checks the trailing bytes. The watch now initializes once under a lock, uses an atomic fast-path read and bounds the deduplication table. The missing full-span check in the bind-array wrappers is inherited. Prior review

Blocking

  1. host/nvn_native.c:2191 allows a rising frame link into any mapped guest allocation. hos_mem_region also accepts the image, heap, system objects and other threads’ stacks. The watch can read unrelated words and report them as callers. Bound the full 16-byte frame to the current guest stack using hos_thread_stack, as svcQueryMemory does, and keep the mapped-range check. Model a second mapped allocation in the fixture so it catches an out-of-stack link.
  2. tests/test_nvn_bind_handles.py:137 formats every log into the same last_log array. If deduplication regresses, multiple workers can write it concurrently, causing undefined behavior in the case the fixture should report as a clean failure. Count only in the threaded case or protect the fixture’s buffer with its own lock.

Does it help? Unproven. The earlier 21-round microbenchmark had the same medians on both sides, 1.83 ns for one handle and 1.88 ns for four. After the source fixes, compare warmed and interleaved runs in the Market and a heavy scene against the updated merge base. Include bind-path CPU time, average FPS, 1% lows, median and p99 frame times. If the comparison stays within the spread, the measured result does not justify the record-writer optimization. The diagnostic fixes can be reviewed on their own merits.

Testing. The author reports all seven focused cases passed on Windows at this head. The selected suite reports 19 passes, two failures reproduced on base and one Linux-only skip. Head CI, native Linux build and gameplay remain open. The author’s farm request is awaiting approval and names Linux NVIDIA, Linux RADV, Windows Intel and Steam Deck. Add AMD Windows to the Tier 1 plan. The separate ReportCounter PR has no ordering dependency. Farm request ReportCounter PR

Reviewed 519f5c7e against 6e1521a7. Checked the interdiff, all changes to both files and revision-matched Graphify maps. Read the relevant allocator, bind, submit, replay, memory-map and thread-stack source. Nothing from the PR was run.

**Recommendation: Request changes.** Bound the diagnostic frame walk to the recording thread’s guest stack and make the concurrency fixture safe when it observes duplicate logs. The performance gain is still unproven. The rebase includes the renderer build fix. The revised writer preserves the record layout and submit-time deferred handles. The fixture now runs the real allocator, checks independent counter deltas and record bytes, and checks the trailing bytes. The watch now initializes once under a lock, uses an atomic fast-path read and bounds the deduplication table. The missing full-span check in the bind-array wrappers is inherited. [Prior review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61948) **Blocking** 1. `host/nvn_native.c:2191` allows a rising frame link into any mapped guest allocation. `hos_mem_region` also accepts the image, heap, system objects and other threads’ stacks. The watch can read unrelated words and report them as callers. Bound the full 16-byte frame to the current guest stack using `hos_thread_stack`, as `svcQueryMemory` does, and keep the mapped-range check. Model a second mapped allocation in the fixture so it catches an out-of-stack link. 2. `tests/test_nvn_bind_handles.py:137` formats every log into the same `last_log` array. If deduplication regresses, multiple workers can write it concurrently, causing undefined behavior in the case the fixture should report as a clean failure. Count only in the threaded case or protect the fixture’s buffer with its own lock. **Does it help?** Unproven. The earlier 21-round microbenchmark had the same medians on both sides, 1.83 ns for one handle and 1.88 ns for four. After the source fixes, compare warmed and interleaved runs in the Market and a heavy scene against the updated merge base. Include bind-path CPU time, average FPS, 1% lows, median and p99 frame times. If the comparison stays within the spread, the measured result does not justify the record-writer optimization. The diagnostic fixes can be reviewed on their own merits. **Testing.** The author reports all seven focused cases passed on Windows at this head. The selected suite reports 19 passes, two failures reproduced on base and one Linux-only skip. Head CI, native Linux build and gameplay remain open. The author’s farm request is awaiting approval and names Linux NVIDIA, Linux RADV, Windows Intel and Steam Deck. Add AMD Windows to the Tier 1 plan. The separate ReportCounter PR has no ordering dependency. [Farm request](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62721) [ReportCounter PR](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1955) **Reviewed** `519f5c7e` against `6e1521a7`. Checked the interdiff, all changes to both files and revision-matched Graphify maps. Read the relevant allocator, bind, submit, replay, memory-map and thread-stack source. Nothing from the PR was run.
@ -2158,3 +2189,3 @@
if ((h[i] & 0xFFFFFFFFull) != want) continue;
uint64_t chain[8] = {c->x[30]}, fp = c->x[29];
for (int k = 1; k < 8 && fp && fp < 0x8000000000ull && !(fp & 7); k++) chain[k] = G64(fp + 8), fp = G64(fp);
for (int k = 1; k < 8 && fp && !(fp & 7) && hos_mem_region(fp, 16); k++) { /* (the whole frame mapped) */
Member

A higher frame link can land in another mapped guest allocation. hos_mem_region accepts the heap, image and other threads' stacks too. Keep the mapping check and bound the whole frame to the current guest stack via hos_thread_stack. Add a fixture case with a link into a second mapped allocation.

A higher frame link can land in another mapped guest allocation. hos_mem_region accepts the heap, image and other threads' stacks too. Keep the mapping check and bound the whole frame to the current guest stack via hos_thread_stack. Add a fixture case with a link into a second mapped allocation.
@ -0,0 +134,4 @@
static void hos_log(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsnprintf(last_log, sizeof last_log, fmt, ap);
Member

If deduplication regresses, several workers can write last_log concurrently here. Make the fixture race-free even on failure by counting only in the threaded case or guarding the buffer with a fixture lock.

If deduplication regresses, several workers can write last_log concurrently here. Make the fixture race-free even on failure by counting only in the threaded case or guarding the buffer with a fixture lock.
The watch's fixture now maps a second allocation above the recording thread's stack (the heap, another thread's
stack) and gives the thread's stack through hos_thread_stack: a frame link up into that allocation must end the walk
with nothing read there. Its hos_log formats under a lock of its own, so lines logged from several threads at once
(a deduplication regression) leave last_log whole and the race case fails cleanly.

Assisted-by: Claude Code
fix(nvn): HOS_NVN_WATCH_TEX walks frames only inside the recording thread's guest stack
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 18s
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
fe1dd99925
A rising frame link could reach any mapped guest allocation (the image, the heap, system objects, another thread's
stack), and the watch logged the words there as callers. Each 16-byte frame must now lie inside the current guest
thread's stack (hos_thread_stack, as svcQueryMemory bounds it) and be mapped; on a thread with no guest thread nothing
past the link register is walked.

Assisted-by: Claude Code
Author
Contributor

@Beanstalk This writes the NVN texture, image and sampler bind records field by field (host/nvn_native.c) instead of building each record and copying it, and the test of the off-by-default HOS_NVN_WATCH_TEX debug watch is inline; the bytes written must be the same. It has not run in the game here with this head yet. Please play Castle Town Market and Hyrule Field, a minute each, with a picture in each compared with main's, on Linux with NVIDIA, on Linux with AMD (RADV), on Windows with an Intel GPU and on the Steam Deck, the PR against main. The pictures must match main's (no wrong or missing textures), no crash; frame time p99 equal to main's or better, within the spread.

@Beanstalk This writes the NVN texture, image and sampler bind records field by field (host/nvn_native.c) instead of building each record and copying it, and the test of the off-by-default HOS_NVN_WATCH_TEX debug watch is inline; the bytes written must be the same. It has not run in the game here with this head yet. Please play Castle Town Market and Hyrule Field, a minute each, with a picture in each compared with main's, on Linux with NVIDIA, on Linux with AMD (RADV), on Windows with an Intel GPU and on the Steam Deck, the PR against main. The pictures must match main's (no wrong or missing textures), no crash; frame time p99 equal to main's or better, within the spread.
Member

@siantm 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 fe1dd99, and the PR has changed since (2eb5aef), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm 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 `fe1dd99`, and the PR has changed since (`2eb5aef`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Author
Contributor

@futondestroyer thanks for the second look (62883). Both points are fixed at fe1dd999 (test 0c4ecdf9 first, then the fix fe1dd999; still on main @ 6e1521a7, so no rebase was needed this round):

  • 62881 (frame walk): fe1dd999 now walks a frame only when the whole 16-byte frame lies inside the current guest thread's stack, taken from hos_thread_stack(hos_self(), ...) as svcQueryMemory does, and is also mapped (hos_mem_region is still checked). A link that leaves the stack ends the walk. With no guest thread, nothing past the link register is walked. The fixture (0c4ecdf9) now maps a second allocation above the thread's stack and has a frame whose link points into it. At 0c4ecdf9, with the walk still bounded only by a mapped region, the match case fails: it logged 106 < c1 < c2 < c3 and read the other allocation. At fe1dd999 it logs 106 < c1 and reads nothing there.
  • 62882 (last_log): the fixture's hos_log now formats into last_log under its own SRWLOCK, so lines logged from several workers when dedup regresses can no longer race on the buffer. The race case then fails on its counts.

Run through this PC's job queue (fb-1954-3, Windows 11, llvm-mingw clang 23.1.5): at fe1dd999, tests/test_nvn_bind_handles.py passes all seven cases, both with no --cc and with CC set. run_all.py --strict --changed origin/main gives 19 passed and 2 failed. The two failures are test_dev_packs, test_host_guest_writes, and they also fail on main @ 6e1521a7. I added Windows with an AMD GPU to Still to test. The description's Testing section is updated.

Still pending on my side: the interleaved in-game runs against the merge base (Market and a heavy scene: bind-path CPU time, average fps, 1% lows, median and p99 frame times). If those stay within the spread, I'll say plainly that the record-writer part has no measured gain. Also pending: Linux, Tier 1 and CI at this head.

@futondestroyer thanks for the second look ([62883](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62883)). Both points are fixed at fe1dd999 (test 0c4ecdf9 first, then the fix fe1dd999; still on `main` @ 6e1521a7, so no rebase was needed this round): - [62881](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62881) (frame walk): fe1dd999 now walks a frame only when the whole 16-byte frame lies inside the current guest thread's stack, taken from `hos_thread_stack(hos_self(), ...)` as `svcQueryMemory` does, and is also mapped (`hos_mem_region` is still checked). A link that leaves the stack ends the walk. With no guest thread, nothing past the link register is walked. The fixture (0c4ecdf9) now maps a second allocation above the thread's stack and has a frame whose link points into it. At 0c4ecdf9, with the walk still bounded only by a mapped region, the `match` case fails: it logged `106 < c1 < c2 < c3` and read the other allocation. At fe1dd999 it logs `106 < c1` and reads nothing there. - [62882](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62882) (`last_log`): the fixture's `hos_log` now formats into `last_log` under its own `SRWLOCK`, so lines logged from several workers when dedup regresses can no longer race on the buffer. The race case then fails on its counts. Run through this PC's job queue (fb-1954-3, Windows 11, llvm-mingw clang 23.1.5): at fe1dd999, `tests/test_nvn_bind_handles.py` passes all seven cases, both with no `--cc` and with `CC` set. `run_all.py --strict --changed origin/main` gives 19 passed and 2 failed. The two failures are `test_dev_packs`, `test_host_guest_writes`, and they also fail on `main` @ 6e1521a7. I added Windows with an AMD GPU to Still to test. The description's Testing section is updated. Still pending on my side: the interleaved in-game runs against the merge base (Market and a heavy scene: bind-path CPU time, average fps, 1% lows, median and p99 frame times). If those stay within the spread, I'll say plainly that the record-writer part has no measured gain. Also pending: Linux, Tier 1 and CI at this head.
Author
Contributor

On BeanBot's point 2, count and span before the read and the inherited span check named in your review: the span part is now its own fix, #2018 (fix/nvn-bind-array-span, test 405eb181, fix cfd24dda, on main @ 40bfceb0). Every Bind*s entry point checks the count (0 to 32) and then all 8 x count bytes of the game's array in the guest window before the watch or the record reads it, and BindVertexBuffers checks its 16-byte ranges whole. tests/test_nvn_bind_span.py runs the real entry points over a guest window followed by no-access pages: on main 13 of its cases read past the window's end and fault before any stop, with the fix all 55 pass (this PC's job queue, fb3-sep-2). It and this PR merge without a conflict in either order; not run in the game yet.

On [BeanBot's point 2, count and span before the read](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-61943) and the inherited span check named in [your review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62883): the span part is now its own fix, #2018 (`fix/nvn-bind-array-span`, test 405eb181, fix cfd24dda, on `main` @ 40bfceb0). Every `Bind*s` entry point checks the count (0 to 32) and then all 8 x count bytes of the game's array in the guest window before the watch or the record reads it, and `BindVertexBuffers` checks its 16-byte ranges whole. `tests/test_nvn_bind_span.py` runs the real entry points over a guest window followed by no-access pages: on `main` 13 of its cases read past the window's end and fault before any stop, with the fix all 55 pass (this PC's job queue, fb3-sep-2). It and this PR merge without a conflict in either order; not run in the game yet.
Author
Contributor

Description: Risks names #2018 (the Bind*s whole-array check) and the proposed landing order; no code change.

Description: Risks names #2018 (the Bind*s whole-array check) and the proposed landing order; no code change.
futondestroyer left a comment

Recommendation: Wait for gameplay measurements and the remaining WIP checks. The two findings in my previous review are resolved at fe1dd999. The watch checks that each 16-byte frame is inside the recording thread’s mapped guest stack before reading it. The fixture exercises a link into a second mapped allocation and serializes its log writes when several workers log concurrently. Previous review

Does it help? Unproven. The earlier 21-round microbenchmark reported the same medians on both sides: 1.83 ns for one handle and 1.88 ns for four. For the performance change, compare warmed, interleaved runs with the watch off in the Market and a demanding scene. Include bind-path CPU time, average FPS, 1% lows, and median and p99 frame times. If the results overlap, keep the diagnostic fixes independently of the record-writer optimization.

Testing. The author reports seven focused Windows cases passing at this head and the new mapped-allocation case failing before its fix. The selected suite reported 19 passes, two failures reproduced on the base, and one Linux-only skip. Local gameplay with the watch off and on, the Linux build, substantive CI and Tier 1 coverage remain open. The existing farm request is pinned to this pair and can check visual parity, crashes and p99 regressions. AMD Windows and repeated gameplay measurements remain separate. Current farm request

Reviewed fe1dd999 against 6e1521a7 with the exact revision maps, both changed files and the relevant allocator, replay, memory and thread-stack source. The command layout and submit-time deferred handles are preserved by inspection. HOS_NVN_WATCH_TEX stays off by default. The inherited wrapper span check is tracked separately in the author’s proposed first landing. Bind-array span fix

**Recommendation: Wait for gameplay measurements and the remaining WIP checks.** The two findings in my previous review are resolved at `fe1dd999`. The watch checks that each 16-byte frame is inside the recording thread’s mapped guest stack before reading it. The fixture exercises a link into a second mapped allocation and serializes its log writes when several workers log concurrently. [Previous review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-62883) **Does it help?** Unproven. The earlier 21-round microbenchmark reported the same medians on both sides: 1.83 ns for one handle and 1.88 ns for four. For the performance change, compare warmed, interleaved runs with the watch off in the Market and a demanding scene. Include bind-path CPU time, average FPS, 1% lows, and median and p99 frame times. If the results overlap, keep the diagnostic fixes independently of the record-writer optimization. **Testing.** The author reports seven focused Windows cases passing at this head and the new mapped-allocation case failing before its fix. The selected suite reported 19 passes, two failures reproduced on the base, and one Linux-only skip. Local gameplay with the watch off and on, the Linux build, substantive CI and Tier 1 coverage remain open. The existing farm request is pinned to this pair and can check visual parity, crashes and p99 regressions. AMD Windows and repeated gameplay measurements remain separate. [Current farm request](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-63024) **Reviewed** `fe1dd999` against `6e1521a7` with the exact revision maps, both changed files and the relevant allocator, replay, memory and thread-stack source. The command layout and submit-time deferred handles are preserved by inspection. `HOS_NVN_WATCH_TEX` stays off by default. The inherited wrapper span check is tracked separately in the author’s proposed first landing. [Bind-array span fix](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2018)
Author
Contributor

@futondestroyer, on your review: no code change this round; the head stays fe1dd999. None of the following has run yet:

  • Warmed, interleaved runs with the watch off against main @ 6e1521a7 in the Market and in Hyrule Field (average fps, 1 % lows, median and p99 frame times). They are queued on this PC behind its pack builds. Bind-path CPU time is asked for with them.
  • The local runs with the watch on, the Linux build, CI, Tier 1 and Windows AMD.

If the record writer's comparison overlaps, I will say so plainly in Measurements, and whether to keep the diagnostic fixes apart from it then becomes a question for this PR's scope.

@futondestroyer, on [your review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-65466): no code change this round; the head stays fe1dd999. None of the following has run yet: - Warmed, interleaved runs with the watch off against `main` @ 6e1521a7 in the Market and in Hyrule Field (average fps, 1 % lows, median and p99 frame times). They are queued on this PC behind its pack builds. Bind-path CPU time is asked for with them. - The local runs with the watch on, the Linux build, CI, Tier 1 and Windows AMD. If the record writer's comparison overlaps, I will say so plainly in Measurements, and whether to keep the diagnostic fixes apart from it then becomes a question for this PR's scope.
dyst left a comment

Verdict: Request changes. The HOS_NVN_WATCH_TEX fixes are right and well tested, and every BeanBot and futondestroyer point is fixed in the code. But the half the title is for, the field-by-field record writer, is a perf change whose own benchmark shows no gain (1.83 ns and 1.88 ns on both sides). The farm run as requested cannot show a gain of a few nanoseconds a bind, and "no measured gain, no merge" (docs/dev/standards.md, Performance and build changes) holds it.

For a player nothing changes: the recorded bytes are the same, and the watch is a debugging switch that stays off. What is better is the off-by-default diagnostic: no first-use race, no fault on a bad frame link, no stray caller words, and a bounded dedup table. The record writer adds a second, hand-kept copy of rec()'s job for one record type, with nothing measured to pay for it.

Reviewed: fe1dd999 against 6e1521a7 (its merge base with main; no merge commits on the branch): host/nvn_native.c's change read in full, with what it relies on (rec/RECN, cmd_alloc, cmd_reserve_rec, put_hdr, hw_fix, nvn_p_bind_handles and nvn_op_hdr in gpu/render/rx_nvn.h, the Bind* entry points, hos_thread_stack, hos_self, hos_mem_region and its lock, query_memory, the fiber code in host/hos_thread.c, host/posix/windows.h's SRWLOCK). tests/test_nvn_bind_handles.py read in full. Both of futondestroyer's reviews and BeanBot's were checked against the code. The head merges into current main (9dd41326) with no textual conflict (git merge-tree). Nothing run (a code review).
Fixed in this review: nothing.
Checked and fine:

  • The record is byte-for-byte what RECN + rec() wrote. The header (8) plus stage, first, n, pad_ (4 × int32) plus src (8) makes 32 bytes with no implicit padding, then 8 bytes a handle. That is a multiple of 8, so cmd_alloc's rounding changes nothing and the header's size equals the allocation. The _Static_assert pins that. pad_ is written, so no byte is left as the pattern. cmd_alloc's put_hdr(p, 0, size) is overwritten as before.
  • n == 0 copies nothing. n == 1 is a fixed 8-byte memcpy, still unaligned-safe for a guest array.
  • The switch is read once under watch_tex_lock, with a double-check. The fast path is a relaxed atomic load of a scalar, which is enough. A value over 32 bits turns the watch off, as Risks says. switches.def's row (diag, off) still holds, and no new switch is added.
  • Dedup lookup and insert happen together under the lock, and the lines are logged outside it. There is no lock held across hos_mem_region (which takes hos_mem's lock) or hos_log, so there is no lock-order issue.
  • The frame walk is bounded to [stk, stk + stk_n - 16] with no overflow (it checks stk_n >= 16 first). It stops on a non-rising link, and it walks nothing with no guest thread. This answers futondestroyer's 62881.
  • The test would catch the fixes being undone. An unwritten pad_ shows as the 0xA5 pattern. Counter deltas come from the model, not from hw_fix. Removing the next <= fp break fails case 104. Bounding by any mapped region fails case 106 (shown at 0c4ecdf9). Racing first use fails race, and the fixture's last_log is now under its own lock (62882). It honours --cc/$CC/LONGSHOT_MINGW and uses srccut.
  • On Linux, the SRWLOCK calls map to the pthread rwlock shim, as elsewhere in the file.

Blocking (to change before merge)

  1. host/nvn_native.c:2146 (the record writer): this is a perf change with no measured gain. The PR's own 21-round micro-benchmark has identical medians on both sides. The requested farm run (a minute a scene, p99 "within the spread") can only show "no regression", never a gain this size. Two ways forward:

    • Show the number the change targets moving outside the spread on the same scene, main against this PR: bind_handles' or the Bind* entries' CPU share in a profile of the Market, or a harness that records through the real cmd_alloc. A bump allocator can hide the memset.
    • Or drop the writer (keep RECN), retitle as fix(nvn): HOS_NVN_WATCH_TEX ..., and land the watch fixes on their own merits. #2018 already defers its watch points (races, frame walk) to them.

    Also note #2050 makes rec() always-inline and drops cmd_alloc's header write. What is left for a specialised writer here is smaller still.

Suggestions (the author may take or leave)

  • host/nvn_native.c:2193: on an nn::os fiber, c->x[29] points into the fiber's own stack (game memory, HosFiber.stack/size). hos_thread_stack(hos_self()) still gives the thread's stack, so the walk now ends at the LR. main walked those frames. If the game records any commands on a fiber, the watch loses its callers there. A small hos_ctx_stack(Ctx *, &addr, &size) in hos_thread.c (via fiber_of_ctx) would bound the walk to the stack actually in use. svcQueryMemory and GetCurrentStackInfo share the same gap.
  • guest_chain (line 1711, used by the other watches) keeps the unbounded walk this PR fixes for the texture watch. One bounded walker used by both would fix them all; that can be a follow-up.
  • The _Static_assert checks that the size is a multiple of 8, but not that the struct has no hidden padding. An offsetof(nvn_p_bind_handles, src) == 16 && offsetof(nvn_p_bind_handles, h) == 24 would pin the "every byte is a field" claim the writer relies on.
  • No case checks the hos_mem_region half of the walk's condition: the fixture's stack is always mapped, so removing it passes. That's fine as a belt-and-braces check, but the docstring could say so.

Testing: the author ran the focused check on Windows (all seven cases pass at fe1dd999; match fails at 0c4ecdf9 as it should), plus run_all --changed (19 pass, the 2 failures also fail on main). Not done yet: an in-game run, a Linux build, CI at this head, Tier 1, Windows AMD. The farm request 63024 is for this head and would cover picture parity, crashes and the Linux build. It is not the measurement blocking point 1 needs.
Overlaps and merge order:

  • #2018 merges cleanly with this head (checked), and its test already stubs hos_thread_stack/hos_mem_region. 2018 first, as proposed, is fine.
  • #2050 has no textual conflict, but a semantic one. It renames static void cmd_reserve_rec( / static uint8_t *cmd_alloc( to static inline ... and adds cmd_grow. That breaks this PR's block(...) cuts, and 2018's too. Whichever lands second updates the other's test.
  • #2023 touches the watches next to guest_chain but not this code. The other siblings (2026, 2025, 2022, 1995, 1994, 1968, 1955) touch other parts of the file.
**Verdict: Request changes.** The `HOS_NVN_WATCH_TEX` fixes are right and well tested, and every BeanBot and futondestroyer point is fixed in the code. But the half the title is for, the field-by-field record writer, is a perf change whose own benchmark shows no gain (1.83 ns and 1.88 ns on both sides). The farm run as requested cannot show a gain of a few nanoseconds a bind, and "no measured gain, no merge" (docs/dev/standards.md, Performance and build changes) holds it. For a player nothing changes: the recorded bytes are the same, and the watch is a debugging switch that stays off. What is better is the off-by-default diagnostic: no first-use race, no fault on a bad frame link, no stray caller words, and a bounded dedup table. The record writer adds a second, hand-kept copy of `rec()`'s job for one record type, with nothing measured to pay for it. **Reviewed:** fe1dd999 against 6e1521a7 (its merge base with `main`; no merge commits on the branch): `host/nvn_native.c`'s change read in full, with what it relies on (`rec`/`RECN`, `cmd_alloc`, `cmd_reserve_rec`, `put_hdr`, `hw_fix`, `nvn_p_bind_handles` and `nvn_op_hdr` in `gpu/render/rx_nvn.h`, the `Bind*` entry points, `hos_thread_stack`, `hos_self`, `hos_mem_region` and its lock, `query_memory`, the fiber code in `host/hos_thread.c`, `host/posix/windows.h`'s SRWLOCK). `tests/test_nvn_bind_handles.py` read in full. Both of futondestroyer's reviews and BeanBot's were checked against the code. The head merges into current `main` (9dd41326) with no textual conflict (`git merge-tree`). Nothing run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - The record is byte-for-byte what `RECN` + `rec()` wrote. The header (8) plus `stage, first, n, pad_` (4 × int32) plus `src` (8) makes 32 bytes with no implicit padding, then 8 bytes a handle. That is a multiple of 8, so `cmd_alloc`'s rounding changes nothing and the header's size equals the allocation. The `_Static_assert` pins that. `pad_` is written, so no byte is left as the pattern. `cmd_alloc`'s `put_hdr(p, 0, size)` is overwritten as before. - `n == 0` copies nothing. `n == 1` is a fixed 8-byte `memcpy`, still unaligned-safe for a guest array. - The switch is read once under `watch_tex_lock`, with a double-check. The fast path is a relaxed atomic load of a scalar, which is enough. A value over 32 bits turns the watch off, as Risks says. `switches.def`'s row (`diag`, off) still holds, and no new switch is added. - Dedup lookup and insert happen together under the lock, and the lines are logged outside it. There is no lock held across `hos_mem_region` (which takes hos_mem's lock) or `hos_log`, so there is no lock-order issue. - The frame walk is bounded to `[stk, stk + stk_n - 16]` with no overflow (it checks `stk_n >= 16` first). It stops on a non-rising link, and it walks nothing with no guest thread. This answers futondestroyer's 62881. - The test would catch the fixes being undone. An unwritten `pad_` shows as the 0xA5 pattern. Counter deltas come from the model, not from `hw_fix`. Removing the `next <= fp` break fails case 104. Bounding by any mapped region fails case 106 (shown at 0c4ecdf9). Racing first use fails `race`, and the fixture's `last_log` is now under its own lock (62882). It honours `--cc`/`$CC`/`LONGSHOT_MINGW` and uses `srccut`. - On Linux, the SRWLOCK calls map to the pthread rwlock shim, as elsewhere in the file. **Blocking** (to change before merge) 1. `host/nvn_native.c:2146` (the record writer): this is a `perf` change with no measured gain. The PR's own 21-round micro-benchmark has identical medians on both sides. The requested farm run (a minute a scene, p99 "within the spread") can only show "no regression", never a gain this size. Two ways forward: - Show the number the change targets moving outside the spread on the same scene, `main` against this PR: `bind_handles`' or the `Bind*` entries' CPU share in a profile of the Market, or a harness that records through the real `cmd_alloc`. A bump allocator can hide the memset. - Or drop the writer (keep `RECN`), retitle as `fix(nvn): HOS_NVN_WATCH_TEX ...`, and land the watch fixes on their own merits. https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2018 already defers its watch points (races, frame walk) to them. Also note https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2050 makes `rec()` always-inline and drops `cmd_alloc`'s header write. What is left for a specialised writer here is smaller still. **Suggestions** (the author may take or leave) - `host/nvn_native.c:2193`: on an `nn::os` fiber, `c->x[29]` points into the fiber's own stack (game memory, `HosFiber.stack`/`size`). `hos_thread_stack(hos_self())` still gives the thread's stack, so the walk now ends at the LR. `main` walked those frames. If the game records any commands on a fiber, the watch loses its callers there. A small `hos_ctx_stack(Ctx *, &addr, &size)` in `hos_thread.c` (via `fiber_of_ctx`) would bound the walk to the stack actually in use. `svcQueryMemory` and `GetCurrentStackInfo` share the same gap. - `guest_chain` (line 1711, used by the other watches) keeps the unbounded walk this PR fixes for the texture watch. One bounded walker used by both would fix them all; that can be a follow-up. - The `_Static_assert` checks that the size is a multiple of 8, but not that the struct has no hidden padding. An `offsetof(nvn_p_bind_handles, src) == 16 && offsetof(nvn_p_bind_handles, h) == 24` would pin the "every byte is a field" claim the writer relies on. - No case checks the `hos_mem_region` half of the walk's condition: the fixture's stack is always mapped, so removing it passes. That's fine as a belt-and-braces check, but the docstring could say so. **Testing:** the author ran the focused check on Windows (all seven cases pass at fe1dd999; `match` fails at 0c4ecdf9 as it should), plus `run_all --changed` (19 pass, the 2 failures also fail on `main`). Not done yet: an in-game run, a Linux build, CI at this head, Tier 1, Windows AMD. The farm request 63024 is for this head and would cover picture parity, crashes and the Linux build. It is not the measurement blocking point 1 needs. **Overlaps and merge order:** - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2018 merges cleanly with this head (checked), and its test already stubs `hos_thread_stack`/`hos_mem_region`. 2018 first, as proposed, is fine. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2050 has no textual conflict, but a semantic one. It renames `static void cmd_reserve_rec(` / `static uint8_t *cmd_alloc(` to `static inline ...` and adds `cmd_grow`. That breaks this PR's `block(...)` cuts, and 2018's too. Whichever lands second updates the other's test. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2023 touches the watches next to `guest_chain` but not this code. The other siblings (2026, 2025, 2022, 1995, 1994, 1968, 1955) touch other parts of the file.
@ -2143,1 +2143,4 @@
/* (longshot) The record written field by field, pad_ too, with no zeroing first (every byte is one of them), and one
handle copied as one 8-byte block: no memset, and no memcpy of a size known only at run time for BindTexture. The
bytes recorded are the same (tests/test_nvn_bind_handles.py) */
static void bind_handles(nvn_cmd *o, uint32_t op, int stage, int first, int n, const uint64_t *h, uint64_t src,
Member

No measured gain for the record writer: the micro-benchmark's medians are identical on both sides, and the farm's p99-within-spread can't show a few ns a bind. Show the targeted number (bind path CPU share, main vs PR) moving outside the spread, or keep RECN and land the watch fixes as fix(nvn).

No measured gain for the record writer: the micro-benchmark's medians are identical on both sides, and the farm's p99-within-spread can't show a few ns a bind. Show the targeted number (bind path CPU share, main vs PR) moving outside the spread, or keep RECN and land the watch fixes as fix(nvn).
@ -2159,2 +2192,2 @@
uint64_t chain[8] = {c->x[30]}, fp = c->x[29];
for (int k = 1; k < 8 && fp && fp < 0x8000000000ull && !(fp & 7); k++) chain[k] = G64(fp + 8), fp = G64(fp);
uint64_t chain[8] = {c->x[30]}, fp = c->x[29], stk = 0, stk_n = 0;
if (hos_self()) hos_thread_stack(hos_self(), &stk, &stk_n); /* (none: no frame is walked) */
Member

On an nn::os fiber, x29 is in the fiber's stack, not hos_thread_stack(hos_self())'s, so the walk now stops at the LR where main walked on. A ctx-aware stack lookup (fiber_of_ctx) would keep those chains.

On an nn::os fiber, x29 is in the fiber's stack, not hos_thread_stack(hos_self())'s, so the walk now stops at the LR where main walked on. A ctx-aware stack lookup (fiber_of_ctx) would keep those chains.
siantm force-pushed perf/nvn-bind-fields from fe1dd99925
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 18s
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
to 2eb5aef906
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
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
2026-11-21 11:18:07 +00:00
Compare
siantm changed title from WIP: perf(nvn): a handle bind's record is written field by field, and HOS_NVN_WATCH_TEX's test is inline to WIP: fix(nvn): HOS_NVN_WATCH_TEX reads its switch once, keeps its chains under a lock and walks only the stack the bind runs on 2026-11-21 11:18:48 +00:00
Author
Contributor

Pushed 2eb5aef9 on main @ 9dd41326 (from fe1dd999 on 6e1521a7) and retitled fix(nvn), as dyst's review 65798 asked: the record writer is out (bind_handles, RECN and rec() as on main), the HOS_NVN_WATCH_TEX fixes stay (757053ee test, ed959f67 fix), and the walk follows an nn::os fiber's own stack (e10e72d1 hos_ctx_stack, 3704a9b5 test, 2eb5aef9 fix). Description rewritten: Summary, Testing on the new base (fb3-1954-r3-light, fb3-mxn-changed), Measurements, Risks, and #2018's order (no textual conflict; its test needs one hos_ctx_stack stub line once both are in).

Pushed 2eb5aef9 on `main` @ 9dd41326 (from fe1dd999 on 6e1521a7) and retitled `fix(nvn)`, as dyst's review 65798 asked: the record writer is out (`bind_handles`, `RECN` and `rec()` as on `main`), the HOS_NVN_WATCH_TEX fixes stay (757053ee test, ed959f67 fix), and the walk follows an `nn::os` fiber's own stack (e10e72d1 `hos_ctx_stack`, 3704a9b5 test, 2eb5aef9 fix). Description rewritten: Summary, Testing on the new base (fb3-1954-r3-light, fb3-mxn-changed), Measurements, Risks, and #2018's order (no textual conflict; its test needs one `hos_ctx_stack` stub line once both are in).
Author
Contributor

@dyst, on your review, and @futondestroyer, on yours: pushed 2eb5aef9 on main @ 9dd41326. The PR is retitled fix(nvn): HOS_NVN_WATCH_TEX ....

  • 65796 and your blocking 1: the record writer is out.
    • bind_handles, RECN and rec() are as on main.
    • The writer's own benchmark showed no difference. It may come back with a profile share of the bind path that does.
    • The offsetof asserts you suggested went with it. They pinned the writer's assumption that every byte of the record is a field, which rec()'s zeroing does not need.
  • The watch fixes stay, rebuilt on main without the writer.
    • 757053ee is the test, now tests/test_nvn_watch_tex.py. It fails on main in wide, match and race, and in zero and other on main's two getenv calls.
    • ed959f67 is the fix. The switch is read once under a lock, the chains are looked up under it, the walk is bounded and mapped, and the count is checked. It comes from 7c5dc91c, 519f5c7e, 0c4ecdf9 and fe1dd999.
    • The test no longer cuts cmd_alloc/cmd_reserve_rec, so the semantic conflict with #2050 you noted is gone too.
  • 65797 (the fiber's stack): taken.
    • e10e72d1 adds hos_ctx_stack(Ctx *, &addr, &size) in host/hos_thread.c. For a fiber's context it gives the fiber's own stack (through fiber_of_ctx); otherwise it gives the thread's.

    • 3704a9b5 is the test:

      • a frame chain on a fiber's stack is walked;
      • the thread's own context does not walk the fiber's stack;
      • a fiber frame that links up into the thread's stack ends the walk.

      It fails at the thread-bounded walk ("600 < 0 ..." where "600 < d1 < d2 ..." was expected).

    • 2eb5aef9 bounds the watch by hos_ctx_stack.

    • svcQueryMemory and GetCurrentStackInfo keep their gap, and so does guest_chain's walk. One bounded walker for all of them is left for a follow-up.

  • The docstring now says the fixture's stacks are always mapped, so no case decides on hos_mem_region alone.
  • #2018 still merges without a textual conflict. Its test needs one hos_ctx_stack stub line once both PRs are in: on the merge it fails without that line and passes with it. Whichever PR lands second adds the line, as the description says.
  • futondestroyer: the diagnostic fixes are now apart from the writer, as you asked for if the results overlapped. With the watch off, the in-game A/B now only checks that the default path (one atomic load before a texture bind) is unchanged. It is pending with the owner.

Tested on 9dd41326: tests/test_nvn_watch_tex.py passes at the head (all 7 cases). The changed-file checks gave 58 passed and 9 failed; the same 9 fail on main with the same messages. Details are in the description.

@dyst, on [your review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-65798), and @futondestroyer, on [yours](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-65466): pushed 2eb5aef9 on `main` @ 9dd41326. The PR is retitled `fix(nvn): HOS_NVN_WATCH_TEX ...`. - [65796](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-65796) and your blocking 1: the record writer is out. - `bind_handles`, `RECN` and `rec()` are as on `main`. - The writer's own benchmark showed no difference. It may come back with a profile share of the bind path that does. - The `offsetof` asserts you suggested went with it. They pinned the writer's assumption that every byte of the record is a field, which `rec()`'s zeroing does not need. - The watch fixes stay, rebuilt on `main` without the writer. - 757053ee is the test, now `tests/test_nvn_watch_tex.py`. It fails on `main` in wide, match and race, and in zero and other on `main`'s two `getenv` calls. - ed959f67 is the fix. The switch is read once under a lock, the chains are looked up under it, the walk is bounded and mapped, and the count is checked. It comes from 7c5dc91c, 519f5c7e, 0c4ecdf9 and fe1dd999. - The test no longer cuts `cmd_alloc`/`cmd_reserve_rec`, so the semantic conflict with #2050 you noted is gone too. - [65797](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1954#issuecomment-65797) (the fiber's stack): taken. - e10e72d1 adds `hos_ctx_stack(Ctx *, &addr, &size)` in `host/hos_thread.c`. For a fiber's context it gives the fiber's own stack (through `fiber_of_ctx`); otherwise it gives the thread's. - 3704a9b5 is the test: - a frame chain on a fiber's stack is walked; - the thread's own context does not walk the fiber's stack; - a fiber frame that links up into the thread's stack ends the walk. It fails at the thread-bounded walk ("600 < 0 ..." where "600 < d1 < d2 ..." was expected). - 2eb5aef9 bounds the watch by `hos_ctx_stack`. - `svcQueryMemory` and `GetCurrentStackInfo` keep their gap, and so does `guest_chain`'s walk. One bounded walker for all of them is left for a follow-up. - The docstring now says the fixture's stacks are always mapped, so no case decides on `hos_mem_region` alone. - #2018 still merges without a textual conflict. Its test needs one `hos_ctx_stack` stub line once both PRs are in: on the merge it fails without that line and passes with it. Whichever PR lands second adds the line, as the description says. - futondestroyer: the diagnostic fixes are now apart from the writer, as you asked for if the results overlapped. With the watch off, the in-game A/B now only checks that the default path (one atomic load before a texture bind) is unchanged. It is pending with the owner. Tested on 9dd41326: `tests/test_nvn_watch_tex.py` passes at the head (all 7 cases). The changed-file checks gave 58 passed and 9 failed; the same 9 fail on `main` with the same messages. Details are in the description.
Author
Contributor

@Beanstalk This fixes the HOS_NVN_WATCH_TEX debug watch (off by default; host/nvn_native.c): it reads its switch once, keeps its chains under a lock and walks only the stack the bind runs on. With the switch unset, as players run, nothing should change. Please take a picture at a fixed point with no input, right after the start save settles, and one main-against-itself picture; then play Castle Town Market (from the market-entrance save) and Hyrule Field, two minutes each, for frame times; the PR against main on the same PC with HOS_NVN_WATCH_TEX unset, and one more run of the PR with HOS_NVN_WATCH_TEX set; on Linux with NVIDIA, Linux with AMD (RADV), Windows with Intel and the Steam Deck. The same picture as main within main's own noise, no crash or hang (with the watch set too); unset, frame time p99 equal to main's, within the run-to-run spread.

@Beanstalk This fixes the HOS_NVN_WATCH_TEX debug watch (off by default; host/nvn_native.c): it reads its switch once, keeps its chains under a lock and walks only the stack the bind runs on. With the switch unset, as players run, nothing should change. Please take a picture at a fixed point with no input, right after the start save settles, and one main-against-itself picture; then play Castle Town Market (from the market-entrance save) and Hyrule Field, two minutes each, for frame times; the PR against main on the same PC with HOS_NVN_WATCH_TEX unset, and one more run of the PR with HOS_NVN_WATCH_TEX set; on Linux with NVIDIA, Linux with AMD (RADV), Windows with Intel and the Steam Deck. The same picture as main within main's own noise, no crash or hang (with the watch set too); unset, frame time p99 equal to main's, within the run-to-run spread.
Member

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

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
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
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/nvn-bind-fields:siantm-perf/nvn-bind-fields'
git switch 'siantm-perf/nvn-bind-fields'
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!1954
No description provided.