WIP: perf(vi): the vsync ticker waits on a high-resolution timer instead of yielding #1235

Draft
Molier wants to merge 1 commit from Molier/Longshot:perf/vsync-ticker-timer into main
First-time contributor

Type: perf · Risk: low · Tested on: Linux (CachyOS, kernel 7.4.0-rc1), Ryzen 7 5800X, 32 GB, Radeon RX 9070 XT, RADV (Mesa 26.2.6), gamescope; host-only synthetic test (posix shim) · Needs: Windows (its own CreateWaitableTimerExW; only the posix shim ran here), Intel, NVIDIA, a Steam Deck

Why

The vsync ticker (vsync_main in host/nn_vi.c) advances the frame-rate cap's clock on its own thread. Its wait went through hos_sleep_ns, which yields in a loop for anything under a millisecond (host/hos_thread.c). Uncapped, the ticker's period is 1 ms, so that spun a whole core doing no work. The game's own sleeps already wait on a high-resolution waitable timer; the ticker's wait did not use it.

What changed

The ticker now waits on a thread-local high-resolution waitable timer instead of yielding, and falls back to the old yield wait when the timer cannot be made. A switch restores the old wait.

  • host/nn_vi.c: vsync_wait_ns creates once per thread (_Thread_local) and waits on a CreateWaitableTimerExW high-resolution timer, arms it with SetWaitableTimerEx, and blocks in WaitForSingleObject; if no timer was made or SetWaitableTimerEx fails, it calls hos_sleep_ns. vsync_sleep picks the timer wait or the yield loop by HOS_VSYNC_YIELD; vsync_main's single wait call per tick now goes through vsync_sleep.
  • docs/development.md: the switch's row in the switch table.

Measurements

Verdict: At 1440p the switch lowers median frame time on the moving legs of the Hyrule Field route: -4.3% (17.87 -> 17.11 ms) and -5.2% (18.06 -> 17.12 ms), each beyond the 3-vs-3 run noise band. The load leg (-2.1%) and the 800p rerun are inside noise either way; no regression measured. Host-only, over 2,000 ticks of a 1 ms period, the ticker thread's own CPU use drops from 99.9% of a core (yield) to 1.9% (timer), at a cost of 0.079 ms mean lateness per tick against 0.001 ms.

Baseline: one build of nightly-189 (main @ aa95d35f) plus local patches (this change among them), with HOS_VSYNC_YIELD=1 in one arm and unset in the other. It is not main against this PR, and it is 150+ commits behind current main; the run on current main is listed under Must be tested.

Hardware: Linux (CachyOS, kernel 7.4.0-rc1), Ryzen 7 5800X, 32 GB, Radeon RX 9070 XT, RADV (Mesa 26.2.6), gamescope
Scene: hf48run — a save in Hyrule Field, the character running a fixed route, 1440p output, render scale 1, frame generation off, uncapped; plus an 800p rerun of the same route.
Method: median frame time per segment (run_a, run_b, load), averaged over 3 runs per arm, interleaved (on, off, on, off, ...) after a warm-up; a claim is "beyond noise" only when every on-run beats every off-run (non-overlapping 3-vs-3 ranges). The ticker thread's own CPU use and lateness come from a host-only synthetic run of the real wait path (posix shim, 2,000 ticks of a 1 ms period).
How to reproduce: the hf48run save and route above, HOS_VSYNC_YIELD=1 (off) against unset (on, the default), 3 or more interleaved runs, uncapped.

median frame time, 1440p, avg of 3 runs/arm HOS_VSYNC_YIELD=1: nightly-189 + local patches Unset (timer): same build Δ beyond noise?
run_a 17.87 ms 17.11 ms -4.3% yes: on 16.95-17.30 ms, off 17.67-18.23 ms (no overlap)
run_b 18.06 ms 17.12 ms -5.2% yes: on 16.57-17.65 ms, off 17.76-18.31 ms (no overlap)
load (teleport) 17.49 ms 17.13 ms -2.1% no: on 16.80-17.72 ms, off 17.33-17.61 ms (overlap)
800p rerun, run_a / run_b / load 17.51 / 17.59 / 16.03 ms 17.97 / 17.94 / 15.48 ms nominally worse on 2 of 3 no: all three overlap

Host-only, same build:

