perf(game): OoT preloads no neighbouring map during play (HOS_OCB_PRELOAD) #2900
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2900
Loading…
Reference in a new issue
No description provided.
Delete branch "Veix/Longshot:perf/ocb-no-preload"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
OoT no longer preloads the neighbouring map during play: on PC the preload costs more while walking than it saves at the door. In the Market at 4K the frames over 20 ms halve, and the first frame after an area's fade is about 40 % lighter; the castle's black screen is up to 0.4 s longer.
OoT's OptimizeChangeBank thread preloads the neighbouring map Link heads towards: its layouts, actor packs and models, read, unpacked and written during play. On the console that is unpacking on a spare core. On PC every map it writes is copied for the renderer, its textures are converted (ASTC to BC), and its threads take the game's emulated cores, so the game thread waits in frames you see. In the Market the game turns between the castle and the field side; with the 2 s hold of #1814 it still loads one or the other again every few seconds. And entering an area starts the preload of its neighbour in the same frames as the area's own first frame: the castle's first frame after its fade did the same work with and without it, but its command recording took 95-216 ms against 11-12 ms and its texture conversion 20-34 ms against 10 ms.
Now the preload manager's update goes on with no unit (the game's "none in range"), so it asks for no map and lets go of the one asked for before; the area loads when it is entered, behind its fade. A direct request (the game's own explicit load) and a manager laid out otherwise (another game build) keep the game's choice.
HOS_OCB_PRELOAD=1brings back the game's preload with the hold, as before.Read first:
game/oot_ocb_hold.h(oot_ocb_preload_on,oot_ocb_none),game/oot_ocb_hold.c(hos_oot_ocb_pick).Testing
Tested: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, Ryzen 9 9900X: the automated walking route (Market, Castle, Market) at 4K, this PR against
HOS_OCB_PRELOAD=1, as in Measurements. The log shows the mode in every run ("ocb: no neighbouring map preloaded during play", or the hold's line); both entries load and play normally. Earlier, on a test build with the same rule, the game asked for a neighbour 19-21 times a run and loaded none. Game-free:test_ocb_holdchecks the switch's values, that a choice flickering between two neighbours loads nothing and lets the map loaded before go once (the update's rest modelled), and that a direct request and another vtable keep the game's choice. The checks this change touches:test_ocb_holdpasses but fortest_callback_in_the_update, which does not build here (this PC's Rust toolchain has no gcc libraries for its build scripts; the change does not touch the site), andtest_switch_tablefails only onLONGSHOT_LAUNCHER_STARTUP, as onmain.Still to test:
HOS_OCB_PRELOAD=1, expecting the same direction in play and a longer black screen at entries (by hand)Measurements
Verdict: in the Market at 4K frames over 20 ms 48 / 35 -> 24 / 22, 1 % low 40.7 / 44.2 -> 46.9 / 46.0 fps, p99 20.8 / 19.9 -> 18.8 / 19.1 ms; the heaviest frame after an entry's fade 233 / 258 -> 139 / 134 ms (castle) and 124 / 121 -> 87 / 84 ms (Market); the castle's black screen 1.12 / 1.08 -> 1.54 / 1.20 s, the Market's 2.26 / 2.31 -> 2.31 / 2.31 s.
Setup: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, Ryzen 9 9900X; one build: this PR on main
28cb22b9e,HOS_OCB_PRELOAD=1(main's behaviour: the switch is the only difference) against unset, interleaved main / PR / PR / main; the automated walking route, 3840x2160 DLAA, uncapped, V-Sync off, shaders loaded at start, headless. The Market: its second stay from 5 s after its entry. A black screen: the frames with almost no drawing (draw recording under 0.2 ms) around the entry; the heaviest frame: the slowest in the 0.5 s after it. From the frame trace.28cb22b9e(HOS_OCB_PRELOAD=1)8bfbc37faWhat the preload costs in a given frame depends on timing, not on the route alone: whether its reading, unpacking and copying overlap a heavy frame (an entry's first frame, a turn) or quiet ones, whether the game's choice lasts the hold (a wall-clock time), and where the loader threads get a core. The route plays the same inputs every run, and main's two runs spread more than this PR's: frames over 20 ms 48 / 35 against 24 / 22, 1 % low 40.7 / 44.2 against 46.9 / 46.0 fps.
Risks
An area loads when it is entered: its black screen can be longer (the castle's up to 0.4 s here); a slower CPU loads it slower. Where the game would use a preloaded map in another way than the change to it, that map is loaded then.
HOS_OCB_PRELOAD=1brings back the game's preload withHOS_OCB_HOLD_MS, as before; a revert is enough too. Nothing changes for a player's saves,longshot_options.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, Ryzen 9 9900X: the automated walking route (Market, Castle, Market) at 4K DLAA, this PR against HOS_OCB_PRELOAD=1, two runs each, interleaved. Both entries load and play normally; the log shows the mode in every run; in the Market frames over 20 ms 48 / 35 -> 24 / 22.
@review
Recommendation: Approve. The code is ready: only testing is left. The measured Windows route shows fewer long Market frames, but the default also extends the castle loading screen by up to 0.42 seconds in these runs. The tradeoff and behavior on other affected Tier 1 systems still need testing before merge. Recommend approval; not approved on the forge.
Disables automatic neighbouring-map preloads by default, moving their work to area entry; an environment switch restores the previous held-preload behavior. This reduces measured walking hitches on the tested PC at the cost of longer loading screens.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
Questions (2) (not confirmed from the code; they don't hold the recommendation)
tests/test_ocb_hold.py:414: Is there a current case where the host selects the wrong behavior, beyond the hypothetical removal or inversion of the branch?Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, on the reported Windows RTX 4070 SUPER route: Market frames over 20 ms fell from 48/35 to 24/22 across two interleaved runs per mode, and castle entry's heaviest post-fade frame fell from 233/258 to 139/134 ms. Castle black screen time rose from 1.12/1.08 to 1.54/1.20 seconds. The comparison used the PR build with its switch restoring base behavior; results elsewhere remain unproven.
Other systems: The manager runs independently of GPU vendor and OS, but CPU contention, storage and loading times can change the result on Windows, Linux and Steam Deck. Direct requests and unknown manager layouts retain the game's choice; the game-free test covers those helper cases. Other areas and the game's alternate two-unit mode have not been exercised in the reported runs.
Switches: Adds HOS_OCB_PRELOAD: unset, 0 or other values disable automatic neighbouring-map preloads; 1 or on restores preloading with HOS_OCB_HOLD_MS. Its default has evidence on one Windows PC but needs the outstanding platform runs. HOS_OCB_HOLD_MS remains available but affects automatic choices only when preloading is enabled. The new switch has a switches.def row.
Reviewed:
8bfbc37faaagainst28cb22b9ed: Read AGENTS.md, CONTRIBUTING.md, the PR template, docs/dev/standards.md, the complete diff and commit, game/oot_ocb_hold.c and game/oot_ocb_hold.h. Read the changed test and its harness, the switch-table change, and searched the hook and its callers; skimmed the remainder of switches.def. docs/review-checklist.md and ../Tooling/AGENTS.md are absent. No generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code or tests were run. The author reports two interleaved runs per mode on Windows and a game-free helper test; CI is still running.
Overlaps and merge order: No overlapping pull requests identified from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by Veix. Nothing was run; a maintainer decides.
On fewer cores, and with Threaded rendering off: the same build (
8bfbc37fa, this PR on main28cb22b9e),HOS_OCB_PRELOAD=1against unset, interleaved main / PR / PR / main, the automated walking route at 3840x2160 DLAA, uncapped, headless; the game limited to the cores by its process's CPU affinity (Windows 11, RTX 4070 SUPER, driver 621.24, Ryzen 9 9900X). The Market: its second stay from 5 s after its entry. The log shows the preload's mode and the threading in every run.4 cores / 8 threads, Threaded rendering on (Auto: the render and recorder threads)
HOS_OCB_PRELOAD=16 cores / 12 threads, Threaded rendering off (
RX_VK_ASYNC=0,RX_VK_RECORDER=off)HOS_OCB_PRELOAD=1The three setups, the Market (
HOS_OCB_PRELOAD=1-> this PR)With Threaded rendering off the renderer's work runs on the game's own threads, and the preload costs the most there: frames over 25 ms 16 / 10 -> 3 / 1. That is the mode a Steam Deck runs in (an integrated GPU: Auto keeps the render thread off, and the recorder thread needs 6 cores). In each setup one of the two runs of this PR has a black screen 0.4-0.6 s longer and the other about the same; the heaviest frame after it is lighter or the same in all of them.
@Beanstalk Check what this costs at area changes. Three times: teleport to Market_Entrance, wait until in play, walk forward 3 s, then walk backwards until the next area starts loading (wait for loading_start, then a timer from loading_start to loading_end). Then the same three times from HyruleField_Child. Main against this PR. Targets: any, radv, steamdeck. Probes: frametime, process, crash. Fails if a timed load is more than 1 s longer or p99 is clearly worse.
@Veix only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.A note on reading the numbers above for normal play: the 1 % lows a player sees will likely gain less than these runs show. The preload only costs where a neighbouring map is in reach, and the route turns constantly in the Market, which keeps switching the game's choice between the castle and the field side and so exaggerates the losses with the preload on. Each frame the preload hit still gains the same; in normal play fewer frames are hit. The Market and Hyrule Field, where the game switches between neighbours the most, are likely where normal play gains the most.