fix(menu): keep renderer locks and upscaler_why out of declarations generation to prevent 5 ms menu faults #3223
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3223
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:fix/menu-upscaler-budget"
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
What a player notices:
Upscaler(for example between FSR 4, DLSS / DLAA, FSR 3.1, and Game's own) or toggling renderer locks (fsr4_model,dlss_model,dlss_pre_bloom,upscaling) no longer triggers repeatedsystem/menu5 ms frame-listener faults and 5 s menu stops.Sharpnessoccasionally disappearing in place without menu faults was observed separately and filed as #3229.)Root cause & fix:
gpu/vk/vk_menu.cpp(menu_capabilities) hashesout->lockedandout->upscaler_whyintoLsCapabilities::generation, whichsettings_host.rs(generation_of()) hashed into the declarations generation. WheneverUpscalerchanged and toggled renderer locks,generation_of()advanced, invalidatingdecls_cacheinsettings_host.rsand forcingsystem/menu(game/modapi/settings-host/store.ts) to re-read and re-lay out every tab across consecutive frames past its 5 ms frame-listener budget (3 faults in a minute -> 5 s stop).This PR separates capability lists from lock/reason state:
game/crates/api/src/services/settings_host.rs: Replacedcaps_generation()withcaps_hashes()/caps_hashes_of(), keepinggeneration_of()tied to capability lists only (n_sizes,n_monitors,n_gpus,n_menu_langs,refresh_mhz,has,reshade_files,outputs,mics,aspects,aspect_monitors,nfc_tags) and hashinglocked()+upscaler_why()intoFact::CapsState.game/crates/api/src/services/settings_push.rs: AddedFact::CapsStateso lock/reason changes rebuild watched rows in the same generation and push only rows whose state actually changed.Prior work & related:
#3098(merged): cachedsettingsHost.declsper generation, which does not preventgeneration_of()from advancing when renderer locks toggle.#3185: samesystem/menu5 mssettingsHost.declsfault signature.#3208(open): moves Insert menu logic out ofgpu/vk/vk_menu.cppinto Rust, but still feedsc.generationinsettings_host.rsand keepsnot_fsr4/not_dlss/not_dlaa/window_is_outputlocks. Because this fix is confined tosettings_host.rsandsettings_push.rs, it avoidsvk_menu.cppconflicts.Testing
Tested:
pr-3223-a725d2de): ToggledUpscalerwith AMD FSR 4.1.2 (INT8 Lite stand-in) active;system/menulogged 0 faults and 0 stops across the entire session (settingsHost.declsran once at3.2 mson initial menu open).3a0f7d8f7):cargo test -p api --lib --locked --release --target x86_64-pc-windows-gnullvm -- settings_host settings_push: 30 passed, 0 failed (includesa_lock_or_an_upscalers_reason_moves_the_rows_not_the_generationanda_lock_or_an_upscalers_reason_builds_every_watched_row_again_in_the_same_generation).tests/run_all.py --changed forge/main: 4 passed, 0 failed, 1 skipped (test_microphone_test_gain.py:clangnot in PATH). Fulltests/run_all.py: 701 passed, 82 skipped, 128 failed (unrelated C++/Vulkan/Rust checks due toclang/clang++/cargonot in sandbox PATH).Still to test:
Upscalerrepeatedly withHOS_FRAME_COST=1and verify0system/menufaults/stops (@Beanstalk).Measurements
Not a performance change; no steady-state FPS/frame-time delta expected. Menu-open
HOS_FRAME_COST=1before/after fault-count verification is still to run before marking ready.Risks
decls()does not readcaps.locked()orcaps.upscaler_why()(both are row state only), andFact::CapsStaterebuilds watched rows whenever either changes.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
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.@review
Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The change appears to prevent lock and reason changes from invalidating declarations, but the reported menu faults have not yet been checked in the game on this head. The required checks are also still running. Recommend approval; not approved on the forge.
It keeps cached menu declarations when renderer locks or upscaler reasons change and rebuilds watched row states instead. This targets the reported menu stops, at the cost of rebuilding all watched rows when that capability state changes.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
game/crates/api/src/services/settings_push.rs:264: The claimed fix has not yet been verified in the game on the current head. (more on the line) Do: On the current head, reproduce the switch sequence against the base and check the fault count, menu stops and Sharpness visibility with HOS_FRAME_COST enabled.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. The reported unit and menu tests passed before the final rebase, but there is no before-and-after game run showing that the 5 ms faults and menu stops are gone.
Other systems: The settings host and its watched-row pushes run on both Windows and Linux and can serve mods holding settings.host. The change also hashes capabilities periodically while the game runs; no current-head game run establishes its effect on menu responsiveness or gameplay.
Switches: None added, changed or removed.
Reviewed:
a725d2deeeagainst3a0f7d8f7f: Read the diff, commit, repository rules and pull request template; inspected the changed code, capability structure, renderer capability producer, push callers and menu consumers. The large settings_host.rs output was truncated, so parts of that file were only skimmed. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No recorded runs, translations or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run, as requested. The pull request reports 30 API tests and one menu behavioral test passing before the final rebase; current-head CI is still running.
Overlaps and merge order: The description identifies open PR #3208 as related; its current diff was not available for comparison.
Automated code review by BeanBot (gpt-6.1-terra), asked for by Jer9. Nothing was run; a maintainer decides.
@ -256,6 +261,7 @@ impl Push {let d = deps.get(k.as_str());fresh|| live|| moved.contains(&Fact::CapsState)L1 (should fix): The claimed fix has not yet been verified in the game on the current head.
When: When a player repeatedly changes the Upscaler, rebuilding every watched row could still exceed the menu listener's budget; the reported tests do not measure that path in the game.
Do: On the current head, reproduce the switch sequence against the base and check the fault count, menu stops and Sharpness visibility with HOS_FRAME_COST enabled.
WIP: fix(menu): keep renderer locks and upscaler_why out of declarations generation to prevent 5 ms menu faultsto fix(menu): keep renderer locks and upscaler_why out of declarations generation to prevent 5 ms menu faultsRecommendation: Approve. The reported current-head AMD game run satisfies L1, with no menu faults or stops while toggling the upscaler. The PR still awaits its stated NVIDIA DLSS/DLAA run and CI results. Nothing blocking is left. Recommend approval; not approved on the forge.
Keeps renderer lock and upscaler-reason changes from invalidating menu declarations, while rebuilding watched rows when their state changes. This avoids repeated full menu layouts at the cost of rebuilding watched rows when capability state changes.
Since the last review (on
a725d2deee)Resolved: L1 (The claimed fix has not yet been verified in the game on the current head.)
Checks: Still running: 11 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes, on the reported Windows AMD run: the current-head build logged 0 faults and 0 stops, and initial declarations took 3.2 ms. No before/after fault count is reported; NVIDIA verification remains outstanding.
Other systems: The changed host path also runs on Linux and with other upscalers. The reported game run covers Windows on AMD; NVIDIA DLSS/DLAA remains to be tested.
Switches: None.
Reviewed:
a725d2deeeagainst3a0f7d8f7f: Read the repository rules and diff; inspected the changed code and related capability and push references. The full changed files were not completely read because the combined output was truncated. The neighboring Tooling rules checkout was unavailable.; nothing run (a code review).Checked and fine:
Testing: No tests or game runs were executed during this review. The PR reports a current-head AMD game run and unit tests from before the final rebase.
Overlaps and merge order: The PR identifies #3208 as related; its description says this change avoids vk_menu.cpp conflicts.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as Jer9 took it out of WIP. Nothing was run; a maintainer decides.
Deck reproduction of the trigger, on plain
mainwithout this PR: Steam Deck LCD,nightly-1118-3a0f7d8f(source429d93ea), launcher install, 1280x800, no player mods, 21-26 fps. Graphics tab,Upscalerswitched (to DLAA,vk: upscaler: NVIDIA DLAA after the game's bloom and tone map).The declarations rebuild is real here, and bigger than on the reporter's machine. Right after the switch, the menu's settings-host listener eats
179 major page faults in one call (longshot/settings-host changed listener)(4.4 ms wall, 3.8 ms in the kernel), and then the frame listener faults three times and stops:One
settingsHost.declscall at 7.0 ms is over the 5 ms callback budget on this hardware by itself, which is the uncached rebuild this PR keeps from happening. That part of the fix matches what I see.What this PR will not fix, on this hardware: with the declarations cached, the same listener still measures 5.5 to 5.9 ms across 52 calls, of which the API is only 0.9 to 1.6 ms and 4.5 to 5.6 ms is the menu's own JavaScript. After its automatic restart the first frame listener reads 5.9 ms (52 calls,
settingsHost.decls3.4 ms, own JavaScript 2.3 ms) and it stops again within seconds. So on a Deck the menu's frame listener sits at or over 5 ms even whendecls()is cheap; this PR removes the spike, not the baseline.system/mods-tabalso faulted and stopped in the same minutes (5.1 to 5.7 ms of CPU; one or twomodsHost.tabcalls at 1.0 to 1.2 ms, and 4.9 to 5.0 ms of its own JavaScript). That is #3230, a different call, and it stops the menu through the same fallback page.Deck available if a run of this PR's head would help:
pr-3223on the Deck with the upscaler and renderer-lock toggles, countingsystem/menufaults, is theplatform/steam-deckcase this PR's Still to test is missing. Say the word and I will run it.Correction to my line above: the
NVIDIA DLAAlog line is not the upscaler that was selected, and I read it wrong.gpu/vk/vk_temporal.cpp'spre_bloom_wanted()logs it once, the first time the temporal path is prepared (temporal_hdr_input()calls it, fromvk_dlss.cpp's prepare), and what it says is that the DLAA-before-the-bloom option is off. Thevk: upscaler: the scene's camera: ...line beside it is the other one-time line from that same first prepare. Together they mark "the temporal upscaler started running", nothing more.What was actually switched here is between the two choices this Deck offers: the game's own upscaler and AMD FSR. Both are supported on this GPU, nothing unsupported was picked, and the menu only lists what runs:
temporal_wanted()/upscaler()fall back to the game's own when a choice'swhyis not OK, so an unavailable upscaler is not selected in the first place.That makes the reproduction stronger rather than weaker: an ordinary change between two supported choices is enough. The evidence stands as posted: one
settingsHost.declscall of 7.0 ms and three frames over the 5 ms budget follow the switch, andsystem/menuis stopped.Ran this PR's head on a Steam Deck LCD, as a dev-packs runtime beside a base build at its parent commit. Same actions on both builds, three runs each, alternating:
3a0f7d8fvs PRa725d2demenu_key insert), walk the focus to theUpscalerrow, then fiveoption setchanges of the Upscaler (0, 1, 0, 1, 0) with the menu openlog.txtsystem/menufaults / stops:The costliest
settingsHost.declscall in the same runs:So the declarations rebuild does get cheaper where the fix applies: 2.1 down to 1.5-1.6 ms in two runs of three, and the frame listener's warn drops from ~3.8 to ~2.8 ms. That matches what the change says it does.
What it does not do here is keep the listener under its budget. It still crosses 5 ms and the menu still stops, one run in three on each build, so on this hardware I cannot separate the two builds by outcome.
system/mods-tabfaulted in all three base runs and two of the three PR runs, which ismodsHost.taband #3230, untouched by this PR.Caveat on the setup: this A/B ran at the title screen, 60 fps, with the Insert menu open, not in gameplay at 20-25 fps where the same listener measured 5.9 ms on
nightly-1118. The pressure in play is higher, not lower. The runtime lives on the SD card.Also, for whoever tries the #3229 row check:
ctl shothanded back a stale title-screen frame while the menu was open in this build (the known swapchain quirk), so a still is not evidence of the focused row; the bridge'sstatusoverlays.focuswas the usable signal.Conclusion from the Deck: the fix removes part of the spike, as intended, and does not by itself make the menu survive here. The listener's own JavaScript and the Mods tab's repaint are separate costs that still reach the budget.
AMD lab A/B/A/B:
main7bc53f841(A) against this PR's heada725d2deemerged onto it (B). AMD lab PC: Linux 7.3.3-1-cachyos, Core i7-9700K, 15 GB RAM (zram swap), Radeon RX 580 with Mesa RADV 3:26.2.6-1. A/B/A/B, 90 s per run after a 15 s warm-up, each a timing job in the queue, headless, uncapped, V-Sync and frame generation off.Scenario: standing in the Market with the Insert menu open, the Upscaler (
dlsskey) changed every 2 s through FSR 3.1, Game's own and Off (44 changes per run),HOS_FRAME_COST=1. 1280x720 output.The
system/menubudget warnings during Upscaler changes are gone with the PR. Neither side had a fault or a stop.system/menu: its script ran N mswarningssystem/menufaults or stopssettingsHost.declsabout 1.2-1.5 ms of it in the lines I read.mainthe budget is not the one in the title: the log saysmore than 2 ms is warned about, more than 8 ms is a fault. So these runs could not show the 5 ms faults, only that the warnings stop. The title and description may want an update.A hang seen once on
main: in a first attempt (not in the table), an A run stopped presenting after its 41st change,control: setting dlss 3 -> 6(FSR 3.1 to Off). The log has novk: upscaler: Off: ...line and no furtherpresentsline after it, and the game didn't answer the control bridge for 40 s, until the harness ended it. That was 1 of 4mainruns and 0 of 4 PR runs, far too few to say the PR affects it.Not covered: DLSS / DLAA (NVIDIA).
Gameplay A/B of this PR on the same Deck, with the two runtimes as above. Same actions both builds: New Game, reach play (Kokiri Forest, child), open the Insert menu, walk the focus to
Upscaler, fiveoption setchanges with the menu open.HOS_EVENT_STATS=1in both. Two runs each, alternating.For completeness, the title-screen runs from before (three each):
Over ten runs the two builds are indistinguishable in outcome, and each stops the menu in half of its gameplay runs. The cost improvement is real where the change applies (
settingsHost.decls2.1 -> 1.5-1.6 ms, listener warn 3.8 -> 2.8 ms) and it is not enough: the listener's own JavaScript is 4.1-5.6 ms on this CPU, so one layout pass still lands at 5-6 ms and three of those in a minute stop the mod.One measurement worth having for whoever picks this up: with
HOS_EVENT_STATS=1, 3600 frames with the Insert menu open at the title screen loggedso the menu is not laying out every frame, it lays out about a dozen times a minute and each pass is the costly thing. That makes the budget question sharper: it is not the frequency, it is the 5-6 ms of one pass on this hardware.
Verdict from this Deck: the change is correct for the spike it removes and it will not stop the fallback page on Deck-class CPUs by itself. The listener's own cost per pass, and
modsHost.tab's repaint (#3230), are separate.@review
Recommendation: Approve. The change removes capability-state changes from declarations generation while continuing to refresh affected row state. Testing shows the declarations spike is reduced, although the menu can still stop on Steam Deck because of separate costs. Recommend approval; not approved on the forge.
Upscaler and renderer-lock changes keep cached menu declarations and rebuild watched row states when locks or availability reasons change. This adds a separate capability-state hash and some row-rebuild work when that state changes.
Since the last review (on
a725d2deee)Nothing changed in the ledger.
Checks: Still running: 10 checks.
Also noticed (5; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes. On the Steam Deck, three alternating title-screen runs per build showed the costliest declarations call at 2.1–2.6 ms on the base and 1.5–2.2 ms on the PR; faults and stops remained variable on both. An AMD Linux A/B/A/B run reduced warnings during 44 upscaler changes per run from 9 to 0 in each pair.
Other systems: The change affects menu capability and row-state handling across platforms and upscalers. Windows AMD and Linux AMD, including Steam Deck, have been exercised; NVIDIA DLSS and DLAA remain untested.
Switches: None.
Reviewed:
a725d2deeeagainst3a0f7d8f7f: Read the repository rules, PR template, diff, changed Rust files and supplied runs. The combined file output was truncated, so not every part of the changed files or referenced standards was read in full; the renderer and menu callers were not fully traced. The review checklist file was absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or execute project code were run. Supplied evidence includes Windows AMD testing, Linux AMD A/B runs and Steam Deck title-screen and gameplay runs.
Overlaps and merge order: PR #3208 also changes menu capability handling; the PR description says it does not overlap these files.
Automated code review by BeanBot (gpt-6.1-terra), asked for by omgitsgela. Nothing was run; a maintainer decides.
a725d2deee51b9c76df1@rebase
51b9c76df155c8fb38feI rebased this pull request onto
main(2500534d84): the new head isc61b0575bd.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
55c8fb38fec61b0575bdRecommendation: Approve. The change removes the declarations rebuild on lock changes, and AMD testing shows fewer menu budget warnings. CI is still running, and the described NVIDIA DLSS/DLAA run remains outstanding. Nothing blocking is left. Recommend approval; not approved on the forge.
Keeps capability lock and reason changes from invalidating menu declarations, while rebuilding watched row states when those changes occur. It reduces the rebuild cost, though Deck testing shows other menu work can still cause stops.
Since the last review (on
a725d2deee)Nothing changed in the ledger.
Checks: Still running: 11 checks.
Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for the targeted rebuild: the Linux AMD A/B/A/B run recorded 9, 1, 9, 1 menu warnings, with the PR's warnings occurring before the first upscaler change. Deck runs showed cheaper declarations calls in two of three title-screen comparisons, but the menu still stopped in one run per build.
Other systems: The hash feeds menu declarations and watched row updates on Windows and Linux. AMD Windows and Linux and Steam Deck runs are reported; NVIDIA DLSS/DLAA remains untested. The Deck's separate menu and mods-tab costs can still cause stops.
Switches: None.
Reviewed:
c61b0575bdagainst2500534d84: Read the diffs, commit log, AGENTS.md and CONTRIBUTING.md; inspected the capability structure and its consumers. The full changed files were requested, but their output was truncated; they were not read in full. The pull request template and referenced standards were not read.; nothing run (a code review).Checked and fine:
Testing: Read the reported AMD and Steam Deck runs and the CI status; no commands from the project or tests were run. CI checks are still running.
Overlaps and merge order: #3208 also changes the renderer settings path; the supplied description says this change avoids its renderer-file conflict.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.