2,000 ticks of a 1 ms period HOS_VSYNC_YIELD=1: nightly-189 + local patches Unset (timer): same build
ticker thread CPU use 99.9% of a core 1.9% of a core
mean lateness per tick 0.001 ms 0.079 ms
spinner check (top -H -b, uncapped switch-on run): no thread at or above ~9% of a core except the main thread during a load burst (87.8%); nothing like the old yield loop's signature
game clock speed samples, same run: 0.966, 0.991, 1.001, 0.999, 1.005, 1.011, 0.998, 1.000 (all but the boot-time 0.966 in the 0.99-1.01 band)
host-only synthetic (2,000 x 1 ms ticks): yield 99.9% of a core, mean late 0.001 ms; timer 1.9% of a core, mean late 0.079 ms

Flags and settings

One new switch, on by default (the timer path).

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
HOS_VSYNC_YIELD=1 Makes the vsync ticker keep the old yield-loop wait under a millisecond n/a (the yield loop was the only path) opts out of the new high-resolution-timer wait restores the core-spinning wait helps: none (it is the slower path); untested: Windows, AMD/Intel/NVIDIA, Steam Deck off: only if the timer path misbehaves on some system

Testing

Tested: Linux (CachyOS, kernel 7.4.0-rc1), Ryzen 7 5800X, Radeon RX 9070 XT, RADV (Mesa 26.2.6), gamescope: the hf48run route above (3 interleaved runs per arm at 1440p, one rerun at 800p), the spinner check and the game-clock speed check. A host-only compile against the real host/nn_vi.c build flags (-fsyntax-only, real generated headers) passes, and the host-only synthetic wait test (2,000 ticks of a 1 ms period) runs clean.

Not tested: Windows' own CreateWaitableTimerExW (only the posix shim was exercised here); Intel and NVIDIA GPUs (this machine is RADV); a Steam Deck or other low-power device, where the yield-versus-timer trade-off may differ; python -I -B tests/run_all.py was not run in full on this rebase.

Must be tested:

  • main @ ac778751 against this PR @ 2435256a, 2 interleaved runs each: the hf48run route at 1440p with default settings, expecting the frame-time result above to hold against a real main build.
  • Windows, any GPU: the same moving outdoor route at 1440p, HOS_VSYNC_YIELD=1 against unset, 3 or more interleaved runs each, expecting the same gain on the moving legs and no regression (Test Farm: @Beanstalk windows, a moving-route A/B with and without HOS_VSYNC_YIELD=1).
  • Intel or NVIDIA on Linux: the same route and switch, expecting no regression (Test Farm: @Beanstalk linux).
  • Steam Deck: the same at its default lower cap, expecting no regression (Test Farm: @Beanstalk steamdeck).

Risks

What could break: If CreateWaitableTimerExW/SetWaitableTimerEx misbehaves on a driver or kernel (a wrong wakeup time, a timer that never fires), the ticker's clock would drift or stall, which paces every frame's present. The code falls back to hos_sleep_ns whenever the timer cannot be made, so a system where the call itself fails is unaffected; a system where it succeeds but behaves wrongly is not covered by the testing above.

Turning it off: HOS_VSYNC_YIELD=1, or revert the commit.

