fix(host): the OptimizeChangeBank hold is keyed to the bank's identity and checks the guest layout (follow-up to #1814) #1870

Merged
llun merged 2 commits from GummiNaomi/Longshot:fix/ocb-hold-review into main 2026-11-21 03:28:25 +00:00
Member

Summary

A follow-up to #1814 (HOS_OCB_HOLD_MS), which was merged while futondestroyer's review asking for changes was still open
(its review of 48b45e7b, #1814). It fixes the review's three
points, and a fourth case ballotstomper found on Linux (4. below); the hold itself, its default (2000 ms) and the patched
line are unchanged.

  1. A reused slot inherited the earlier occupant's hold timer. The candidate was remembered by its slot index only, so
    when the map changed and the same slot was filled with another neighbour, that neighbour could be taken on the old
    one's time (on main: chosen at 1.6 s after an earlier occupant had been chosen from 0, it is taken at 2.0 s instead of
    3.6 s). A choice is now the manager, the unit and the map in it (an FNV-1a of the unit's own path), seen by every
    update with no gap over 500 ms; a change of any of these, or a pause in the updates (a loading screen, a freeze),
    starts its time again.
  2. The read assumed the guest layout and the pointers' lifetime. main followed the manager's path pointers (+0x70,
    +0x1e8, each unit's +0x10) wherever they pointed. The constructor (f_80d32c00) points each of them at a 0x100-byte
    buffer inside the manager, and nothing repoints them, so the host now checks exactly that before each read: the
    vtable (0x84bc1a28: the build and the class), each path pointer equal to its own buffer, the buffer sizes, the current
    length, a state the game has (0-7), in-use flags of 0 or 1, and the chosen unit in use. The strings are then read from
    those buffers only: every read stays inside the manager the update is running on, and no pointer the game could have
    freed is followed. Any mismatch gives the game's own choice at that update (counted; logged once). The patch is also
    made only in the supported build's lift (patch_file's supported flag, like the other build-specific patches), and the
    host compares main's build id with e0f3ccfa... once; another build gets the game's own choice.
  3. Negative values of the switch. HOS_OCB_HOLD_MS=-5 gave the 2000 ms default, although #1814 documented a negative
    value as off. A negative whole number is now 0 (the game's own), like 0 and off; malformed values (-, -x, 12x)
    keep the default; the switch is read once whatever its value (no "not read yet" value it could also take).
  4. A map two units name was cancelled and loaded again, over and over (reported, diagnosed and the fix designed by
    ballotstomper, in their comment of 21 Nov on this PR; Linux, RX 6750 XT). Hyrule Field lists Gerudo Valley in two
    units: unit 1 (the Lake Hylia side, LoadRadius 30) and unit 4 (the valley's gate, LoadRadius 240). Inside unit 4's
    radius the update chooses 4 and asks for the valley; at the next update oot_ocb_held resolved the held map to the
    first in-use unit naming it, unit 1, so oot_ocb_pick held choice 4 back for unit 1, and the update's release of
    the units it did not choose (f_832ba400, by path) cancelled the load it had just asked for. The valley's ~250 files
    were opened and decompressed again every ~76 ms while Link stayed in the radius; main has the same lookup.
    • oot_ocb_held now takes the update's choice: when that unit is in use and names the held map, it is the held unit,
      the same preload; oot_ocb_step passes it in (ballotstomper's fix). A choice is held back only when it names another
      map, which is what the hold is for.
    • Added beside it: when the choice names another map and is held back, the update goes on with the unit naming the
      held map whose +1 is set (asked for: f_832b9880 sets it when f_832ba540 succeeds and clears it when it lets the
      unit go), else the first one as before. Without it, a choice flickering between unit 4 and another
      neighbour's unit went on with unit 1 while it was held back, and the release of unit 4 cancelled the valley once.
    • Where each map has one unit (the market's neighbours), the held unit is the same as before.

Rebased onto main @ 6e1521a7 (head 1727599a; before it, a106df16 at f066ea85). No conflicts this time. Point 4 is one
new commit on top, crediting ballotstomper.

Read first: host/oot_ocb_hold.h (oot_ocb_pick, oot_ocb_layout, oot_ocb_held, oot_ocb_key, oot_ocb_step,
oot_ocb_hold_ms), then host/oot_ocb_hold.c and the gate in nx2/oot_patches.py patch_file. See #1814.

Testing

Tested: Windows 11 Pro 26200, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, the game held to 4
cores (affinity 0xF00), points 1-3 at 7afc46f8 (their code unchanged since): seven fountain-basin runs against main (below), one run with
HOS_OCB_HOLD_MS=-1, and six area changes plus a walk to the market's exit on each side. In every run the hold's log
line is there and the "not laid out" line is not: the layout check accepts the game's own manager (a run long enough to
log the counters says 39 choices of another neighbour held back, 4 taken, 0 updates refused, in 18000 updates). Area
changes: 6 of 6 arrived on both, 4.9 / 4.1 / 2.8 / 4.5 / 3.1 / 2.8 s here against 4.9 / 3.0 / 2.8 / 4.5 / 3.1 / 2.8 s on
main (the second, the first arrival in Hyrule Field, is the only one apart); the walk south ends at the same spot and the
same "Hyrule Castle Town" card on both.

Point 4 in the game here, at this head (1727599a) against main @ 6e1521a7, interleaved (main, PR, PR, main) plus one main
run with the hold off: the debug teleport into Gerudo Valley, Link walked back towards the field (four stick presses of
225 frames at a 61 fps cap, the same spot every run), then standing 60 s. Gerudo Valley's map must list Hyrule Field in
two units too (the change only does anything where two units name the held map), and there main cancels and reloads the field again and again: its layout opened 561 and 541 times, against 2
with this PR and 2 on main with HOS_OCB_HOLD_MS=0 (so the loop is the hold's lookup, not the game's). Numbers under
Measurements. ballotstomper measured their fix (the first bullet of 4.) on Linux on #1814's code: also there.

Checks: tests/test_ocb_hold.py passes on Windows (clang) and Linux (WSL Ubuntu 24.04, gcc 13.3) at this head. Its cases
for points 1-3 fail on main for the review's reasons: run against main's header, the same-slot refill is taken at 2000 ms
instead of 3600 ms, the held unit is read through a pointer outside the manager (and held), and -1, -5, -2000 give
2000 ms (at 7afc46f8). Point 4's cases are ballotstomper's (two in-use units naming one map, that map loading:
oot_ocb_held gives 4 with choice 4 and 1 with none, oot_ocb_step keeps 4), the +1 fallback, and a model of the rest
of the update (it asks for the unit it goes on with and lets go of the other units asked for, by path): 10 s standing in
unit 4's radius, then 10 s on the edge of another neighbour's radius, 0 loads of the valley cancelled. Run against the
previous head's lookup (main's: the first unit naming the map), they fail: 312 and 313 cancels, oot_ocb_held 1 for choice
4; with ballotstomper's rule alone, the edge case still cancels once. test_switch_table (--cxx clang++) and
test_doc_anchors pass. run_all.py --changed at this head ran 72 checks (those that read the changed files): 32 pass, 26 are
skipped (no gcc or Vulkan headers on this PC) and 14 fail, each the same way on main @ 6e1521a7 (test_bc_small_scratch,
test_crash_dialog, test_dev_ab, test_dev_packs, test_frame_overlap, test_frame_whole, test_high_fps_fixes, test_lift_cache,
test_linux_pressure, test_oot_cloth_60, test_oot_cloth_time, test_quick_pipelines, test_texture_ahead,
test_water_substeps: MSVC headers under -Werror, HOS_HEAP_BASE, an unclassified FSR 4 file, main's own). The host file
was built by the builder's Windows (llvm-mingw) build of this head.

Still to test:

  • steamdeck: walk into Castle Town's market fountain and circle for a minute, with and without HOS_OCB_HOLD_MS=0,
    expecting fewer long frames with the hold and no ocb: the preload manager ... is not laid out line in the log
    (@Beanstalk steamdeck, the market fountain circles with HOS_OCB_HOLD_MS=0 against unset)
  • linux, any GPU: the same circles, expecting the hold's log line and no "not laid out" line (@Beanstalk linux, the market
    fountain circles)
  • 16 cores, Windows: the fountain circles against main, expecting no difference (by hand)
  • linux or steamdeck (point 4): ballotstomper's ranch walk at this head, expecting their fix's numbers (by hand or the
    Test Farm)
  • any (point 4): Hyrule Field inside the valley gate's radius (unit 4), the field side of the case measured here from
    the valley's side, expecting Gerudo Valley's files opened once (by hand, HOS_FS_TRACE=1)

Measurements

Verdict: the hold works as on main: in the 4-core fountain basin 70.4 fps against main's 71.1 (-1.0 %, within the
runs' spread: 69.6-71.7 here, 70.5-71.5 on main), the loader threads 6.4-8.2 % of a core against 5.0-7.4 %, and 43 % with
the hold off (HOS_OCB_HOLD_MS=-1, now off as documented: 56.5 fps). Area changes as on main. Nothing to gain was
expected from points 1-3: they are correctness fixes. Point 4 is a real gain where a map has two units: ballotstomper's
ranch walk (Linux, RX 6750 XT, #1814's code with their fix) went from 39.3 / 36.9 / 37.0 fps to 54.8 / 47.6 / 55.8, p99
from 67-160 ms to 27-82 ms, game time a frame from ~21 ms to 15-17 ms; a watch on the manager showed the valley's load
reaching state 4 and staying. Here, the same case from Gerudo Valley's side (Testing), 60 s standing at a 61 fps cap
(so fps cannot rise; the long frames, the game's time a frame and the loaders' CPU show it):

Before: main @ 6e1521a7 (two runs) After: this PR @ 1727599a (two runs) Before, HOS_OCB_HOLD_MS=0: main @ 6e1521a7 (one run)
Hyrule Field's layout opened 561 / 541 2 / 2 2
files opened, the whole run 187,995 / 194,332 12,258 / 12,833 12,890
loader threads, % of a core (mean of the 5 s lines) 211 / 206 none over 5 % none over 5 %
frames of 20 ms or more 6.1 / 7.0 % 0.1 / 0.1 % 0.2 %
99th percentile frame 26.5 / 27.1 ms 18.0 / 17.8 ms 18.1 ms
frames of 33.3 ms or more 1 / 4 (longest 37 / 223 ms) 0 / 0 0
the game's time a frame (mean) 8.11 / 8.42 ms 5.87 / 5.64 ms 5.96 ms

Setup: as above (this PC, all 16 cores this time), 1920x1080 headless (the control tool's test profile),
RX_VK_FRAME_TRACE=1 HOS_FPS_MAX=61 HOS_FS_TRACE=1 HOS_THREAD_TIMES=5, the kokiri-start save. Loaders: Resource
Memory, ARes Loading 0/1 and the ParallelDecompThreads. Standing at the valley's arrival spot without the walk, main
opens the field's layout twice too: the loop needs Link inside both units' radii.

Setup: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D SMT off, 32 GB, the game held to 4
cores (process affinity 0xF00), as #1814 measured it. Castle Town's market (child) from the kokiri-start save: four
cycles of teleport, a walk into the fountain's basin and six small circles, the circles' frames only; 2560x1440, uncapped
(HOS_FPS_MAX=1000), headless, RX_VK_FRAME_TRACE=1 HOS_THREAD_TIMES=5 and #1814's
RX_VK_ASTC_BC_ALL=1 RX_VK_IMAGE_BLOCK_MB=32 RX_VK_LOAD=create RX_VK_BC_LAYERS=8 RX_VK_LATE_FIX=0. Two interleaved rounds
(main, PR, PR, main), the executables swapped in one game folder; one main run of the first round never got past its
first teleport ("an event is playing") and was run again. The difference of the means: a bootstrap over 3 s blocks.
Loaders: ARes Loading, OptimizeChangeBanc, ParallelDecompThread and Resource Memory from the 5 s thread-time lines.

Before: main @ 8f462db5 After: this PR @ 7afc46f8 After, HOS_OCB_HOLD_MS=-1: this PR @ 7afc46f8
fps (each run) 71.5 / 71.2 / 70.5 70.2 / 69.6 / 70.0 / 71.7 56.5
fps, pooled (median run) 71.1 (71.2) 70.4 (70.1) 56.5
mean frame, pooled 14.07 ms 14.21 ms (+0.14, 95 %: +0.01 to +0.27) 17.69 ms
frames >= 16.7 ms 7.8 % 9.0 % 37.4 %
99th percentile frame 19.7 ms 20.0 ms 38.8 ms
frames of 33.3 ms or more 0 1 123
loader threads, % of a core 7.4 / 5.0 / 6.8 7.5 / 8.2 / 6.6 / 6.4 43.0
area changes arrived 6 of 6 6 of 6
  ocbfix-m1      main        5122 frames   71.5 fps  late  7.1 %  median 13.77 ms
  ocbfix-m2b     main        4620 frames   71.2 fps  late  7.6 %  median 13.80 ms
  ocbfix-m3      main        5002 frames   70.5 fps  late  8.8 %  median 13.94 ms
  ocbfix-p1      pr          4702 frames   70.2 fps  late  9.0 %  median 14.04 ms
  ocbfix-p2      pr          4614 frames   69.6 fps  late 11.4 %  median 14.11 ms
  ocbfix-p3      pr          4806 frames   70.0 fps  late  9.3 %  median 14.05 ms
  ocbfix-p4      pr          5248 frames   71.7 fps  late  6.8 %  median 13.74 ms
main       pooled 14744 frames   71.1 fps  mean 14.07 ms  late  7.8 %
pr         pooled 19370 frames   70.4 fps  mean 14.21 ms  late  9.0 %
pr - main: mean +0.136 ms (+0.97 % frame time, fps -0.96 %); 95 % interval +0.011 to +0.265 ms
main pooled             14744 frames  71.1 fps mean 14.07 ms late   7.8 % p99  19.7 p99.9  22.7 hitches   0 (0.00/1000)
pr pooled               19370 frames  70.4 fps mean 14.21 ms late   9.0 % p99  20.0 p99.9  23.2 hitches   1 (0.05/1000)
  ocbfix-n1             4554 frames  56.5 fps mean 17.69 ms late  37.4 % p99  38.8 p99.9  48.8 hitches 123 (27.01/1000)
[hos sead::MainThread] ocb: a new neighbour to preload is taken once it stays the choice 2000 ms (HOS_OCB_HOLD_MS; 0: the game's own at every frame)
[hos sead::MainThread] ocb: 39 choices of another neighbour held back, 4 taken, 0 updates refused, in 18000 updates
[hos sead::MainThread] ocb: off (HOS_OCB_HOLD_MS): the game's own choice of a neighbour to preload at every frame

The switch's default stays 2000 ms, as #1814 measured it; only what a negative value means changes (off, as documented).
The block bootstrap puts 7afc46f8 up to 0.27 ms a frame behind main, but the runs overlap (the fastest run of all is
this PR's); the per-update work added is a few hundred byte and word loads inside the manager (its layout and one path's hash),
microseconds a frame. Not measured: 16 cores, the Steam Deck, Linux.

Risks

What could break: if the game's manager were ever laid out otherwise than the check expects, the hold would quietly do
nothing (the game's own choice at every frame, as with HOS_OCB_HOLD_MS=0) and the log would say so once
(ocb: the preload manager at ... is not laid out as host/oot_ocb_hold.h knows it); on this build the check passes (0
refused). A neighbour that comes back into the same slot after a pause now waits its full hold again: at most 2 s more
before its preload starts, as with any new choice. Point 4: a choice of another unit naming the held map is no longer held
back at all (it is the same preload; holding it was never the point), and a choice held back goes on with the unit that
asked for the held map; if the +1 byte ever meant something else, it would pick another unit naming the same map, never
another map. Turning it off: HOS_OCB_HOLD_MS=0, off or now any negative number.
After updating: the lifted code is unchanged, so no new translation; nothing else changes for players.

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). (The checks that read the changed files, on Windows; test_ocb_hold also on Linux; the failures are main's own here.)
  • 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 switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Built on Windows; the Linux build not run here, only the Linux checks.)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

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

🤖 Generated with Claude Code

## Summary A follow-up to #1814 (`HOS_OCB_HOLD_MS`), which was merged while futondestroyer's review asking for changes was still open (its review of 48b45e7b, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1814). It fixes the review's three points, and a fourth case ballotstomper found on Linux (4. below); the hold itself, its default (2000 ms) and the patched line are unchanged. 1. **A reused slot inherited the earlier occupant's hold timer.** The candidate was remembered by its slot index only, so when the map changed and the same slot was filled with another neighbour, that neighbour could be taken on the old one's time (on main: chosen at 1.6 s after an earlier occupant had been chosen from 0, it is taken at 2.0 s instead of 3.6 s). A choice is now the manager, the unit **and** the map in it (an FNV-1a of the unit's own path), seen by every update with no gap over 500 ms; a change of any of these, or a pause in the updates (a loading screen, a freeze), starts its time again. 2. **The read assumed the guest layout and the pointers' lifetime.** main followed the manager's path pointers (+0x70, +0x1e8, each unit's +0x10) wherever they pointed. The constructor (`f_80d32c00`) points each of them at a 0x100-byte buffer inside the manager, and nothing repoints them, so the host now checks exactly that before each read: the vtable (0x84bc1a28: the build and the class), each path pointer equal to its own buffer, the buffer sizes, the current length, a state the game has (0-7), in-use flags of 0 or 1, and the chosen unit in use. The strings are then read from those buffers only: every read stays inside the manager the update is running on, and no pointer the game could have freed is followed. Any mismatch gives the game's own choice at that update (counted; logged once). The patch is also made only in the supported build's lift (`patch_file`'s supported flag, like the other build-specific patches), and the host compares main's build id with `e0f3ccfa...` once; another build gets the game's own choice. 3. **Negative values of the switch.** `HOS_OCB_HOLD_MS=-5` gave the 2000 ms default, although #1814 documented a negative value as off. A negative whole number is now 0 (the game's own), like `0` and `off`; malformed values (`-`, `-x`, `12x`) keep the default; the switch is read once whatever its value (no "not read yet" value it could also take). 4. **A map two units name was cancelled and loaded again, over and over** (reported, diagnosed and the fix designed by ballotstomper, in their comment of 21 Nov on this PR; Linux, RX 6750 XT). Hyrule Field lists Gerudo Valley in two units: unit 1 (the Lake Hylia side, LoadRadius 30) and unit 4 (the valley's gate, LoadRadius 240). Inside unit 4's radius the update chooses 4 and asks for the valley; at the next update `oot_ocb_held` resolved the held map to the *first* in-use unit naming it, unit 1, so `oot_ocb_pick` held choice 4 back for unit 1, and the update's release of the units it did not choose (`f_832ba400`, by path) cancelled the load it had just asked for. The valley's ~250 files were opened and decompressed again every ~76 ms while Link stayed in the radius; main has the same lookup. - `oot_ocb_held` now takes the update's choice: when that unit is in use and names the held map, it is the held unit, the same preload; `oot_ocb_step` passes it in (ballotstomper's fix). A choice is held back only when it names another map, which is what the hold is for. - Added beside it: when the choice names another map and is held back, the update goes on with the unit naming the held map whose `+1` is set (asked for: `f_832b9880` sets it when `f_832ba540` succeeds and clears it when it lets the unit go), else the first one as before. Without it, a choice flickering between unit 4 and another neighbour's unit went on with unit 1 while it was held back, and the release of unit 4 cancelled the valley once. - Where each map has one unit (the market's neighbours), the held unit is the same as before. **Rebased** onto main @ 6e1521a7 (head 1727599a; before it, a106df16 at f066ea85). No conflicts this time. Point 4 is one new commit on top, crediting ballotstomper. Read first: `host/oot_ocb_hold.h` (`oot_ocb_pick`, `oot_ocb_layout`, `oot_ocb_held`, `oot_ocb_key`, `oot_ocb_step`, `oot_ocb_hold_ms`), then `host/oot_ocb_hold.c` and the gate in `nx2/oot_patches.py` `patch_file`. See #1814. ## Testing **Tested:** Windows 11 Pro 26200, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, the game held to 4 cores (affinity 0xF00), points 1-3 at 7afc46f8 (their code unchanged since): seven fountain-basin runs against main (below), one run with `HOS_OCB_HOLD_MS=-1`, and six area changes plus a walk to the market's exit on each side. In every run the hold's log line is there and the "not laid out" line is not: the layout check accepts the game's own manager (a run long enough to log the counters says `39 choices of another neighbour held back, 4 taken, 0 updates refused, in 18000 updates`). Area changes: 6 of 6 arrived on both, 4.9 / 4.1 / 2.8 / 4.5 / 3.1 / 2.8 s here against 4.9 / 3.0 / 2.8 / 4.5 / 3.1 / 2.8 s on main (the second, the first arrival in Hyrule Field, is the only one apart); the walk south ends at the same spot and the same "Hyrule Castle Town" card on both. Point 4 in the game here, at this head (1727599a) against main @ 6e1521a7, interleaved (main, PR, PR, main) plus one main run with the hold off: the debug teleport into Gerudo Valley, Link walked back towards the field (four stick presses of 225 frames at a 61 fps cap, the same spot every run), then standing 60 s. Gerudo Valley's map must list Hyrule Field in two units too (the change only does anything where two units name the held map), and there main cancels and reloads the field again and again: its layout opened 561 and 541 times, against 2 with this PR and 2 on main with `HOS_OCB_HOLD_MS=0` (so the loop is the hold's lookup, not the game's). Numbers under Measurements. ballotstomper measured their fix (the first bullet of 4.) on Linux on #1814's code: also there. Checks: `tests/test_ocb_hold.py` passes on Windows (clang) and Linux (WSL Ubuntu 24.04, gcc 13.3) at this head. Its cases for points 1-3 fail on main for the review's reasons: run against main's header, the same-slot refill is taken at 2000 ms instead of 3600 ms, the held unit is read through a pointer outside the manager (and held), and `-1`, `-5`, `-2000` give 2000 ms (at 7afc46f8). Point 4's cases are ballotstomper's (two in-use units naming one map, that map loading: `oot_ocb_held` gives 4 with choice 4 and 1 with none, `oot_ocb_step` keeps 4), the `+1` fallback, and a model of the rest of the update (it asks for the unit it goes on with and lets go of the other units asked for, by path): 10 s standing in unit 4's radius, then 10 s on the edge of another neighbour's radius, 0 loads of the valley cancelled. Run against the previous head's lookup (main's: the first unit naming the map), they fail: 312 and 313 cancels, `oot_ocb_held` 1 for choice 4; with ballotstomper's rule alone, the edge case still cancels once. `test_switch_table` (`--cxx clang++`) and `test_doc_anchors` pass. `run_all.py --changed` at this head ran 72 checks (those that read the changed files): 32 pass, 26 are skipped (no gcc or Vulkan headers on this PC) and 14 fail, each the same way on main @ 6e1521a7 (test_bc_small_scratch, test_crash_dialog, test_dev_ab, test_dev_packs, test_frame_overlap, test_frame_whole, test_high_fps_fixes, test_lift_cache, test_linux_pressure, test_oot_cloth_60, test_oot_cloth_time, test_quick_pipelines, test_texture_ahead, test_water_substeps: MSVC headers under `-Werror`, `HOS_HEAP_BASE`, an unclassified FSR 4 file, main's own). The host file was built by the builder's Windows (llvm-mingw) build of this head. **Still to test:** - steamdeck: walk into Castle Town's market fountain and circle for a minute, with and without `HOS_OCB_HOLD_MS=0`, expecting fewer long frames with the hold and no `ocb: the preload manager ... is not laid out` line in the log (@Beanstalk steamdeck, the market fountain circles with HOS_OCB_HOLD_MS=0 against unset) - linux, any GPU: the same circles, expecting the hold's log line and no "not laid out" line (@Beanstalk linux, the market fountain circles) - 16 cores, Windows: the fountain circles against main, expecting no difference (by hand) - linux or steamdeck (point 4): ballotstomper's ranch walk at this head, expecting their fix's numbers (by hand or the Test Farm) - any (point 4): Hyrule Field inside the valley gate's radius (unit 4), the field side of the case measured here from the valley's side, expecting Gerudo Valley's files opened once (by hand, `HOS_FS_TRACE=1`) ## Measurements **Verdict:** the hold works as on main: in the 4-core fountain basin 70.4 fps against main's 71.1 (-1.0 %, within the runs' spread: 69.6-71.7 here, 70.5-71.5 on main), the loader threads 6.4-8.2 % of a core against 5.0-7.4 %, and 43 % with the hold off (`HOS_OCB_HOLD_MS=-1`, now off as documented: 56.5 fps). Area changes as on main. Nothing to gain was expected from points 1-3: they are correctness fixes. Point 4 is a real gain where a map has two units: ballotstomper's ranch walk (Linux, RX 6750 XT, #1814's code with their fix) went from 39.3 / 36.9 / 37.0 fps to 54.8 / 47.6 / 55.8, p99 from 67-160 ms to 27-82 ms, game time a frame from ~21 ms to 15-17 ms; a watch on the manager showed the valley's load reaching state 4 and staying. Here, the same case from Gerudo Valley's side (Testing), 60 s standing at a 61 fps cap (so fps cannot rise; the long frames, the game's time a frame and the loaders' CPU show it): | | Before: main @ 6e1521a7 (two runs) | After: this PR @ 1727599a (two runs) | Before, `HOS_OCB_HOLD_MS=0`: main @ 6e1521a7 (one run) | |---|---|---|---| | Hyrule Field's layout opened | 561 / 541 | 2 / 2 | 2 | | files opened, the whole run | 187,995 / 194,332 | 12,258 / 12,833 | 12,890 | | loader threads, % of a core (mean of the 5 s lines) | 211 / 206 | none over 5 % | none over 5 % | | frames of 20 ms or more | 6.1 / 7.0 % | 0.1 / 0.1 % | 0.2 % | | 99th percentile frame | 26.5 / 27.1 ms | 18.0 / 17.8 ms | 18.1 ms | | frames of 33.3 ms or more | 1 / 4 (longest 37 / 223 ms) | 0 / 0 | 0 | | the game's time a frame (mean) | 8.11 / 8.42 ms | 5.87 / 5.64 ms | 5.96 ms | Setup: as above (this PC, all 16 cores this time), 1920x1080 headless (the control tool's test profile), `RX_VK_FRAME_TRACE=1 HOS_FPS_MAX=61 HOS_FS_TRACE=1 HOS_THREAD_TIMES=5`, the `kokiri-start` save. Loaders: Resource Memory, ARes Loading 0/1 and the ParallelDecompThreads. Standing at the valley's arrival spot without the walk, main opens the field's layout twice too: the loop needs Link inside both units' radii. Setup: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D SMT off, 32 GB, the game held to 4 cores (process affinity 0xF00), as #1814 measured it. Castle Town's market (child) from the `kokiri-start` save: four cycles of teleport, a walk into the fountain's basin and six small circles, the circles' frames only; 2560x1440, uncapped (`HOS_FPS_MAX=1000`), headless, `RX_VK_FRAME_TRACE=1 HOS_THREAD_TIMES=5` and #1814's `RX_VK_ASTC_BC_ALL=1 RX_VK_IMAGE_BLOCK_MB=32 RX_VK_LOAD=create RX_VK_BC_LAYERS=8 RX_VK_LATE_FIX=0`. Two interleaved rounds (main, PR, PR, main), the executables swapped in one game folder; one main run of the first round never got past its first teleport ("an event is playing") and was run again. The difference of the means: a bootstrap over 3 s blocks. Loaders: ARes Loading, OptimizeChangeBanc, ParallelDecompThread and Resource Memory from the 5 s thread-time lines. | | Before: main @ 8f462db5 | After: this PR @ 7afc46f8 | After, `HOS_OCB_HOLD_MS=-1`: this PR @ 7afc46f8 | |---|---|---|---| | fps (each run) | 71.5 / 71.2 / 70.5 | 70.2 / 69.6 / 70.0 / 71.7 | 56.5 | | fps, pooled (median run) | 71.1 (71.2) | 70.4 (70.1) | 56.5 | | mean frame, pooled | 14.07 ms | 14.21 ms (+0.14, 95 %: +0.01 to +0.27) | 17.69 ms | | frames >= 16.7 ms | 7.8 % | 9.0 % | 37.4 % | | 99th percentile frame | 19.7 ms | 20.0 ms | 38.8 ms | | frames of 33.3 ms or more | 0 | 1 | 123 | | loader threads, % of a core | 7.4 / 5.0 / 6.8 | 7.5 / 8.2 / 6.6 / 6.4 | 43.0 | | area changes arrived | 6 of 6 | 6 of 6 | | ``` ocbfix-m1 main 5122 frames 71.5 fps late 7.1 % median 13.77 ms ocbfix-m2b main 4620 frames 71.2 fps late 7.6 % median 13.80 ms ocbfix-m3 main 5002 frames 70.5 fps late 8.8 % median 13.94 ms ocbfix-p1 pr 4702 frames 70.2 fps late 9.0 % median 14.04 ms ocbfix-p2 pr 4614 frames 69.6 fps late 11.4 % median 14.11 ms ocbfix-p3 pr 4806 frames 70.0 fps late 9.3 % median 14.05 ms ocbfix-p4 pr 5248 frames 71.7 fps late 6.8 % median 13.74 ms main pooled 14744 frames 71.1 fps mean 14.07 ms late 7.8 % pr pooled 19370 frames 70.4 fps mean 14.21 ms late 9.0 % pr - main: mean +0.136 ms (+0.97 % frame time, fps -0.96 %); 95 % interval +0.011 to +0.265 ms main pooled 14744 frames 71.1 fps mean 14.07 ms late 7.8 % p99 19.7 p99.9 22.7 hitches 0 (0.00/1000) pr pooled 19370 frames 70.4 fps mean 14.21 ms late 9.0 % p99 20.0 p99.9 23.2 hitches 1 (0.05/1000) ocbfix-n1 4554 frames 56.5 fps mean 17.69 ms late 37.4 % p99 38.8 p99.9 48.8 hitches 123 (27.01/1000) [hos sead::MainThread] ocb: a new neighbour to preload is taken once it stays the choice 2000 ms (HOS_OCB_HOLD_MS; 0: the game's own at every frame) [hos sead::MainThread] ocb: 39 choices of another neighbour held back, 4 taken, 0 updates refused, in 18000 updates [hos sead::MainThread] ocb: off (HOS_OCB_HOLD_MS): the game's own choice of a neighbour to preload at every frame ``` The switch's default stays 2000 ms, as #1814 measured it; only what a negative value means changes (off, as documented). The block bootstrap puts 7afc46f8 up to 0.27 ms a frame behind main, but the runs overlap (the fastest run of all is this PR's); the per-update work added is a few hundred byte and word loads inside the manager (its layout and one path's hash), microseconds a frame. Not measured: 16 cores, the Steam Deck, Linux. ## Risks What could break: if the game's manager were ever laid out otherwise than the check expects, the hold would quietly do nothing (the game's own choice at every frame, as with `HOS_OCB_HOLD_MS=0`) and the log would say so once (`ocb: the preload manager at ... is not laid out as host/oot_ocb_hold.h knows it`); on this build the check passes (0 refused). A neighbour that comes back into the same slot after a pause now waits its full hold again: at most 2 s more before its preload starts, as with any new choice. Point 4: a choice of another unit naming the held map is no longer held back at all (it is the same preload; holding it was never the point), and a choice held back goes on with the unit that asked for the held map; if the `+1` byte ever meant something else, it would pick another unit naming the same map, never another map. Turning it off: `HOS_OCB_HOLD_MS=0`, `off` or now any negative number. After updating: the lifted code is unchanged, so no new translation; nothing else changes for players. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). (The checks that read the changed files, on Windows; `test_ocb_hold` also on Linux; the failures are main's own here.) - [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 switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Built on Windows; the Linux build not run here, only the Linux checks.) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(host): the OptimizeChangeBank hold is keyed to the bank's identity and checks the guest layout (follow-up to #1814)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
PR description / Description follows the template (pull_request_target) Failing after 16s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
Third-party parts / As their notes say (pull_request) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval needs a second approval (sensitive paths)
CI / Website build and checks (pull_request) Has been cancelled
7afc46f877
The review of #1814 (futondestroyer) found three things, fixed here:

- A reused slot inherited the earlier occupant's hold timer: the candidate was a slot index only. It is now the manager,
  the unit and the map in it (an FNV-1a of the unit's own path), seen by every update without a gap of more than 500 ms;
  any change starts its time again.
- The read assumed the guest layout and followed the manager's path pointers wherever they pointed. The host now checks
  the manager as f_80d32c00 builds it before each read (its vtable, each path pointer at its own 0x100-byte buffer, the
  buffer sizes, the state, the in-use flags, the chosen unit in use) and reads the strings from those buffers only, so
  nothing outside the live manager is read; any mismatch gives the game's own choice at that update (counted, logged
  once). The patch is made only in the supported build's lift, and the host checks main's build id once.
- Negative HOS_OCB_HOLD_MS values gave the 2000 ms default although the switch documents them as off: a negative whole
  number is now 0 (the game's own), like 0 and off; the switch is read once whatever its value.

tests/test_ocb_hold.py: the review's same-slot replacement within the hold, a pause, another manager, every layout
mismatch and stale pointer, the switch's unset, empty, 0, negative, positive and malformed values (each as the update
sees it), the supported-build gate. The new cases fail on main (the refilled slot taken at 2000 ms instead of 3600 ms,
the held unit read through a pointer outside the manager, -5 giving 2000 ms).

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

@Beanstalk steamdeck and linux: Castle Town's market (child) from kokiri-start, walk into the fountain's basin and circle for a minute, with HOS_OCB_HOLD_MS unset against HOS_OCB_HOLD_MS=0, RX_VK_FRAME_TRACE=1 HOS_THREAD_TIMES=5. Expecting fewer long frames and less loader-thread CPU with the hold (unset), the hold's log line, and no ocb: the preload manager ... is not laid out line.

(Earlier runs on #1846 and #1847 today ended in error before building: the farm's checkout of main failed git rev-parse --verify HEAD^{commit} in packs.py's cmd_base, so nothing was measured there.)

@Beanstalk steamdeck and linux: Castle Town's market (child) from kokiri-start, walk into the fountain's basin and circle for a minute, with `HOS_OCB_HOLD_MS` unset against `HOS_OCB_HOLD_MS=0`, `RX_VK_FRAME_TRACE=1 HOS_THREAD_TIMES=5`. Expecting fewer long frames and less loader-thread CPU with the hold (unset), the hold's log line, and no `ocb: the preload manager ... is not laid out` line. (Earlier runs on #1846 and #1847 today ended in `error` before building: the farm's checkout of main failed `git rev-parse --verify HEAD^{commit}` in packs.py's cmd_base, so nothing was measured there.)
Member

@GummiNaomi approval of 7afc46f recorded. This diff touches sensitive paths, so a second member of BigBeans must approve it too.

@GummiNaomi approval of `7afc46f` recorded. This diff touches sensitive paths, so a second member of `BigBeans` must approve it too.
Member

Beanstalk test farm

Commit 1727599 · approved by nobody yet · dashboard

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

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

Results look worst?

Results look worst?
GummiNaomi force-pushed fix/ocb-hold-review from 7afc46f877
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
PR description / Description follows the template (pull_request_target) Failing after 16s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
Third-party parts / As their notes say (pull_request) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval needs a second approval (sensitive paths)
CI / Website build and checks (pull_request) Has been cancelled
to f066ea8578
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 16s
beanstalk/approval not approved yet
Third-party parts / As their notes say (pull_request) Successful in 18s
PR description / Description follows the template (pull_request_target) Failing after 6s
CI / Website build and checks (pull_request) Has been cancelled
2026-11-20 21:14:52 +00:00
Compare
Author
Member

@HumanBean slightly, yes, by about 1 %: 70.4 against 71.1 fps, +0.14 ms a frame. That is within the runs' spread, though (main 70.5-71.5 fps, this PR 69.6-71.7), and the single fastest run of all was one of this PR's. The extra work is a few reads of the manager once a frame, so a real 0.14 ms cost is unlikely.

This PR is not meant to be faster. It fixes the three points of futondestroyer's review of #1814, which merged while that review was open:

  1. the hold read the game's path pointers wherever they pointed, so a freed one could crash;
  2. a reused slot could inherit the old neighbour's timer and preload up to about 2 s early;
  3. a negative HOS_OCB_HOLD_MS, documented as off, gave the default.

Rebased onto main @ a106df16 (only a switches.def row conflicted); its checks pass again. The farm needs a second BigBeans approval, since it touches nx2/oot_patches.py.

@HumanBean slightly, yes, by about 1 %: 70.4 against 71.1 fps, +0.14 ms a frame. That is within the runs' spread, though (main 70.5-71.5 fps, this PR 69.6-71.7), and the single fastest run of all was one of this PR's. The extra work is a few reads of the manager once a frame, so a real 0.14 ms cost is unlikely. This PR is not meant to be faster. It fixes the three points of futondestroyer's review of #1814, which merged while that review was open: 1. the hold read the game's path pointers wherever they pointed, so a freed one could crash; 2. a reused slot could inherit the old neighbour's timer and preload up to about 2 s early; 3. a negative `HOS_OCB_HOLD_MS`, documented as off, gave the default. Rebased onto main @ a106df16 (only a `switches.def` row conflicted); its checks pass again. The farm needs a second BigBeans approval, since it touches `nx2/oot_patches.py`.
Contributor

A case the hold still gets wrong on this head, found on Lon Lon Ranch (Linux, RX 6750 XT).

What happens. Hyrule Field's map lists Gerudo Valley in two units: unit 1 (the Lake Hylia side, LoadRadius 30) and unit 4 (the valley's gate, LoadRadius 240). Inside unit 4's radius:

  1. The update chooses 4 and asks for GerudoValley_Child (f_832ba540); unit 4's asked-for byte (+1) is set and the load starts.
  2. The next update, oot_ocb_held resolves the held map to a unit by path and returns the first in-use unit naming it: unit 1.
  3. oot_ocb_pick compares by unit index, so the choice 4 is held back: the update goes on with unit 1. Asking for it does nothing, since the manager's current map is already that one.
  4. The update then lets every other asked-for unit go. Unit 4 is one, and f_832ba400 releases by path, so it cancels the load just asked for: state 2/3 → 5 → 0, the current path emptied.
  5. With nothing held, the next update starts again at 1.

The map's ~250 files (layouts, 39 actor packs, 177 models, 32 textures) are opened and decompressed again every ~76 ms for as long as Link stays in the radius. A watch on the manager at one spot showed state 0 in 403 updates, 2–3 in 369, and loaded once in 811, with no unit left asked for. The fountain basin's maps have one unit each, so it doesn't show there.

The fix.

  • oot_ocb_held takes the update's choice as well. When that unit is in use and its own path is the held map's, it is the held unit; otherwise it is the first unit naming the map, as now.
  • oot_ocb_step passes chosen in.

So a choice is held back only when it names another map than the one held, which is what the hold is for. A unit naming the same map is the same preload, and the release by path can no longer cancel it.

Measured on #1814's code, which has the same lookup, with the fix: the load reaches state 4 and stays. A recorded walk through the ranch goes from 39.3 / 36.9 / 37.0 fps to 54.8 / 47.6 / 55.8 (p99 67–160 ms → 27–82 ms; game time a frame ~21 ms → 15–17).

A test for it: two in-use units naming one map with that map loading; oot_ocb_held with choice 4 returns 4, with no choice 1, and oot_ocb_step keeps 4. I can port both onto this head if you'd like them in this PR.

A case the hold still gets wrong on this head, found on Lon Lon Ranch (Linux, RX 6750 XT). **What happens.** Hyrule Field's map lists Gerudo Valley in two units: unit 1 (the Lake Hylia side, LoadRadius 30) and unit 4 (the valley's gate, LoadRadius 240). Inside unit 4's radius: 1. The update chooses 4 and asks for `GerudoValley_Child` (`f_832ba540`); unit 4's asked-for byte (+1) is set and the load starts. 2. The next update, `oot_ocb_held` resolves the held map to a unit by path and returns the first in-use unit naming it: unit 1. 3. `oot_ocb_pick` compares by unit index, so the choice 4 is held back: the update goes on with unit 1. Asking for it does nothing, since the manager's current map is already that one. 4. The update then lets every other asked-for unit go. Unit 4 is one, and `f_832ba400` releases by path, so it cancels the load just asked for: state 2/3 → 5 → 0, the current path emptied. 5. With nothing held, the next update starts again at 1. The map's ~250 files (layouts, 39 actor packs, 177 models, 32 textures) are opened and decompressed again every ~76 ms for as long as Link stays in the radius. A watch on the manager at one spot showed state 0 in 403 updates, 2–3 in 369, and loaded once in 811, with no unit left asked for. The fountain basin's maps have one unit each, so it doesn't show there. **The fix.** - `oot_ocb_held` takes the update's choice as well. When that unit is in use and its own path is the held map's, it is the held unit; otherwise it is the first unit naming the map, as now. - `oot_ocb_step` passes `chosen` in. So a choice is held back only when it names another map than the one held, which is what the hold is for. A unit naming the same map is the same preload, and the release by path can no longer cancel it. **Measured** on #1814's code, which has the same lookup, with the fix: the load reaches state 4 and stays. A recorded walk through the ranch goes from 39.3 / 36.9 / 37.0 fps to 54.8 / 47.6 / 55.8 (p99 67–160 ms → 27–82 ms; game time a frame ~21 ms → 15–17). A test for it: two in-use units naming one map with that map loading; `oot_ocb_held` with choice 4 returns 4, with no choice 1, and `oot_ocb_step` keeps 4. I can port both onto this head if you'd like them in this PR.
GummiNaomi force-pushed fix/ocb-hold-review from f066ea8578
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 16s
beanstalk/approval not approved yet
Third-party parts / As their notes say (pull_request) Successful in 18s
PR description / Description follows the template (pull_request_target) Failing after 6s
CI / Website build and checks (pull_request) Has been cancelled
to 1727599a3a
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
PR description / Description follows the template (pull_request_target) Failing after 7s
beanstalk/approval not approved yet
CI / Website build and checks (pull_request) Failing after 17s
2026-11-21 02:20:28 +00:00
Compare
Author
Member

@ballotstomper thank you: a clear report, the cause traced through to the release by path, numbers, and the fix. It is in this PR now, so there is no need to port it.

What changed (1727599a, on main @ 6e1521a7; the commit credits you for the report and the fix's design):

  • oot_ocb_held takes the update's choice: when that unit is in use and names the held map, it is the held unit; oot_ocb_step passes chosen in. A choice is held back only when it names another map.
  • One addition beside it: when the choice names another map and is held back, the update now goes on with the unit naming the held map whose +1 is set (the update sets it when f_832ba540 succeeds and clears it when it lets the unit go), else the first one as before. Without that, a choice flickering between unit 4 and another neighbour's unit went on with unit 1 while it was held back, and the release of unit 4 cancelled the valley once. Where your rule gives the choice, the result is the same.

How it was tested: your test as you described it (two in-use units naming one map, that map loading: oot_ocb_held gives 4 with choice 4 and 1 with no choice; oot_ocb_step keeps 4), the +1 fallback, and a small model of the rest of the update (it asks for the unit it goes on with and lets go of the other units asked for, by path): 10 s in unit 4's radius, then 10 s on the edge of another neighbour's radius. At this head the valley's load is never cancelled. With the previous lookup it is cancelled 312 and 313 times, and with the choice rule alone once on the edge. test_ocb_hold passes on Windows (clang) and Linux (gcc). I haven't run it in the game on Windows yet (the test PC is busy with other runs). Your ranch numbers are in the description, credited to you.

@ballotstomper thank you: a clear report, the cause traced through to the release by path, numbers, and the fix. It is in this PR now, so there is no need to port it. **What changed** (1727599a, on main @ 6e1521a7; the commit credits you for the report and the fix's design): - `oot_ocb_held` takes the update's choice: when that unit is in use and names the held map, it is the held unit; `oot_ocb_step` passes `chosen` in. A choice is held back only when it names another map. - One addition beside it: when the choice names another map and is held back, the update now goes on with the unit naming the held map whose `+1` is set (the update sets it when `f_832ba540` succeeds and clears it when it lets the unit go), else the first one as before. Without that, a choice flickering between unit 4 and another neighbour's unit went on with unit 1 while it was held back, and the release of unit 4 cancelled the valley once. Where your rule gives the choice, the result is the same. **How it was tested:** your test as you described it (two in-use units naming one map, that map loading: `oot_ocb_held` gives 4 with choice 4 and 1 with no choice; `oot_ocb_step` keeps 4), the `+1` fallback, and a small model of the rest of the update (it asks for the unit it goes on with and lets go of the other units asked for, by path): 10 s in unit 4's radius, then 10 s on the edge of another neighbour's radius. At this head the valley's load is never cancelled. With the previous lookup it is cancelled 312 and 313 times, and with the choice rule alone once on the edge. `test_ocb_hold` passes on Windows (clang) and Linux (gcc). I haven't run it in the game on Windows yet (the test PC is busy with other runs). Your ranch numbers are in the description, credited to you.
Author
Member

@ballotstomper the in-game check on Windows (RTX 4070 SUPER, 9950X3D) is done, at 1727599a against main @ 6e1521a7 (main, PR, PR, main). I found the same loop from the other side: Gerudo Valley's map must list Hyrule Field twice too. I teleported into the valley, walked Link back towards the field to the same spot each run (61 fps cap), then stood 60 s:

  • Hyrule Field's layout was opened 561 and 541 times on main, and 2 and 2 with this PR. Main with HOS_OCB_HOLD_MS=0 also gave 2, so the loop comes from the hold's lookup, not the game.
  • Files opened over the whole run: about 190,000 on main, about 12,500 with this PR.
  • The loader threads used ~2.1 cores on main. With this PR none of them was over 5 %.
  • Frames of 20 ms or more: 6-7 % on main, 0.1 % with this PR. The 99th percentile went from 27 ms to 18 ms, and the game's time a frame from 8.1-8.4 ms to 5.6-5.9 ms.

The table is in the description. I haven't checked the field side (inside unit 4's radius) here; it's listed under Still to test.

@ballotstomper the in-game check on Windows (RTX 4070 SUPER, 9950X3D) is done, at 1727599a against main @ 6e1521a7 (main, PR, PR, main). I found the same loop from the other side: Gerudo Valley's map must list Hyrule Field twice too. I teleported into the valley, walked Link back towards the field to the same spot each run (61 fps cap), then stood 60 s: - Hyrule Field's layout was opened 561 and 541 times on main, and 2 and 2 with this PR. Main with `HOS_OCB_HOLD_MS=0` also gave 2, so the loop comes from the hold's lookup, not the game. - Files opened over the whole run: about 190,000 on main, about 12,500 with this PR. - The loader threads used ~2.1 cores on main. With this PR none of them was over 5 %. - Frames of 20 ms or more: 6-7 % on main, 0.1 % with this PR. The 99th percentile went from 27 ms to 18 ms, and the game's time a frame from 8.1-8.4 ms to 5.6-5.9 ms. The table is in the description. I haven't checked the field side (inside unit 4's radius) here; it's listed under Still to test.
llun approved these changes 2026-11-21 03:28:18 +00:00
llun merged commit f1f2dc5bd2 into main 2026-11-21 03:28:25 +00:00
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!1870
No description provided.