perf(libc): set TZ once on Linux #2031
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2031"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T05:31:41Z.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T05:37:14Z.
The optimization and evidence are Linux/glibc-specific, but
#ifndef _WIN32also runs this initializer on macOS. That changes the process environment there and forces an explicit/etc/localtimezone-file path without Darwin validation. Could you gate this with__linux__(or provide a macOS behavior test and evidence) so the change only affects the platform described in the PR? I’m holding approval pending that.Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T05:47:01Z.
Agreed. The initializer is now behind
#ifdef __linux__, so macOS and Windows are unchanged and the change only affects the platform the PR describes.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T05:55:37Z.
Review: COMMENTED
Thanks for limiting the initializer to
__linux__. I built exact head631654b6on Linux with GCC 12 and ranguest_time_conversionwithTZunset; it passed 1/1 in 0.46 s. Conventions andgit diff --checkpass. 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.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:50Z.
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).
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T10:36:58Z.
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
localtime/mktimere-read the zone each frame.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:46:15Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
631654b6, merged ontomaind70b8998in one build with 38 other PRs that had no Windows run.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:08:25Z.
Checked the diff against glibc (
tzset_internalhas no early return whenTZis unset, so everylocaltime/mktimere-reads the zone file), built the libc tests on Linux and ran them (42/43;guest_time_conversionpasses, the one not run isguest_wcsrtombs, whose executable isn't in the scoped build). Numbers for PPSA28997 are in the thread, Linux-only gating is in, and Windows builds per @popcoder565. Merging.