Compatibility: Nothing changes: no save, option, cache or ABI change.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks. Not ticked yet: Testing says the yield-versus-timer trade-off on a Steam Deck or low-power device was not measured.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). Not run in full on this rebase; the PR's own tests pass (named in Testing).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • Docs updated.
**Type:** perf · **Risk:** low · **Tested on:** Linux (CachyOS, kernel 7.4.0-rc1), Ryzen 7 5800X, 32 GB, Radeon RX 9070 XT, RADV (Mesa 26.2.6), gamescope; host-only synthetic test (posix shim) · **Needs:** Windows (its own `CreateWaitableTimerExW`; only the posix shim ran here), Intel, NVIDIA, a Steam Deck ## Why The vsync ticker (`vsync_main` in `host/nn_vi.c`) advances the frame-rate cap's clock on its own thread. Its wait went through `hos_sleep_ns`, which yields in a loop for anything under a millisecond (`host/hos_thread.c`). Uncapped, the ticker's period is 1 ms, so that spun a whole core doing no work. The game's own sleeps already wait on a high-resolution waitable timer; the ticker's wait did not use it. ## What changed The ticker now waits on a thread-local high-resolution waitable timer instead of yielding, and falls back to the old yield wait when the timer cannot be made. A switch restores the old wait. - `host/nn_vi.c`: `vsync_wait_ns` creates once per thread (`_Thread_local`) and waits on a `CreateWaitableTimerExW` high-resolution timer, arms it with `SetWaitableTimerEx`, and blocks in `WaitForSingleObject`; if no timer was made or `SetWaitableTimerEx` fails, it calls `hos_sleep_ns`. `vsync_sleep` picks the timer wait or the yield loop by `HOS_VSYNC_YIELD`; `vsync_main`'s single wait call per tick now goes through `vsync_sleep`. - `docs/development.md`: the switch's row in the switch table. ## Measurements **Verdict:** At 1440p the switch lowers median frame time on the moving legs of the Hyrule Field route: -4.3% (17.87 -> 17.11 ms) and -5.2% (18.06 -> 17.12 ms), each beyond the 3-vs-3 run noise band. The load leg (-2.1%) and the 800p rerun are inside noise either way; no regression measured. Host-only, over 2,000 ticks of a 1 ms period, the ticker thread's own CPU use drops from 99.9% of a core (yield) to 1.9% (timer), at a cost of 0.079 ms mean lateness per tick against 0.001 ms. Baseline: one build of nightly-189 (main @ aa95d35f) plus local patches (this change among them), with `HOS_VSYNC_YIELD=1` in one arm and unset in the other. It is not main against this PR, and it is 150+ commits behind current main; the run on current main is listed under Must be tested. Hardware: Linux (CachyOS, kernel 7.4.0-rc1), Ryzen 7 5800X, 32 GB, Radeon RX 9070 XT, RADV (Mesa 26.2.6), gamescope Scene: `hf48run` — a save in Hyrule Field, the character running a fixed route, 1440p output, render scale 1, frame generation off, uncapped; plus an 800p rerun of the same route. Method: median frame time per segment (`run_a`, `run_b`, `load`), averaged over 3 runs per arm, interleaved (on, off, on, off, ...) after a warm-up; a claim is "beyond noise" only when every on-run beats every off-run (non-overlapping 3-vs-3 ranges). The ticker thread's own CPU use and lateness come from a host-only synthetic run of the real wait path (posix shim, 2,000 ticks of a 1 ms period). How to reproduce: the `hf48run` save and route above, `HOS_VSYNC_YIELD=1` (off) against unset (on, the default), 3 or more interleaved runs, uncapped. | median frame time, 1440p, avg of 3 runs/arm | `HOS_VSYNC_YIELD=1`: nightly-189 + local patches | Unset (timer): same build | Δ | beyond noise? | |---|---|---|---|---| | `run_a` | 17.87 ms | 17.11 ms | -4.3% | yes: on 16.95-17.30 ms, off 17.67-18.23 ms (no overlap) | | `run_b` | 18.06 ms | 17.12 ms | -5.2% | yes: on 16.57-17.65 ms, off 17.76-18.31 ms (no overlap) | | `load` (teleport) | 17.49 ms | 17.13 ms | -2.1% | no: on 16.80-17.72 ms, off 17.33-17.61 ms (overlap) | | 800p rerun, `run_a` / `run_b` / `load` | 17.51 / 17.59 / 16.03 ms | 17.97 / 17.94 / 15.48 ms | nominally worse on 2 of 3 | no: all three overlap | Host-only, same build: | 2,000 ticks of a 1 ms period | `HOS_VSYNC_YIELD=1`: nightly-189 + local patches | Unset (timer): same build | |---|---|---| | ticker thread CPU use | 99.9% of a core | 1.9% of a core | | mean lateness per tick | 0.001 ms | 0.079 ms | ``` spinner check (top -H -b, uncapped switch-on run): no thread at or above ~9% of a core except the main thread during a load burst (87.8%); nothing like the old yield loop's signature game clock speed samples, same run: 0.966, 0.991, 1.001, 0.999, 1.005, 1.011, 0.998, 1.000 (all but the boot-time 0.966 in the 0.99-1.01 band) host-only synthetic (2,000 x 1 ms ticks): yield 99.9% of a core, mean late 0.001 ms; timer 1.9% of a core, mean late 0.079 ms ``` ### Flags and settings One new switch, on by default (the timer path). | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `HOS_VSYNC_YIELD=1` | Makes the vsync ticker keep the old yield-loop wait under a millisecond | n/a (the yield loop was the only path) | opts out of the new high-resolution-timer wait | restores the core-spinning wait | helps: none (it is the slower path); untested: Windows, AMD/Intel/NVIDIA, Steam Deck | off: only if the timer path misbehaves on some system | ## Testing **Tested:** Linux (CachyOS, kernel 7.4.0-rc1), Ryzen 7 5800X, Radeon RX 9070 XT, RADV (Mesa 26.2.6), gamescope: the `hf48run` route above (3 interleaved runs per arm at 1440p, one rerun at 800p), the spinner check and the game-clock speed check. A host-only compile against the real `host/nn_vi.c` build flags (`-fsyntax-only`, real generated headers) passes, and the host-only synthetic wait test (2,000 ticks of a 1 ms period) runs clean. **Not tested:** Windows' own `CreateWaitableTimerExW` (only the posix shim was exercised here); Intel and NVIDIA GPUs (this machine is RADV); a Steam Deck or other low-power device, where the yield-versus-timer trade-off may differ; `python -I -B tests/run_all.py` was not run in full on this rebase. **Must be tested:** - main @ ac778751 against this PR @ 2435256a, 2 interleaved runs each: the `hf48run` route at 1440p with default settings, expecting the frame-time result above to hold against a real main build. - Windows, any GPU: the same moving outdoor route at 1440p, `HOS_VSYNC_YIELD=1` against unset, 3 or more interleaved runs each, expecting the same gain on the moving legs and no regression (Test Farm: @Beanstalk windows, a moving-route A/B with and without `HOS_VSYNC_YIELD=1`). - Intel or NVIDIA on Linux: the same route and switch, expecting no regression (Test Farm: @Beanstalk linux). - Steam Deck: the same at its default lower cap, expecting no regression (Test Farm: @Beanstalk steamdeck). ## Risks **What could break:** If `CreateWaitableTimerExW`/`SetWaitableTimerEx` misbehaves on a driver or kernel (a wrong wakeup time, a timer that never fires), the ticker's clock would drift or stall, which paces every frame's present. The code falls back to `hos_sleep_ns` whenever the timer cannot be made, so a system where the call itself fails is unaffected; a system where it succeeds but behaves wrongly is not covered by the testing above. **Turning it off:** `HOS_VSYNC_YIELD=1`, or revert the commit. **Compatibility:** Nothing changes: no save, option, cache or ABI change. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [ ] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. Not ticked yet: Testing says the yield-versus-timer trade-off on a Steam Deck or low-power device was not measured. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). Not run in full on this rebase; the PR's own tests pass (named in Testing). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] Docs updated.
perf(vi): the vsync ticker waits on a high-resolution timer, not the yield loop (HOS_VSYNC_YIELD=1 turns it off)
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
2435256a9e
The ticker (vsync_main) slept through hos_sleep_ns, which under a millisecond yields in a loop: uncapped (1 ms period) it used a core. It now waits on a thread-local high-resolution waitable timer, as sleep_ns does for the game's own sleeps; the timer cannot be made: hos_sleep_ns as before. HOS_VSYNC_YIELD=1: the old path.

