Repository navigation
perf(libc): set TZ once on Linux - #2031
Conversation
Without TZ, glibc's localtime and mktime run tzset on every call and re-check /etc/localtime each time. PPSA28997 calls them every frame during its intro, which then spent most of its time there. TZ is set to :/etc/localtime when unset, so the zone is read once.
|
The optimization and evidence are Linux/glibc-specific, but |
|
Agreed. The initializer is now behind |
MarcZX10
left a comment
There was a problem hiding this comment.
Thanks for limiting the initializer to __linux__. I built exact head 631654b6 on Linux with GCC 12 and ran guest_time_conversion with TZ unset; it passed 1/1 in 0.46 s. Conventions and git diff --check pass. GitHub currently reports no checks on this head, so please get the required CI jobs running (or have a maintainer approve any held workflow) before merge. I will hold approval until checks are visible.
|
Could you add numbers for the PPSA28997 intro, main against main plus this (fps or frame time over a few runs)? Perf changes need before/after figures for the change itself (#218). |
|
PPSA28997, Linux (CachyOS, kernel 7.2), GCC, same build with and without this change: the time from the Sony logo to the Santa Monica logo drops from about 2 minutes to about 15–20 seconds, which is normal speed. Without it, the intro plays far below speed the whole time because |
|
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
No title was run. 🤖 Addressed by Claude Code |
|
Checked the diff against glibc ( |
perf(libc): set TZ once on Linux
What
Without
TZ, glibc'slocaltimeandmktimeruntzseton every call, and eachtzsetre-checks/etc/localtime. PPSA28997 (God of War Sons of Sparta) calls them every frame during its intro, which then spent most of its time there and played back far below speed. libc now setsTZto:/etc/localtimewhen it is unset and callstzsetonce at load, so the zone file is read once. ATZset by the user is left as it is. Windows is unchanged.Tested
tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)