perf(host): on Linux the game's own short sleeps wait on the timer instead of yielding #2637
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2637
Loading…
Reference in a new issue
No description provided.
Delete branch "perf/linux-short-sleep-timer"
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?
Draft. On Linux, OoT's idle job workers burn a processor each spinning in a yield loop while one of them waits on the GPU. This makes the game's own sub-millisecond sleeps (
SleepThread) wait on the timer instead, as Windows already does on 6-thread CPUs since #2263.What it costs today
With #2602, Hyrule Field (RTX 3090, Ryzen 9 7900X, 24 threads, Linux, default options):
ModuleSystemWorkerthreads andsead::MainThreadyield for 3.3-3.6 ms a frame each insleep_away. That is about 9 ms of CPU a frame in all, while one of them waits on a GPU readback.sleep_nsnever counts the processors, so every sleep under a millisecond is a yield loop (host/hos_thread.c).The change
On Linux, when
HOS_SHORT_SLEEP_TIMERis not set, the game's own short sleeps wait on the timer (mode 1). The host's own short sleeps (the frame limiter, the audio renderer) keep yielding, so frame pacing is unchanged.HOS_SHORT_SLEEP_TIMER=0: all yield, as before.HOS_SHORT_SLEEP_TIMER=1: all on the timer.Measured
Hyrule Field, one run each, all sleeps on the timer (
HOS_SHORT_SLEEP_TIMER=1, mode 2, which also moves the host's sleeps). This PR's default (mode 1) has not been run yet.HOS_CHAIN). #2263 found TOTK's 20 µs waits on its critical path with the timer for all sleeps, which is why this changes only the game's own sleeps.Tested
tests/test_short_sleep_timer.pypasses. It covershos_short_sleep_timeritself, which is unchanged; the new Linux default is in its caller.Not yet tested
Measured after the merge, on main with this change: one alternating pair in Hyrule Field (uncapped, RTX on Linux/Wayland, 15 s measured after a 20 s settle), default against
HOS_SHORT_SLEEP_TIMER=0(the old behaviour).HOS_SHORT_SLEEP_TIMER=0HOS_SHORT_SLEEP_TIMER=0is the switch to compare with, and a report here would help.github-sync referenced this pull request2026-11-12 06:22:54 +00:00