Measured host-only (posix shim, the real vsync_sleep, 2000 ticks of 1 ms): timer 1.9 % of a core, mean late 0.079 ms; yield 99.9 %, mean late 0.001 ms.

Assisted-by: Claude (Anthropic)
Author
First-time contributor

Tested in game: this commit has been part of the local build the measurements come from (Linux, CachyOS, Ryzen 7 5800X, RX 9070 XT, RADV Mesa 26.2.6, gamescope) since 2026-11-16, on nightly-189 and then nightly-338 bases: several hours of the two benchmark routes (uncapped and capped 60) and a short play session (about 15 minutes) at 4K. The game clock stayed in the 0.99-1.01 band (samples in the description) and no thread spins at the ticker's period. Not run: this branch built from its own commit on current main, and Windows.

Tested in game: this commit has been part of the local build the measurements come from (Linux, CachyOS, Ryzen 7 5800X, RX 9070 XT, RADV Mesa 26.2.6, gamescope) since 2026-11-16, on nightly-189 and then nightly-338 bases: several hours of the two benchmark routes (uncapped and capped 60) and a short play session (about 15 minutes) at 4K. The game clock stayed in the 0.99-1.01 band (samples in the description) and no thread spins at the ticker's period. Not run: this branch built from its own commit on current main, and Windows.
Member

