docs(dev): note the cost of the checked guest copies #20691
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20691"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-15T12:49:42Z.
What
CONVENTIONS.mdpoints contributors atGuestCopyIn_nid_no_patch/GuestCopyOut_nid_no_patchand the guest-pointer audit, but says nothing about what a checked copy costs. On #20589 Dean asked to keep the direct stores insincosf,modfandremquofor that reason, and the measurements there showed how large the difference is. This adds one paragraph after the audit paragraph:GuestFaultCopy, a copy guarded by a fault handler, once its handlers are installed. WithAPS5_GUEST_COPY_SYSCALLset, when the handlers fail to install, and on other Linux hosts, it falls back to aprocess_vm_readv/process_vm_writevsystem call. On that path a write measured about 330 ns per output in #20589 (modfandmodffon an i7-13700K, against 1.3-1.4 ns for a plain store); reads and the fault-guarded copy are not measured. On Windows both directions first try the guest arena's own copy; otherwise a read is oneReadProcessMemorycall and a write walks the range withVirtualQuery(neither measured).327a1d6c2athe note kept direct access for every per-element call; ligmaSec's review asked to narrow it.)The same numbers led me to withdraw #20600 (
mbrtoc32/mbrtoc16, 3-6 copies per character) and #20588 (wcstok_s, about 1,965 ns per token against 3 ns), and to rework #20526 and #20587 to copy once per call.Tested
Documentation only; nothing to build or run.
mbstowcs_sof 100 characters: 33.5 µs per call with one copy per character, 0.97 µs with one copy per call, 0.17 µs onmain).tools/check_conventions.pypasses on the branch and this body.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T20:16:34Z.
Review: APPROVED
Reviewed — looks good
The documentation change matches its stated goal, and the reviewed text contains no verified blocking defect.
What I ran
Reviewed head
bf3882080eb78921b29d017dff2c19d520e74b21using the prepared description, commit list, manifest, diff, and the changed file at the pinned head. No commands or tests were run; this is a documentation-only change.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text in
review/files/andfiles.jsoncould not be read through the available reader. The manifest shows one changed file and marks it included; I read the full 37-line file at the pinned head instead. The cited benchmark details and the Windows behavior were not independently verified. No build or tests were run.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:12:51Z.
Review: COMMENTED
I compared the added note with both copy implementations in
General.cpp. The Windows note currently describes only the output path.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T13:46:54Z.
Review: COMMENTED
Reviewed — no blocking findings
The documented copy paths match the implementation; the cited performance measurements were not independently verified.
What I ran
Reviewed head
313d6e04f508c0287528c37dd9e4f8b44301ba99usingrepo_read.pyand the prepared review files. No tests or builds were run; this is a documentation-only change.Read
docs/dev/CONVENTIONS.md, the prepared diff, description, commits, manifest and file list. The only changed file listed for review was read in full; no files were excluded.Results
Reader commands and relevant output
General.cpplines 88–100 showCopyGuestBytesusingReadProcessMemoryon Windows andprocess_vm_readvon Linux. Lines 870–884 showGuestCopyOut_nid_no_patchwalking Windows regions withVirtualQuery, then copying, and usingprocess_vm_writevon Linux.Negative control
Not applicable; no behavior or tests changed.
Findings
Blocking
None.
Non-blocking
docs/dev/CONVENTIONS.md:32.Sources
Not verified
The benchmark captures, measurement methodology and reported timings were not independently checked. No automated checks, builds, or platform-specific runs were performed.
To get this to a good state
Nothing is required. Optionally, verify the latency figures against the cited benchmark records.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T16:53:27Z.
Review: COMMENTED
Reviewed — no blocking findings
The documentation change is limited to one paragraph; the checked-copy implementation details and benchmark figures could not be independently confirmed because the pinned reader could not write its read log.
What I ran
Reviewed head
94e3caa0cf57790adb1fd830f933e2bdcdf40d9c. Readdescription.md,commits.md,manifest.json,files.json,diff.patch, and the included full text ofdocs/dev/CONVENTIONS.md. No tests were run because this is documentation-only.Attempted source searches with
python3 repo_read.py searchfor the checked-copy functions and Linux syscall setting; the reader failed while trying to append its log.Results
Findings
Blocking
None.
Non-blocking
The paragraph gives implementation details and benchmark figures that this review could not independently verify. The description attributes the figures to earlier PR measurements; they are not presented here as measurements run for this review.
Not verified
Could not verify the Linux and Windows copy paths or benchmark figures against source or original benchmark output. No negative control was applicable. No files were excluded by the supplied review manifest.
To get this to a good state
Nothing is required. The implementation details and figures are optional points to confirm against source and benchmark records.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:54:25Z.
Review: COMMENTED
The linked benchmark measures the output-side checked math calls. It does not measure
process_vm_readv. Please scope the timing to the write path and note that Linux x86_64 uses the fault-guarded copy when its handlers initialize successfully, with the syscall path also serving as a fallback.The last two sentences would also make a broad exception for direct guest access based on call frequency. Please keep the batching guidance and limit unchecked access to specific, measured cases with documented pointer assumptions. A frequently called export can still receive an invalid pointer.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T17:04:35Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new cost paragraph describes copy paths and controls that do not match the implementation at this head.
What I ran
Reviewed head
327a1d6c2a9f666f1a7d7764da2e98725ae3a67fagainst the prepared diff. No merged-preview check or build was run. I usedrepo_read.pyto inspectGeneral.cppandGuestArena.cppat the pinned head.Results
Negative control
Not applicable; this change adds no tests or executable behavior.
Findings
Blocking
docs/dev/CONVENTIONS.md:32documents LinuxGuestFaultCopyandAPS5_GUEST_COPY_SYSCALLpaths that are not present in the inspected implementation:GuestCopyIn_nid_no_patchcallsCopyGuestBytes, which usesprocess_vm_readvon Linux, andGuestCopyOut_nid_no_patchusesprocess_vm_writev. The paragraph also names WindowsGuestArenaStoreOwned_nid_no_patch, which was not found; the inspected Windows write path checks the range withVirtualQueryand then usesmemcpy. Please revise the paragraph to describe the implementation at this head before merging.Non-blocking
None.
Sources
Not verified
The benchmark figures and cited PR measurements were not independently checked. No runtime or platform-specific checks were run. The prepared bundle lists
docs/dev/CONVENTIONS.mdas reviewed; no files were excluded.To get this to a good state
Correct the copy-path documentation to match the pinned implementation, then review the updated paragraph against the source.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T17:05:02Z.
Review: COMMENTED
Actionable comments
GuestCopyOut_nid_no_patch.45f3492e-b578-4c13-a3a1-d2f6555ec0b6Reviewing files that changed from the base of the PR and between
94e3caa0cfand327a1d6c2a.docs/dev/CONVENTIONS.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:11:57Z.
Review: COMMENTED
I rechecked
327a1d6c2aagainst my earlier comments. The benchmark exception is confined to the measured output path and documents its validation assumptions. The normal protected path now falls back to the checked copy when handler initialization fails. These address the two issues from my earlier review. This follow-up covers the source changes.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T18:51:59Z.
Review: APPROVED
Reviewed — looks good
The added guidance matches the checked-copy paths in the pinned source, and I found no blocking issue.
What I ran
Reviewed head
435f60a782bb90539040d17320acf1e911e4a0a7. Read the full changed file and targeted source ranges; no build or tests were run.The reader returned the requested source output, but its log append failed because the run directory is read-only.
Results
Negative control
Not run; this documentation-only change has no relevant negative control.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The timing figures and the reported
tools/check_conventions.pyresult are author-reported; I did not independently verify them. Runtime behavior and performance were not tested. The changed file read wasdocs/dev/CONVENTIONS.mdin full;files.jsonlists no excluded files. Source context was limited to the targeted ranges listed above.To get this to a good state
Nothing is required.