perf(memory): reduce repeated write-tracking range scans #1310
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1310"
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 TibixDev on 2026-10-07T23:09:51Z.
What
Scan version stamps within each contiguous leaf instead of finding the leaf for every block. On Linux, collect nearby watched pages together within existing queue epochs.
Select the range before collection. Widen it only when Linux confirms full watched coverage. Keep the requested range on Windows, for uncached reads, and for threads without epochs. Do not retry a failed collection.
Related: #1201 and #1202 change queue scheduling and retain more collected ranges. This change keeps epoch boundaries and the existing cache size.
Tested
Fedora 44, Release build:
Isolated comparison against upstream
a9ba39c9: unchanged 64 MiB checks fell from 510 to 208 ns. A saved 4,172-request replay used 11–12% less time. Checks that found a write at the first block were about 1 ns slower. These are component timings, not title frame times. Windows was not tested.Checklist
main; related PRs are described above.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:14Z.
When the widened walk fails,
GuestMemory.cpp:1017walks the requested pages again. Retrying after a failed attempt isn't allowed here (#182); please decide the range before the first walk. For numbers, see #1324.Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T04:17:39Z.
The range is now selected before the walk. Linux widens it only after checking watched coverage. Windows keeps the requested range because its arena check does not prove that neighboring pages are committed. A failed walk returns without a retry.
I also compared upstream
a9ba39c9with that upstream plus this revised PR alone. Both used the same test harness andlibc.prx. Fedora 44, GCC 16 Release, Ryzen 5 5600, CPU 3; six runs per variant in ABBA order. Each run had one warmup and nine measured batches. Values below are medians of the six run medians.Version checks, ns/check (upstream → PR):
The saved 4,172-request replay fell from 471.4 to 418.4 ns/request with clean pages, and from 496.3 to 435.6 ns/request with a write every 64 requests: 11.2% and 12.2% less time. The observed run ranges did not overlap for either replay case.
The early-exit cases are about 1 ns slower. This replay preserves request ranges and epochs, not the complete game workload; it does not establish a frame-time gain.
Write-history and graphics tests pass. Write-tracking tests also pass with caching disabled and with the shared cache enabled. Windows was not tested.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-08T08:06:37Z.
Tested on Windows, since the description says it wasn't: Windows 10 (19045), RTX 3060 Laptop (driver 616.92), MinGW-w64 GCC 15.2.0, Release,
mainda402739merged with f26ea472.agc_write_trackingwith the new cases passes 5 of 5 runs.agc_driver_dcc_keys_first_write, which fails onmaintoo (#1434).agc_driver_recorder_tests, which is not in ctest, passes 3 of 3 runs.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:21:56Z.
Conflicts with main in
tests/WriteTracking.cpp(new cases landed at the same spot); please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:58:31Z.
Rebased on current
main(conflict intests/WriteTracking.cppwith the new unwatch/private-mapping cases; kept both sets). Linux build + full ctest pass (553/553), includingagc_write_tracking. The range is selected before the walk with no retry, as asked in #182, and the Windows path keeps the linear scan. Merging once CI is green on the rebased head.