Windows numbers for this, since the description asks for them. I had found the same spinning thread in a played session (an unnamed thread at 97-101 % of a core for as long as the cap was Uncapped; its start address is vsync_main in the build's map) and was about to write the same fix when I found this PR.

Verdict: on Windows the ticker's own CPU goes from 96-97 % of a core to under 0.5 %, and the whole game's CPU from about 6.1 to 4.8 cores. The frame rate is the same within the runs' spread, on all cores and held to four. The game clock's speed is 1.000 on both sides. No regression seen.

Hardware: Windows 11 Pro 26200, Ryzen 9 9950X3D (16 cores, SMT off; the game's threads on the 8 cores of the larger cache, as the log says), 32 GB, RTX 4070 SUPER 12 GB, NVIDIA 617.42
Build: this PR's head, longshot v3.0.0-rc.5-41-g2435256a, clean tree, built here with clang for the MSVC target (so Windows' own CreateWaitableTimerExW, not the shim)
Scene: Castle Town, the walk from the south gate into the market, the turns and the walk back (a scripted route on the wall clock, 100 s), 2560x1440, DLAA, frame generation off, uncapped (HOS_FPS_MAX=1000)
Method: one build, HOS_VSYNC_YIELD=1 against unset, the two in turn, three runs each; headless. Frame figures from the frame trace (RX_VK_FRAME_TRACE=1, both sides) from 40 s on. CPU: every thread's CPU time read from outside over 20 s of the route (from 60 s on), nothing in the process touched. Then the same with the process held to four cores (affinity 0xF); there the log says "the game's sleeps under a millisecond wait on the timer ... (4 logical processors", so only the host's own short sleeps still yield.

All cores:

HOS_VSYNC_YIELD=1: this PR @ 2435256a Unset (the timer): this PR @ 2435256a
fps, three runs 60.5, 61.1, 70.3 57.3, 61.6, 69.2
fps, median 61.1 61.6
Median frame, median of the runs 15.59 ms 15.59 ms
99th percentile frame 26.75, 25.56, 24.35 ms 28.75, 25.52, 25.08 ms
The ticker thread (vsync_main) 97, 97, 96 % of a core not among the busiest six; 0 % (under 0.5 %) in a fourth run that listed every thread
All of the game's threads together 611, 617, 587 % of a core 478, 482, 510 %
Game clock speed in the world (HOS_FPS_LOG), median 1.001, 1.000, 1.000 1.000, 0.999, 1.000

Held to four cores:

HOS_VSYNC_YIELD=1: this PR @ 2435256a Unset (the timer): this PR @ 2435256a
fps, three runs 51.4, 51.2, 62.4 62.9, 51.5, 53.8
fps, median 51.4 53.8
Median frame, median of the runs 18.68 ms 17.83 ms
Frames over 25 ms (of about 2,600-3,200) 193, 198, 134 80, 229, 152
The ticker thread 24, 24, 29 % of a core not among the busiest six
All of the game's threads together 345, 347, 335 % of a core 305, 311, 318 %
Game clock speed in the world, median 0.999, 1.000, 1.000 1.000, 1.002, 0.999

What I would not claim from this: a frame rate gain. This route does not show the same view every run: one run in three on each side sat in lighter views (about 1,950-2,000 draws a frame in the log's windows against 2,250-2,320), and those are the 62-70 fps ones. Like for like the sides are level: on all cores 60.5 and 61.1 against 57.3 and 61.6 in the heavier views and 70.3 against 69.2 in the lighter; on four cores 51.4 and 51.2 against 51.5 and 53.8, and 62.4 against 62.9. The CPU saving is there in every run.

One thing for the reviewers rather than a request: host/hos_thread.c's sleep_ns already holds this timer (one per thread, with the same fallback), so the ticker could ask it for "the timer whatever the length" instead of keeping a second copy in nn_vi.c. I had it that way locally, with cases added to tests/test_short_sleep_timer.py; glad to send those if useful.

🤖 Generated with Claude Code

Windows numbers for this, since the description asks for them. I had found the same spinning thread in a played session (an unnamed thread at 97-101 % of a core for as long as the cap was Uncapped; its start address is `vsync_main` in the build's map) and was about to write the same fix when I found this PR. **Verdict:** on Windows the ticker's own CPU goes from 96-97 % of a core to under 0.5 %, and the whole game's CPU from about 6.1 to 4.8 cores. The frame rate is the same within the runs' spread, on all cores and held to four. The game clock's speed is 1.000 on both sides. No regression seen. Hardware: Windows 11 Pro 26200, Ryzen 9 9950X3D (16 cores, SMT off; the game's threads on the 8 cores of the larger cache, as the log says), 32 GB, RTX 4070 SUPER 12 GB, NVIDIA 617.42 Build: this PR's head, `longshot v3.0.0-rc.5-41-g2435256a`, clean tree, built here with clang for the MSVC target (so Windows' own `CreateWaitableTimerExW`, not the shim) Scene: Castle Town, the walk from the south gate into the market, the turns and the walk back (a scripted route on the wall clock, 100 s), 2560x1440, DLAA, frame generation off, uncapped (`HOS_FPS_MAX=1000`) Method: one build, `HOS_VSYNC_YIELD=1` against unset, the two in turn, three runs each; headless. Frame figures from the frame trace (`RX_VK_FRAME_TRACE=1`, both sides) from 40 s on. CPU: every thread's CPU time read from outside over 20 s of the route (from 60 s on), nothing in the process touched. Then the same with the process held to four cores (affinity `0xF`); there the log says "the game's sleeps under a millisecond wait on the timer ... (4 logical processors", so only the host's own short sleeps still yield. All cores: | | `HOS_VSYNC_YIELD=1`: this PR @ 2435256a | Unset (the timer): this PR @ 2435256a | |---|---|---| | fps, three runs | 60.5, 61.1, 70.3 | 57.3, 61.6, 69.2 | | fps, median | 61.1 | 61.6 | | Median frame, median of the runs | 15.59 ms | 15.59 ms | | 99th percentile frame | 26.75, 25.56, 24.35 ms | 28.75, 25.52, 25.08 ms | | The ticker thread (`vsync_main`) | 97, 97, 96 % of a core | not among the busiest six; 0 % (under 0.5 %) in a fourth run that listed every thread | | All of the game's threads together | 611, 617, 587 % of a core | 478, 482, 510 % | | Game clock speed in the world (`HOS_FPS_LOG`), median | 1.001, 1.000, 1.000 | 1.000, 0.999, 1.000 | Held to four cores: | | `HOS_VSYNC_YIELD=1`: this PR @ 2435256a | Unset (the timer): this PR @ 2435256a | |---|---|---| | fps, three runs | 51.4, 51.2, 62.4 | 62.9, 51.5, 53.8 | | fps, median | 51.4 | 53.8 | | Median frame, median of the runs | 18.68 ms | 17.83 ms | | Frames over 25 ms (of about 2,600-3,200) | 193, 198, 134 | 80, 229, 152 | | The ticker thread | 24, 24, 29 % of a core | not among the busiest six | | All of the game's threads together | 345, 347, 335 % of a core | 305, 311, 318 % | | Game clock speed in the world, median | 0.999, 1.000, 1.000 | 1.000, 1.002, 0.999 | What I would not claim from this: a frame rate gain. This route does not show the same view every run: one run in three on each side sat in lighter views (about 1,950-2,000 draws a frame in the log's windows against 2,250-2,320), and those are the 62-70 fps ones. Like for like the sides are level: on all cores 60.5 and 61.1 against 57.3 and 61.6 in the heavier views and 70.3 against 69.2 in the lighter; on four cores 51.4 and 51.2 against 51.5 and 53.8, and 62.4 against 62.9. The CPU saving is there in every run. One thing for the reviewers rather than a request: `host/hos_thread.c`'s `sleep_ns` already holds this timer (one per thread, with the same fallback), so the ticker could ask it for "the timer whatever the length" instead of keeping a second copy in `nn_vi.c`. I had it that way locally, with cases added to `tests/test_short_sleep_timer.py`; glad to send those if useful. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Owner

Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).

  • Tested on my own PC: ticked: The author's comment: the build ran for hours on their own Linux Radeon RX 9070 XT machine, on benchmark routes and play.
  • Nothing gets worse that I know of: not ticked: Testing says the yield-versus-timer trade-off on a Steam Deck or low-power device was not measured. Measure that cost and state it in Risks, then tick it.
Brought up to the [ready-for-review standard](https://git.magicbean.dev/MagicBeanDev/Longshot/src/branch/main/CONTRIBUTING.md#ready-for-review-out-of-wip) (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know). - *Tested on my own PC*: ticked: The author's comment: the build ran for hours on their own Linux Radeon RX 9070 XT machine, on benchmark routes and play. - *Nothing gets worse that I know of*: not ticked: Testing says the yield-versus-timer trade-off on a Steam Deck or low-power device was not measured. Measure that cost and state it in Risks, then tick it.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vsync-ticker-timer:Molier-perf/vsync-ticker-timer'
git switch 'Molier-perf/vsync-ticker-timer'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!1235
No description provided.