test(libkernel): wait until 50 ms have passed before the first process time read #3414

Merged
reyani-dev merged 1 commit from upstream-pr/3414 into main 2026-10-11 10:12:44 +00:00
reyani-dev commented 2026-10-11 09:52:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T09:52:55Z.


What

Follow-up to #3368, which @orishamir found flaky on Windows (comment on #3368): under parallel load, guest_process_time_counter occasionally fails with

first process time counter does not include the time before the first call

The test slept 50 ms with std::this_thread::sleep_for and then required the first reading to include 50 ms. On Windows that sleep can return slightly early when measured against the performance counter the guest clock reads (TimedWait::NowNanos, QPC), so the reading could come out just under 50 ms. The fix itself is fine: the start is captured at load. Only the test's wait was imprecise.

The test now waits until std::chrono::steady_clock reports 50 ms have passed, looping on sleep_until, before the first call. The process start precedes that point, so the first reading includes at least 50 ms (scaled for the _scaled variants).

Tested

Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, on main a73a1af9:

  • ctest -R "^guest_process_time" --repeat until-fail:60 -j8:
    • on main, guest_process_time and guest_process_time_counter_scaled failed with 0xc0000409 within the 60 rounds;
    • with this change, all four pass all 60 rounds.
  • check_conventions.py passes, and pr_overlap.py reports no overlap.

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 in TechnicalDebt
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818184878 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3414). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T09:52:55Z. --- ### What Follow-up to #3368, which @orishamir found flaky on Windows (comment on #3368): under parallel load, `guest_process_time_counter` occasionally fails with ``` first process time counter does not include the time before the first call ``` The test slept 50 ms with `std::this_thread::sleep_for` and then required the first reading to include 50 ms. On Windows that sleep can return slightly early when measured against the performance counter the guest clock reads (`TimedWait::NowNanos`, QPC), so the reading could come out just under 50 ms. The fix itself is fine: the start is captured at load. Only the test's wait was imprecise. The test now waits until `std::chrono::steady_clock` reports 50 ms have passed, looping on `sleep_until`, before the first call. The process start precedes that point, so the first reading includes at least 50 ms (scaled for the `_scaled` variants). ### Tested Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, on `main` `a73a1af9`: - `ctest -R "^guest_process_time" --repeat until-fail:60 -j8`: - on `main`, `guest_process_time` and `guest_process_time_counter_scaled` failed with `0xc0000409` within the 60 rounds; - with this change, all four pass all 60 rounds. - `check_conventions.py` passes, and `pr_overlap.py` reports no overlap. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
orishamir commented 2026-10-11 10:11:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-11T10:11:49Z.


Verified on the machine that saw the flake: Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, 0eaf2ec1 merged onto main 434f290d (clean). guest_process_time_counter passes 20/20 and the four guest_process_time* tests 5/5 each; the one failure I had seen was in a full --parallel 4 run, so the repeats here were serial, which is the easier case, but the loop on sleep_until removes the early-return the old 50 ms sleep_for allowed.

AI-assisted: yes (Claude Code Fable 5.1 xhigh)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107940943 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3414#issuecomment-6107940943). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-11T10:11:49Z. --- Verified on the machine that saw the flake: Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, 0eaf2ec1 merged onto `main` 434f290d (clean). `guest_process_time_counter` passes 20/20 and the four `guest_process_time*` tests 5/5 each; the one failure I had seen was in a full `--parallel 4` run, so the repeats here were serial, which is the easier case, but the loop on `sleep_until` removes the early-return the old 50 ms `sleep_for` allowed. AI-assisted: yes (Claude Code Fable 5.1 xhigh)
adriadam10 commented 2026-10-11 10:12:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:12:41Z.


Checked the diff (test-only, waits on steady_clock before the first read, so the process start precedes it) and ran guest_process_time* 10 rounds on Linux, all pass; Conventions green. The Windows fix rests on your 60-round -j8 run; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107947485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3414#issuecomment-6107947485). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T10:12:41Z. --- Checked the diff (test-only, waits on `steady_clock` before the first read, so the process start precedes it) and ran `guest_process_time*` 10 rounds on Linux, all pass; Conventions green. The Windows fix rests on your 60-round `-j8` run; merging.
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!3414
No description provided.