macOS: every checked guest copy is a mach_vm_read_overwrite call (guest_icu_comparisons 16 s on M1, 0.19 s on Linux CI) #26519

Open
opened 2026-11-24 03:45:00 +00:00 by Romannachwievor · 0 comments
Romannachwievor commented 2026-11-24 03:45:00 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-24T03:45:00Z.


On macOS, every checked guest copy is a mach_vm_read_overwrite call. GuestCopyIn_nid_no_patch and GuestCopyInUnsynced_nid_no_patch go through CopyGuestBytes (General.cpp:96, main 5e16f4422d). Linux x86-64 tries GuestFaultCopy::Copy first (:105), and Windows tries GuestArenaCopyOwned_nid_no_patch first (:100). On macOS there is no in-process path, so each copy is a Mach call (:116).

The test that shows it is guest_icu_comparisons, which has TIMEOUT 20 (libSceIcu/CMakeLists.txt:389). Since commits 1077cb0ed3 and 1d50979dbd (11-18), its strings are read through checked guest copies in page-bounded chunks.

Host guest_icu_comparisons
Linux CI, run 45297537266 0.19 s
Windows CI, run 45276912076 6.19 s
Apple M1, alone, three runs 15.94 / 16.52 / 16.61 s
Apple M1, ctest -j8 Timeout at 20.04 s

The M1 runs used macOS 26.5, an x86_64 Release build under Rosetta 2, on main c55872d43f plus #17425 and #11049 (needed for the macOS full build). An earlier M1 run on main 0af6acc89e (11-21) also timed out under ctest -j6 and passed alone in 13.96 s.

To check where the time goes, I put a plain memcpy behind an environment variable in the macOS branch of CopyGuestBytes, as a local experiment only. With it, both of two runs crashed with SIGSEGV after 2.44 s, in Length through UnitReader::At in libSceIcu.prx (macOS crash report). That crash is expected: the later cases make reads that a checked copy has to refuse, and a plain memcpy does not refuse them. Exhaustive(), which makes most of the copies, runs first and reads only in-memory arrays. Without the variable the same binary took 17.94 and 21.99 s for the whole test. sample of the unmodified test showed the main thread inside Rosetta runtime routines in every sample. So most of the time goes to the copy path, not to ICU. I did not measure a title, but every GuestCopyIn on macOS takes the same path.

I have not tried a fix. One option is an in-process copy that recovers from faults, as GuestFaultCopy does on Linux (specifics/linux/GuestFaultCopy.cpp). Another is an ownership check first, as Windows does with the guest arena. Raising the test's timeout would only hide the cost. This matters for the macOS full-build job proposed in #24117 / #24341, since ctest -j there would time this test out.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6574130838 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/26519). Originally posted by [Romannachwievor](https://github.com/Romannachwievor) on 2026-11-24T03:45:00Z. --- On macOS, every checked guest copy is a `mach_vm_read_overwrite` call. `GuestCopyIn_nid_no_patch` and `GuestCopyInUnsynced_nid_no_patch` go through `CopyGuestBytes` ([General.cpp:96](https://github.com/boykopovar/AnyPS5/blob/5e16f4422d/core/libs/prx/libc/src/General.cpp#L96), `main` `5e16f4422d`). Linux x86-64 tries `GuestFaultCopy::Copy` first (:105), and Windows tries `GuestArenaCopyOwned_nid_no_patch` first (:100). On macOS there is no in-process path, so each copy is a Mach call (:116). The test that shows it is `guest_icu_comparisons`, which has `TIMEOUT 20` ([libSceIcu/CMakeLists.txt:389](https://github.com/boykopovar/AnyPS5/blob/5e16f4422d/core/libs/prx/libSceIcu/CMakeLists.txt#L389)). Since commits 1077cb0ed3 and 1d50979dbd (11-18), its strings are read through checked guest copies in page-bounded chunks. | Host | `guest_icu_comparisons` | |---|---| | Linux CI, run 45297537266 | 0.19 s | | Windows CI, run 45276912076 | 6.19 s | | Apple M1, alone, three runs | 15.94 / 16.52 / 16.61 s | | Apple M1, `ctest -j8` | Timeout at 20.04 s | The M1 runs used macOS 26.5, an x86_64 Release build under Rosetta 2, on `main` `c55872d43f` plus #17425 and #11049 (needed for the macOS full build). An earlier M1 run on `main` `0af6acc89e` (11-21) also timed out under `ctest -j6` and passed alone in 13.96 s. To check where the time goes, I put a plain `memcpy` behind an environment variable in the macOS branch of `CopyGuestBytes`, as a local experiment only. With it, both of two runs crashed with SIGSEGV after 2.44 s, in `Length` through `UnitReader::At` in `libSceIcu.prx` (macOS crash report). That crash is expected: the later cases make reads that a checked copy has to refuse, and a plain `memcpy` does not refuse them. `Exhaustive()`, which makes most of the copies, runs first and reads only in-memory arrays. Without the variable the same binary took 17.94 and 21.99 s for the whole test. `sample` of the unmodified test showed the main thread inside Rosetta runtime routines in every sample. So most of the time goes to the copy path, not to ICU. I did not measure a title, but every `GuestCopyIn` on macOS takes the same path. I have not tried a fix. One option is an in-process copy that recovers from faults, as `GuestFaultCopy` does on Linux (specifics/linux/GuestFaultCopy.cpp). Another is an ownership check first, as Windows does with the guest arena. Raising the test's timeout would only hide the cost. This matters for the macOS full-build job proposed in #24117 / #24341, since `ctest -j` there would time this test out. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#26519
No description provided.