fix(agc): profile completed CPU copies with their actual spans #4187
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4187"
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 Scramblrrrr on 2026-10-12T00:55:43Z.
What
CPU-copy profiling currently counts each region's logical size before sparse allocation clamps it, so a 512 MiB sparse heap can be reported as 512 MiB copied even when its buffer and read are much smaller. Count completed copy operations after copying and report logical spans, buffer spans and actual read bytes separately. Reason and address-bucket totals use buffer spans. Zero-filled gaps are not counted as bytes read.
These are accumulated per-operation totals, not unique allocation sizes or resident memory. Copy behavior and sparse-clamp policy are unchanged; #2992 already implements sparse heap trimming.
Tested
Windows 11 Pro 26200, GCC 15.2 Release, RTX 5070 Ti, required Vulkan, main
7a84b222plus head875d7301168330b3d2842e1d2a244979a63e9df3:agc_driver_graphicsandagc_driver_bda_devicepassed 2/2 in 5.91 seconds. Conventions and diff checks pass. Fixture checks use ordinary settings: the graphics mock lacks the profiling query-pool function.Actual 007 profiling with the identical change carried on rendering head
247de1151e0a53a68c3dbf3445ce134ff5a9cc8f,APS5_PROFILE_DRAW=1: after 33,000 completed CPU-copy operations the log reports 10,398,938 MiB logical spans versus 248,082 MiB buffer spans/bytes read. This validates the distinction, not a performance improvement or a current-main title success. Title files/captures remain local. No full-suite or Linux claim.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T01:18:56Z.
This is cleanly metrics-only — every new or moved statement is counter bookkeeping; the sparse-allocation clamp, the staged-copy path, and every side-effecting call are untouched with identical arguments. The zero-filled-gap exclusion is structurally determined (it walks
region.backed, the region's actual committed guest ranges) rather than inspecting byte values, which is the right way to do it — a real zero byte in committed memory still counts as read.One nuance worth naming, already acknowledged in spirit by the body's "accumulated per-operation totals" framing: moving the count to after the copy means a copy that throws partway now contributes to none of the totals, where it previously counted toward the attempt before failing. That's fine here because nothing in the driver branches on these counters — they only feed a diagnostic print — but it does mean a before/after comparison of these logs across versions isn't apples-to-apples for interrupted copies specifically.
Thread-safety is consistent with what was already there: the new accumulators are either call-local or guarded by the same mutex the pre-existing counters used, and nothing new is held across that lock acquisition.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T14:13:04Z.
Thanks for checking the accounting and locking. Agreed on the interrupted-copy distinction: an operation that throws before completion contributes to none of the new totals, even if it performed a partial read. These counters describe completed operations and are diagnostic only; they do not control copying or allocation. I will keep that qualification explicit when comparing profiler logs across versions. No performance change claimed here. AI-assisted: Codex.