Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
mugurc:fix/tests-zone-race-yield
Oct 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
mugurc:fix/tests-zone-race-yield

Conversation

@mugurc

@mugurc mugurc commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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 (#1 (comment)).

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 3fd1cc3 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

The zone race of guest_time_conversion changes TZ in a tight loop while
six threads convert times. 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 mostly
waited, and the test ran for 21 seconds, past its 20-second timeout; a
run with counters showed about 373 million TZ changes against the
readers' 15,000 local time conversions. The flipper now yields after
each change. It still changes TZ about 800,000 times while the readers
convert, they see each zone in about half of their conversions, and the
test takes about a second.
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestTimeConversion.cpp
PR 10129 core/libs/tests/GuestTimeConversion.cpp

@ycbuzi

ycbuzi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Windows run of 070e447 merged onto main ec7eacc (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.

@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 5674fa6 into boykopovar:main Oct 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants