fix(host): a CPU read or write of texels gives the thread's virtual core up while it waits for the GPU (no ~1 s freeze at area changes) #1827
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1827
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:fix/texels-give-core-up"
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
At some area changes, and once at boot, the game froze for about a second. A background thread of the game (SceneLowPriority at an area change, BootupBackgroundWorkThread at boot) wrote a texture's texels; Longshot's write waits in the Vulkan back end for the GPU to finish the work submitted before it, and that thread kept its virtual core through the wait. A worker the frame needed (ModuleSystemWorker2) could run only on that core and waited for it, the frame's signal never came, the GPU work being waited for could not finish, and only the present's one-second wait for the frame (
RX_VK_FRAME_GATE_MS) broke the cycle.This gives the virtual core up for the back end's call in both texel wrappers, read and write, as Longshot already does for its other waits for the GPU on a game thread (an invalidate, a remap). In four interleaved tours of seven areas, the one-second freezes went from 3 and 5 a tour (the core kept, as on main) to none.
How to see it on main: teleport between areas (Castle Town's market, Hyrule Field, Kakariko, Kokiri Forest, the Lost Woods, Zora's River) with the next frame's work held at OoT's frame limiter (
HOS_NVN_FRAME_OVERLAP=1, #1811); at some arrivals a frame takes about 1010 ms and the log's virtual-core waits name SceneLowPriority holding about a second. My runs all had that overlap on (it makes the cycle easy to reach); whether main alone reaches it was not tested. The change is right either way: the thread does no game work while it waits.Read first:
rx_nvn_read_texelsandrx_nvn_write_texelsinhost/rx_backend.c, thentests/test_texels_vcore.py.See #1811, #1646 (FreeAddressRegion gives its virtual core up while it discards: another wait, another fix).
Testing
Tested: Windows 11, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off. Four teleport tours of seven areas from the
kokiri-startsave, interleaved (kept, given up, given up, kept), on a build of main @f505340bwith #1810-#1813's changes and this fix, my play settings (HOS_NVN_FRAME_OVERLAP=1,RX_VK_TEX_MOVE=1,RX_VK_TEX_AHEAD=2,RX_VK_LATE_FIX=1), 2560x1440, no window: with the core given up, no virtual-core hold of 300 ms or more, no frame of 500 ms or more after the first arrival and no time-out of the present's wait in either tour; 0 errors in every log. The bug's steps no longer show it.Checks:
tests/test_texels_vcore.pypasses on this head on Windows (clang) and Linux (g++ 13.3, WSL Ubuntu 24.04), its four cases each; on main's wrappers its four default cases fail ("core held during the call") and the twoHOS_TEXELS_KEEP_CORE=1cases pass.Suite:
tests/run_all.pywith every check on main @068fb8ebin WSL Ubuntu 24.04 (740 pass, 61 fail, 69 skipped: no clang or spirv-val there), then this head's--changedchecks in WSL (42 pass, 8 fail, 4 skipped) and on Windows (49 run, 17 fail). Every failure also fails on main @068fb8ebon the same OS: in WSLtest_crash_dialog,test_dev_ab,test_frame_overlap,test_host_guest_writes,test_linux_pressure,test_present_queue_default,test_slow_frames,test_vk_occlusion_queries; on Windows those eight andtest_audio_output_devices,test_collect_wide,test_dev_build,test_driver_env_choose,test_hud_layout,test_invalidate_vcore,test_mesh_fallback_layout,test_pipeline_tour,test_wide_ui(most of them this PC's compiler wrapper or a missing tool).Still to test:
mainwithout #1811: the seven-area teleport tour twice withHOS_TEXELS_KEEP_CORE=1and twice unset, expecting no frame near 1 s unset and no virtual-core wait of 300 ms or more in the log (by hand)Measurements
Verdict: fixed where it showed: virtual-core holds of about a second, 3 and 5 a tour with the core kept, 0 and 0 with it given up; frames of 500 ms or more, 4 and 4 against 0 and 0 (the longest 1010 and 1008 ms against 296 and 320 ms).
Setup: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, 32 GB, 16 cores; a teleport tour of seven areas from the
kokiri-startsave, 2560x1440, uncapped, no window (HOS_HEADLESS=1), my play settings above in every tour; measured: the log's virtual-core waits (holds of 300 ms or more, with the holder), the frame trace's frames after the first arrival, the log's lines where the present's wait timed out; two tours a side, interleaved.Baseline: one build, main @
f505340b(11 commits before0de25c3e, on which this was first written) with #1810-#1813's changes and this fix;HOS_TEXELS_KEEP_CORE=1gives main's behaviour (the core kept) and unset this PR's. None of the commits since touches the two texel wrappers.HOS_TEXELS_KEEP_CORE=1) @f505340bf505340bRX_VK_FRAME_GATE_MS)HOS_TEXELS_KEEP_CORE(new, a kill switch) ships unset, the core given up, chosen by the table above;=1keeps the core through the wait, as before.Risks
What could break: after the GPU wait the thread may wait for a core again, as after an invalidate or a remap; nothing it does while it waits touches game state. Turning it off:
HOS_TEXELS_KEEP_CORE=1. After updating, a player notices nothing apart from the freeze gone: no change to 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
mainand passes here.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
WIP: fix(host): a CPU read or write of texels gives the thread's virtual core up while it waits for the GPU (no ~1 s freeze at area changes)to fix(host): a CPU read or write of texels gives the thread's virtual core up while it waits for the GPU (no ~1 s freeze at area changes)