From a24ffea86eb57ad630011644a26febc95021adde Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 13 Oct 2026 18:16:50 -0500 Subject: [PATCH] perf(startup): let Windows relax the system timer resolution On Windows SDL3 raises the global timer resolution with timeBeginPeriod(1) and holds it for the whole process lifetime, which keeps the system on a 1 ms tick and costs power for no benefit here. - A startup hint now asks SDL to leave the system timer alone. Nothing in the app needs sub-15 ms waits: vsync paces drawing, the idle wait is 200 ms, and background sleeps are 50 ms or longer. The hint is Windows-only in effect and is ignored elsewhere; an environment override that turns it off is harmless. Co-Authored-By: Claude Opus 4.8 --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 9e3418a..08abdd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2428,6 +2428,10 @@ int main(int argc, char* argv[]) static bool InitSDL() { + // SDL3 otherwise holds timeBeginPeriod(1) for the process lifetime on Windows. Nothing here needs + // sub-15 ms waits (vsync pacing, the 200 ms idle wait, >=50 ms thread sleeps), so let the system + // timer relax. Ignored on non-Windows platforms; a false return (env override) is harmless. + SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0"); if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) { fprintf(stderr, "Error: SDL_Init(): %s\n", SDL_GetError()); return false;