feat(equeue): implement macOS edge watches #12741

Merged
SHOnnay merged 1 commit from upstream-pr/12741 into main 2026-11-02 13:39:21 +00:00
SHOnnay commented 2026-10-29 06:33:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SHOnnay on 2026-10-29T06:33:01Z.


What

On macOS, EV_CLEAR on guest sockets and pipes threw because EdgeWatch had no host backend. This adds one: a private host kqueue with EV_CLEAR, close-on-exec and zero-timeout retrieval, following the existing Linux epoll design. Pipe-write events and the other unsupported cases still throw.

The isolated fixture in core/libs/tests/EdgeWatch.cpp compiles the production EdgeWatch.cpp. A dedicated macos-15-intel and macos-15 CI job is a near-copy of write-watch, with eligibility wiring for its build inputs. The existing debt entries are updated narrowly. Linux and Windows code paths are byte-for-byte unchanged: removing the two added __APPLE__ blocks reproduces upstream's file exactly.

Related:

  • #9843 rejects TCP low-watermarks above 1 with no Linux guard, so it would also apply on macOS.
  • #9575 changes watched-queue activation bookkeeping.

This backend builds and passes against upstream/main without either PR. The overlap check reported documentation conflicts only; it reported no overlap in EdgeWatch.cpp or the workflow.

Tested

macOS ARM64 only. Intel macOS, Linux and Windows were not run locally. The fixture does not establish full guest-runtime kevent behaviour.

The fixture covers socket and pipe repeated arrivals (including while prior data remains unread), no repeated idle notification, EOF with buffered data, and blocking waits; plus socket write fill/drain, close-on-exec, descriptor cleanup and invalid registration. Pipe reads can themselves raise new host notifications, including EOF reads; the fixture consumes those notifications before asserting idle silence. Waits use bounded polling with deadlines and no fixed sleeps.

Commands:

cmake -S core/libs/tests/edge_watch -B /private/tmp/anyps5-build-edge-watch -DCMAKE_BUILD_TYPE=Release
cmake --build /private/tmp/anyps5-build-edge-watch --parallel
ctest --test-dir /private/tmp/anyps5-build-edge-watch --output-on-failure

Before: the final fixture was built against upstream/main's unchanged production EdgeWatch.cpp, temporarily restored for the baseline and then restored to the implementation afterwards. Four of five tests fail:

Test project /private/tmp/anyps5-build-edge-watch
    Start 1: edge_watch_socket
1/5 Test #1: edge_watch_socket ................***Failed    0.46 sec
FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux

    Start 2: edge_watch_pipe
2/5 Test #2: edge_watch_pipe ..................***Failed    0.00 sec
FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux

    Start 3: edge_watch_write
3/5 Test #3: edge_watch_write .................***Failed    0.00 sec
FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux

    Start 4: edge_watch_lifecycle
4/5 Test #4: edge_watch_lifecycle .............***Failed    0.00 sec
FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux

    Start 5: edge_watch_errors
5/5 Test #5: edge_watch_errors ................   Passed    0.00 sec

20% tests passed, 4 tests failed out of 5

Total Test time (real) =   0.47 sec

The following tests FAILED:
	  1 - edge_watch_socket (Failed)
	  2 - edge_watch_pipe (Failed)
	  3 - edge_watch_write (Failed)
	  4 - edge_watch_lifecycle (Failed)
Errors while running CTest

After restoring the implementation, a clean rebuild avoided reusing baseline objects:

cmake --build /private/tmp/anyps5-build-edge-watch --clean-first --parallel
ctest --test-dir /private/tmp/anyps5-build-edge-watch --output-on-failure
Test project /private/tmp/anyps5-build-edge-watch
    Start 1: edge_watch_socket
1/5 Test #1: edge_watch_socket ................   Passed    0.73 sec
    Start 2: edge_watch_pipe
2/5 Test #2: edge_watch_pipe ..................   Passed    0.41 sec
    Start 3: edge_watch_write
3/5 Test #3: edge_watch_write .................   Passed    0.16 sec
    Start 4: edge_watch_lifecycle
4/5 Test #4: edge_watch_lifecycle .............   Passed    0.01 sec
    Start 5: edge_watch_errors
5/5 Test #5: edge_watch_errors ................   Passed    0.00 sec

100% tests passed out of 5

Total Test time (real) =   1.32 sec

Repeated locally 20 times per case (100 of 100 executions passed):

ctest --test-dir /private/tmp/anyps5-build-edge-watch --output-on-failure --repeat until-fail:20 --no-tests=error
    Start 5: edge_watch_errors
    Test #5: edge_watch_errors ................   Passed    0.00 sec
    Start 5: edge_watch_errors
5/5 Test #5: edge_watch_errors ................   Passed    0.00 sec

100% tests passed out of 5

Total Test time (real) =  20.04 sec

Additional checks:

