fix(libkernel): use precise waits for empty poll sets #4980

Merged
MarcZX10 merged 1 commit from upstream-pr/4980 into main 2026-10-14 01:26:00 +00:00
MarcZX10 commented 2026-10-13 07:11:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:11:33Z.


What

When poll_nid_postfix has no native sockets or pipes and a positive timeout, it currently calls std::this_thread::sleep_for(std::chrono::milliseconds(timeout)). On Windows, sleep_for(1 ms) can take about 15.6 ms because the timed wait follows coarse GetTickCount64 steps, as documented and measured in issue #1471.

Use the existing PreciseSleepUs helper for this empty-set wait, converting the guest timeout from milliseconds to microseconds. Add a repeated 1 ms empty-poll timing check to guest_poll so the coarse 15.6 ms behavior fails the test. This carries only the poll portion of Doston Abdullayev’s public fix branch and preserves his original commit authorship. The select portion is covered separately by #4754.

Tested

  • Linux Release/Ninja: built guest_poll_tests and libkernel.prx; ctest -R '^guest_poll$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base upstream/main --head HEAD: passed.
  • git diff --check: passed.
  • Windows behavior is supported by the Windows 10 / MinGW measurements and before/after guest_poll runs reported on #1471. This branch was not independently built on Windows.

Checklist

  • Based on current main; no equivalent open PR implements the empty-set poll timeout fix
  • One topic per PR
  • No comments in code except technical debt
  • Unimplemented paths still throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code or dependencies
  • Generic behavior, not specific to one title
  • Depends on: #4933 (touches the same poll_nid_postfix function; merge/rebase after it)
  • Unblocks: none
  • AI-assisted: yes; the implementation is carried from Doston Abdullayev’s public branch, with local validation and PR preparation assisted by Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839709215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4980). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:11:33Z. --- ### What When `poll_nid_postfix` has no native sockets or pipes and a positive timeout, it currently calls `std::this_thread::sleep_for(std::chrono::milliseconds(timeout))`. On Windows, `sleep_for(1 ms)` can take about 15.6 ms because the timed wait follows coarse `GetTickCount64` steps, as documented and measured in [issue #1471](https://github.com/boykopovar/AnyPS5/issues/1471). Use the existing `PreciseSleepUs` helper for this empty-set wait, converting the guest timeout from milliseconds to microseconds. Add a repeated 1 ms empty-poll timing check to `guest_poll` so the coarse 15.6 ms behavior fails the test. This carries only the `poll` portion of Doston Abdullayev’s public fix branch and preserves his original commit authorship. The `select` portion is covered separately by #4754. ### Tested - Linux Release/Ninja: built `guest_poll_tests` and `libkernel.prx`; `ctest -R '^guest_poll$' --output-on-failure`: **1/1 passed**. - `python3 tools/check_conventions.py --base upstream/main --head HEAD`: passed. - `git diff --check`: passed. - Windows behavior is supported by the Windows 10 / MinGW measurements and before/after `guest_poll` runs reported on #1471. This branch was not independently built on Windows. ### Checklist - [x] Based on current `main`; no equivalent open PR implements the empty-set `poll` timeout fix - [x] One topic per PR - [x] No comments in code except technical debt - [x] Unimplemented paths still throw; no silent stubs added - [x] No notes, investigation files or images added to the repository - [x] No new third-party code or dependencies - [x] Generic behavior, not specific to one title - [x] Depends on: #4933 (touches the same `poll_nid_postfix` function; merge/rebase after it) - [x] Unblocks: none - [x] AI-assisted: yes; the implementation is carried from Doston Abdullayev’s public branch, with local validation and PR preparation assisted by Codex
xXPBSXx commented 2026-10-13 09:16:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T09:16:27Z.


Windows counter-test: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, this PR merged onto main 2a2a3dc65. guest_poll passes with the PR; with the PR's source files replaced by main's, same test, it aborts (0xc0000409).

Not tested: Linux, a console, a title run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142324065 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4980#issuecomment-6142324065). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T09:16:27Z. --- Windows counter-test: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, this PR merged onto `main` `2a2a3dc65`. `guest_poll` passes with the PR; with the PR's source files replaced by `main`'s, same test, it aborts (0xc0000409). Not tested: Linux, a console, a title run. AI-assisted (Claude Code).
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!4980
No description provided.