[perf] Win32 StartSync busy-spins one core at 100% when not updating (Window.cpp) #134

Closed
opened 2026-06-17 21:18:56 +02:00 by jorijnvdgraaf · 0 comments

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).

Location: implementations/Crafter.Graphics-Window.cpp:700-713
Severity: medium · Effort: trivial · Category: cpu

Problem

When updating is false (paused/minimized/stopped), the PeekMessage(PM_REMOVE) loop pins one core at 100%, repeatedly running Gamepad::Tick() (mutex + per-pad GetCurrentReading COM call) + onBeforeUpdate. (When updating, FIFO present paces the loop, so per-frame polling is correctly vsync-gated — the "decoupled" concern there was refuted.)

Fix

Block on MsgWaitForMultipleObjectsEx / WaitMessage while !updating.

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass). **Location:** `implementations/Crafter.Graphics-Window.cpp:700-713` **Severity:** medium · **Effort:** trivial · **Category:** cpu ### Problem When `updating` is false (paused/minimized/stopped), the `PeekMessage(PM_REMOVE)` loop pins one core at 100%, repeatedly running `Gamepad::Tick()` (mutex + per-pad `GetCurrentReading` COM call) + `onBeforeUpdate`. (When updating, FIFO present paces the loop, so per-frame polling is correctly vsync-gated — the "decoupled" concern there was refuted.) ### Fix Block on `MsgWaitForMultipleObjectsEx` / `WaitMessage` while `!updating`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
Catcrafts/Crafter.Graphics#134
No description provided.