python3 tools/tests/test_build_eligibility.py
python3 tools/check_conventions.py --base upstream/main
actionlint -format '{{json .}}' .github/workflows/build.yml
  • Eligibility suite: 10 tests passed. Additional checks using its harness selected edge-watch for the fixture, production source/header and libc inputs, skipped README-only changes, and selected an isolated edit to its workflow job.
  • Conventions: 2 findings, 0 errors (exit 0); the two edited debt entries exceed 1,000 characters.
  • Homebrew actionlint 1.7.12: zero new findings compared with upstream/main's workflow, comparing diagnostic kind/message occurrence counts rather than shifted line numbers.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5063472679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12741). Originally posted by [SHOnnay](https://github.com/SHOnnay) on 2026-10-29T06:33:01Z. --- ### What On macOS, `EV_CLEAR` on guest sockets and pipes threw because EdgeWatch had no host backend. This adds one: a private host kqueue with `EV_CLEAR`, close-on-exec and zero-timeout retrieval, following the existing Linux epoll design. Pipe-write events and the other unsupported cases still throw. The isolated fixture in `core/libs/tests/EdgeWatch.cpp` compiles the production `EdgeWatch.cpp`. A dedicated `macos-15-intel` and `macos-15` CI job is a near-copy of write-watch, with eligibility wiring for its build inputs. The existing debt entries are updated narrowly. Linux and Windows code paths are byte-for-byte unchanged: removing the two added `__APPLE__` blocks reproduces upstream's file exactly. Related: - #9843 rejects TCP low-watermarks above 1 with no Linux guard, so it would also apply on macOS. - #9575 changes watched-queue activation bookkeeping. This backend builds and passes against upstream/main without either PR. The overlap check reported documentation conflicts only; it reported no overlap in EdgeWatch.cpp or the workflow. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> macOS ARM64 only. Intel macOS, Linux and Windows were not run locally. The fixture does not establish full guest-runtime kevent behaviour. The fixture covers socket and pipe repeated arrivals (including while prior data remains unread), no repeated idle notification, EOF with buffered data, and blocking waits; plus socket write fill/drain, close-on-exec, descriptor cleanup and invalid registration. Pipe reads can themselves raise new host notifications, including EOF reads; the fixture consumes those notifications before asserting idle silence. Waits use bounded polling with deadlines and no fixed sleeps. Commands: ```sh cmake -S core/libs/tests/edge_watch -B /private/tmp/anyps5-build-edge-watch -DCMAKE_BUILD_TYPE=Release cmake --build /private/tmp/anyps5-build-edge-watch --parallel ctest --test-dir /private/tmp/anyps5-build-edge-watch --output-on-failure ``` Before: the final fixture was built against upstream/main's unchanged production EdgeWatch.cpp, temporarily restored for the baseline and then restored to the implementation afterwards. Four of five tests fail: ```text Test project /private/tmp/anyps5-build-edge-watch Start 1: edge_watch_socket 1/5 Test #1: edge_watch_socket ................***Failed 0.46 sec FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux Start 2: edge_watch_pipe 2/5 Test #2: edge_watch_pipe ..................***Failed 0.00 sec FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux Start 3: edge_watch_write 3/5 Test #3: edge_watch_write .................***Failed 0.00 sec FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux Start 4: edge_watch_lifecycle 4/5 Test #4: edge_watch_lifecycle .............***Failed 0.00 sec FAIL: kevent: EV_CLEAR on a socket or a pipe off Linux Start 5: edge_watch_errors 5/5 Test #5: edge_watch_errors ................ Passed 0.00 sec 20% tests passed, 4 tests failed out of 5 Total Test time (real) = 0.47 sec The following tests FAILED: 1 - edge_watch_socket (Failed) 2 - edge_watch_pipe (Failed) 3 - edge_watch_write (Failed) 4 - edge_watch_lifecycle (Failed) Errors while running CTest ``` After restoring the implementation, a clean rebuild avoided reusing baseline objects: ```sh cmake --build /private/tmp/anyps5-build-edge-watch --clean-first --parallel ctest --test-dir /private/tmp/anyps5-build-edge-watch --output-on-failure ``` ```text Test project /private/tmp/anyps5-build-edge-watch Start 1: edge_watch_socket 1/5 Test #1: edge_watch_socket ................ Passed 0.73 sec Start 2: edge_watch_pipe 2/5 Test #2: edge_watch_pipe .................. Passed 0.41 sec Start 3: edge_watch_write 3/5 Test #3: edge_watch_write ................. Passed 0.16 sec Start 4: edge_watch_lifecycle 4/5 Test #4: edge_watch_lifecycle ............. Passed 0.01 sec Start 5: edge_watch_errors 5/5 Test #5: edge_watch_errors ................ Passed 0.00 sec 100% tests passed out of 5 Total Test time (real) = 1.32 sec ``` Repeated locally 20 times per case (100 of 100 executions passed): ```sh ctest --test-dir /private/tmp/anyps5-build-edge-watch --output-on-failure --repeat until-fail:20 --no-tests=error ``` ```text Start 5: edge_watch_errors Test #5: edge_watch_errors ................ Passed 0.00 sec Start 5: edge_watch_errors 5/5 Test #5: edge_watch_errors ................ Passed 0.00 sec 100% tests passed out of 5 Total Test time (real) = 20.04 sec ``` Additional checks: ```sh python3 tools/tests/test_build_eligibility.py python3 tools/check_conventions.py --base upstream/main actionlint -format '{{json .}}' .github/workflows/build.yml ``` - Eligibility suite: 10 tests passed. Additional checks using its harness selected edge-watch for the fixture, production source/header and libc inputs, skipped README-only changes, and selected an isolated edit to its workflow job. - Conventions: 2 findings, 0 errors (exit 0); the two edited debt entries exceed 1,000 characters. - Homebrew actionlint 1.7.12: zero new findings compared with upstream/main's workflow, comparing diagnostic kind/message occurrence counts rather than shifted line numbers. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes (Codex) <!-- yes / no -->
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!12741
No description provided.