fix(tests): let the TZ flipper of the zone race yield #8288

Merged
mugurc merged 1 commit from upstream-pr/8288 into main 2026-10-24 01:23:45 +00:00
mugurc commented 2026-10-20 09:00:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mugurc on 2026-10-20T09:00:53Z.


What

guest_time_conversion (#6916) times out on macOS. Its zone race changes TZ in a tight loop while six threads convert times, and on macOS the flipper keeps the guest environment lock: the default mutex there lets the thread that unlocks take the lock again before a woken waiter runs. The readers spend their time waiting on the zone and environment locks, and the test runs for 21 seconds, past its 20-second timeout. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).

The flipper now yields after each change. The readers still see TZ change under them all the time, so the race checks the same thing, and the test takes about a second on macOS.

Tested

macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS without the rest of the macOS series, so the run is on main 3fd1cc393 with the series (ci/macos-series-2 on my fork), #8279, #8284, #8287, the open macOS fixes #7524 and #7937, and three changes from #7332.

  • A sample profile of the test: the readers spend about 90% of their samples waiting, in ZoneScope on the zone lock or in CopyGuestEnvironment_nid_no_patch on the environment lock. The flipper spends nearly half of its samples waking waiters when it unlocks.
  • Counters added for one run, not in this PR. With the tight loop, the flipper changed TZ about 373 million times while the readers made their 15,000 localtime_s calls, and the run took 39 seconds. With the yield, it changes TZ about 800,000 times, and the readers get each of the two offsets in about half of their calls, over three runs (7,427/7,573, 7,472/7,528 and 7,522/7,478). No conversion was torn in any run.
  • guest_time_conversion passes 5 runs of 5 under its 20-second timeout, in 0.5 to 1.3 seconds.
  • Linux and Windows: not run. The change is in the test only, and the yield does not change what the readers check.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4933472305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8288). Originally posted by [mugurc](https://github.com/mugurc) on 2026-10-20T09:00:53Z. --- ### What `guest_time_conversion` (#6916) times out on macOS. Its zone race changes TZ in a tight loop while six threads convert times, and on macOS the flipper keeps the guest environment lock: the default mutex there lets the thread that unlocks take the lock again before a woken waiter runs. The readers spend their time waiting on the zone and environment locks, and the test runs for 21 seconds, past its 20-second timeout. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298). The flipper now yields after each change. The readers still see TZ change under them all the time, so the race checks the same thing, and the test takes about a second on macOS. ### Tested macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS without the rest of the macOS series, so the run is on `main` 3fd1cc393 with the series (`ci/macos-series-2` on my fork), #8279, #8284, #8287, the open macOS fixes #7524 and #7937, and three changes from #7332. - A `sample` profile of the test: the readers spend about 90% of their samples waiting, in `ZoneScope` on the zone lock or in `CopyGuestEnvironment_nid_no_patch` on the environment lock. The flipper spends nearly half of its samples waking waiters when it unlocks. - Counters added for one run, not in this PR. With the tight loop, the flipper changed TZ about 373 million times while the readers made their 15,000 `localtime_s` calls, and the run took 39 seconds. With the yield, it changes TZ about 800,000 times, and the readers get each of the two offsets in about half of their calls, over three runs (7,427/7,573, 7,472/7,528 and 7,522/7,478). No conversion was torn in any run. - `guest_time_conversion` passes 5 runs of 5 under its 20-second timeout, in 0.5 to 1.3 seconds. - Linux and Windows: not run. The change is in the test only, and the yield does not change what the readers check. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
ycbuzi commented 2026-10-21 06:58:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T06:58:36Z.


Windows run of 070e44768c merged onto main ec7eacc62d (95c21ccdb0, clean), one of the hosts the description lists as not run. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built guest_time_conversion_tests with no errors or warnings; ctest --repeat until-fail:2 on guest_time_conversion: passes on both repeats. Not run: Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310062886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8288#issuecomment-6310062886). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T06:58:36Z. --- Windows run of 070e44768c merged onto `main` ec7eacc62d (95c21ccdb0, clean), one of the hosts the description lists as not run. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `guest_time_conversion_tests` with no errors or warnings; `ctest --repeat until-fail:2` on `guest_time_conversion`: passes on both repeats. Not run: Linux.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
boykopovar/AnyPS5!8288
No description provided.