Skip to content

[perf/fight-frames] VU0 FMAC inlined; the frame pacer on a waitable timer on Windows - #138

Merged
Arzaroth merged 3 commits into
masterfrom
perf/fight-frames
Nov 24, 2026
Merged

Arzaroth merged 3 commits into
masterfrom
perf/fight-frames

Conversation

@Arzaroth

Copy link
Copy Markdown
Contributor

Frame-time work for TheBozos/SoulCaliburIII_Recomp#15 (fights below 60 game frames/s on a Ryzen 7 3800X; menus at 55 under Proton Experimental with fsync).

Layers:

  1. refactor(vu0): the field-by-field FMAC paths as named functions (no behaviour change).
  2. perf(vu0): the four-field FMAC shortcut (madd, mul, add, sub) always inlined at every call, sources by reference; the rare exact path stays out of line. These were real calls from both the generated code and the VU0 microprogram interpreter.
  3. fix(app): bozo::app::sleepUntil sleeps on a high-resolution waitable timer on Windows (falling back to a plain waitable timer, then sleep_until); the frame pacer and the window thread use it. Under Proton Experimental with fsync, sleep_until overslept by up to 13 ms and a 60 cap ran at 52-57.

Measured with Soulcalibur III (game-thread work per frame, PS2X_FRAME_STATS=1, Tales of Souls fight on a Ryzen 7 7800X3D): 6.9 ms on this master, 6.45 ms with layer 2; the game's own mesh changes take it to 5.2 ms. A standalone pacer loop under Proton Experimental + fsync: 55 -> 60.00 frames/s. The game's headless US route record (calls, threads, sound, draw-list hashes) is identical on every frame after every layer. 58 tests pass at each layer.

🤖 Generated with Claude Code

Arzaroth and others added 3 commits November 24, 2026 09:55
… functions

add, sub, mul, madd and msub keep their SIMD shortcut and hand the other
cases to addExact, subExact, mulExact, maddExact and msubExact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… every call

add, sub, mul, madd and msub were real calls from the generated code
(built at -O1) and from the port's microprograms. They are now
always_inline with their sources by reference, and the field-by-field
paths stay out of line, so only the rare exact case pays for a call.

Tales of Souls fight (PAL60, Valentine Mansion), headless game-thread
work: 7.42 -> 6.30 ms a frame. The US route's record is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FramePacer::frameEnd and the window's own present schedule slept with
std::this_thread::sleep_until, which MinGW turns into nanosleep. Under
Proton Experimental with fsync that oversleeps by up to 13 ms, so a game
with 1 ms of work a frame ran its menus at 55 frames a second while the
presents held 60. bozo::app::sleepUntil waits on a high-resolution
waitable timer instead (a plain one where that kind is missing, then
sleep_until); other systems keep sleep_until.

PAL sc3.exe under Proton Experimental with fsync, menus: 58.6 -> 59.95
game frames a second (a standalone pacer loop: 55 -> 60.00).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Arzaroth
Arzaroth merged commit 0a2459a into master Nov 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant