Repository navigation
perf(agc): allocate storage CPU snapshots on demand - #3991
oneandonlydean merged 5 commits into
Conversation
|
Tested on Linux (CachyOS x86_64, GCC) with an NVIDIA GeForce RTX 5060 Ti (driver 615.78.08, Vulkan 1.4):
Regarding the test fixture: Happy to report that the clean upstream Linux build validation limit mentioned in the description is verified! LGTM. |
|
Build failure on Windows: the new test doesn't compile on Windows:
The change itself looks correct to me. I went through every reader of
So starting with Nits:
Tested by reviewer AI-assisted: yes. Written with AI assistance (Claude Code), with the build run on my machine; I reviewed it. |
|
Thanks for catching this, @TideOPL. Fixed in 70015bd55: the fixture now passes My earlier native checks used an older local integration with the four-argument API, so they missed this public-branch compile error. I reproduced the reported failure using the complete public Windows The description also now clarifies that Qwen wrote this follow-up; I reviewed and validated it. Your rerun on the updated head would help close the remaining build and runtime validation. |
|
Could you measure a title's resident memory with and without this PR on the same base? A perf PR needs a number for the change itself (#218), and the fixture only counts one image's vector. Please also run |
|
@oneandonlydean Both checks are now complete on public head Public Windows fixture: I configured a fresh Release build using this head's project sources/headers and independent dependency checkouts at its pinned revisions (reusing the pinned FFmpeg package), built and linked RTX 4070 Laptop GPU, Vulkan core validation enabled; no validation errors or skips. This executes the public five-argument fixture, closing the compile-only limitation in my earlier reply. Same-base title A/B: Silent Hill 2 startup, Windows 11, MinGW GCC 15.2, Release Three pairs alternated run order. Each run started with an empty recompiled-shader cache and the same copied Vulkan pipeline-cache seed. Settings were texture cache 512 MiB, staging pool 64 MiB, resource-cache entries 16. Resident memory is Windows
Median resident memory: 3875.0 -> 3736.8 MiB, an observed 138.2 MiB (3.57%) reduction. Ranges: 3859.0-3903.1 MiB without; 3706.3-3749.4 MiB with. Median process private commit was 2635.9 -> 2501.6 MiB. All six runs reached the checkpoint without a recorded fatal error. Storage-image instances varied from 17 to 19, entirely from dynamic 1024x1024 images; other descriptor counts matched. This and the counter variation make the checkpoint approximate. I have not normalized or subtracted that difference from the measurements. These numbers cover early startup only. They do not establish menu/gameplay correctness, steady-state memory, or that the title fits within 8 GiB throughout. Both 8 GiB process guards remained enabled, along with 4 GiB available-RAM and 8 GiB commit-headroom guards; no run hit them. Logs and proprietary assets remain local. I've updated the PR description with this validation and its scope. AI-assisted: Codex prepared the comparison and checked the results. This validation required no production-code change or new push; the earlier fixture correction was written by Qwen and reviewed by Codex. |
|
Preparing an independent 007 Windows/RTX 5070 Ti cross-test of your current #3991 head 70015bd. All three authored commits applied cleanly with attribution on our older integration stack: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-lazy-snapshot-cross-test head a33e1e5. Source only, not built/staged; your storage_cpu_snapshot fixture and related graphics/recorded tests are next after the currently running quiet host-window #290 control. This will compare 4e40830 against that same base plus your lazy snapshots, not claim current-main/full-suite coverage. No competing upstream implementation. AI-assisted: Codex. No title data uploaded. |
|
Linux follow-up for head 70015bd, ported locally onto public main c36fd0a with the external #757/#758/#4288 stack and two local shader fixes. This is combined integration evidence, not an isolated performance A/B. Hardware is i7-13700K / RX 6900 XT, RADV Mesa 26.2.4, 31 GiB RAM. The patch applied cleanly. Built runtime libs and agc_driver_recorder_tests. Existing Linux checks agc_storage_baseline_settled, agc_storage_upload_lifetime and agc_storage_upload_failure pass. agc_unit_shadow exits successfully but explicitly reports that unit shadows were not tested because host imports are compared, so I do not count it as coverage. The new agc_storage_cpu_snapshot regression is Windows-only and was not run here. Demon's Souls passes startup shader registration and reaches texture loading, but this combined run still stops at our available-RAM watchdog (2.53 GiB remaining), before a main menu. No memory reduction or menu fix from this PR is established. A separate disposable-buffer probe confirms that this host's udmabuf size_limit_mb=64 rejects a 64 MiB +4096-byte import with EINVAL while a 4096-byte control succeeds. The title's several much larger import requests therefore remain an independent constraint. No game assets were copied or modified, and no kernel settings were changed for these results. Testing performed with AI assistance. |
|
Windows port efcd899 (older 4e40830 integration base) now passes eight native tests, no skips: storage_cpu_snapshot, storage_baseline_settled, storage_upload_lifetime/failure, graphics, sampled_cache_budget, draw_cache_reuse ON/OFF. New snapshot fixture passes on real NVIDIA host imports. This older base has a private StorageTexture constructor, so I changed the fixture's two make_shared calls to StorageTexture::Create; production lazy-snapshot code is unchanged. Branch: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-lazy-snapshot-cross-test . Graphics SHA256 2D6144562ED06C779E803C690A3F21AE0A2DB730FB78068FE33C023F2F18C254. Game test next, no memory/performance gain claimed yet. AI-assisted: Codex. Not full current-main/full-suite coverage. |
|
#3991 Windows follow-up efcd899/SHA2D614456: rendered title frame865 Campaign Resume now reproduces the runtime-table unsupported operation at shader0x3001136900 stage4 pc0x54 (descriptor0x3f00080260 etc.). It then terminates, rather than the RAM guard firing, on: |
|
@Scramblrrrr @Mouhand-Kaddo Thanks for the independent follow-ups. The Windows port's eight native passes, including The reported title runs use additional patches and different settings/cache states, so they do not isolate #3991's memory or FPS effect. The later 2,359,296,000-byte Vulkan buffer allocation failure also does not identify #3991 as its cause; allocation origin, memory type and lifetime need to be established first. I am keeping the PR's performance claim limited to the documented same-base early-startup A/B, with no menu, gameplay or whole-game memory claim. These reports do not currently call for a production-code change to this PR. AI-assisted: Codex read the reports and prepared this response; no new code or model-worker inference was needed. |
|
Linux follow-up for the tested head This was a combined integration stack: public-main snapshot The earlier Linux storage baseline/upload lifetime/upload failure checks remain the focused evidence. I do not attribute the complete title result or a memory reduction to this PR alone. Reproduction detail: the title run temporarily raised Linux |
|
The Windows job doesn't compile on 70015bd (https://github.com/boykopovar/AnyPS5/actions/runs/38259671911): |
|
Retest on Linux using updated #4456 head The title support stack remains #757/#758/#4288/#3991/#4402 plus the local grouped split-load correction. Five integration shader/graphics checks pass. Demon's Souls PPSA01342 rendered language/display settings and the online/offline prompt, then aborted with exit 134: This run did not verify main menu. The earlier c36-based integration did reach it. I have not isolated which rebased-stack change causes the descriptor failure, so this is not a regression attribution to this PR. No memory guard/OOM event stopped the run. One brief debugger snapshot was taken during startup, then detached. The temporary Linux udmabuf limit was again 2048 MiB for the title run and is now verified back at 64. Assets were read directly through an enforced read-only view of the Windows gaming drive, without copying the game. Original input hashes and timestamps are unchanged. AI-assisted testing/report. |
70015bd to
d2ebb51
Compare
|
Fixed in Local Windows validation passed: the recorder fixture and 124 runtime libraries built successfully; nine Vulkan checks passed on RTX 4070 with core validation, no skips or validation errors. Conventions passed. The snapshot test confirms 0 retained bytes for watched direct uploads and 262,144 bytes for CPU fallback. |
Create uploads before publishing snapshot validity. Keep allocation edits separate from the per-unit validity changes in boykopovar#5024.
d2ebb51 to
0612c18
Compare
What
Watched GPU-direct storage uploads resize the full
originalCPU vector even though that path invalidates the snapshot and uploads from imported guest memory. Allocate the vector only when capturing guest bytes, uploading through the CPU, or using CPU write-back. The factory completes the initial upload before publishing the texture; watched direct uploads establish an invalid, empty CPU snapshot. The private field initializer follows main. The separate generation baseline is unchanged.The CPU-fallback allocation sits immediately before the guest-byte read, after generation stamping. The CPU write-back allocation sits after the GPU-direct and unregistered-drop exits, before comparison-baseline handling. These locations avoid conflicts with #5024's per-unit CPU-write preservation; the initializer change is removed because the private factory establishes validity before publication. Both merge orders with #5024 head
e5449936fsucceed and produce the identical tree. Neither feature depends on the other. Earlier checks also verified both merge orders with #3949.The regression checks zero retained
originalsnapshot bytes for a watched shared-memory import, correct upload/refresh/write-back texels, comparison fallback after write tracking is removed, and import-disabled CPU upload/write-back.The Windows fixture registers its test surfaces with
gpu=true, matching the five-argumentMutation::AddAPI. Both fixture textures use the current publicStorageTexture::Createfactory; upstream made the constructor private, so directmake_sharedcalls no longer compile. The factory performs upload, view creation and live-image registration. The outer Windows guard remains.OriginalSnapshotBytes()reports retained vector capacity, including capacity left by earlier CPU fallbacks.Tested
Windows 11, MinGW GCC 15.2 Release, RTX 4070 Laptop GPU:
0612c181f, rebased onto main4bb2c7f39: fresh Release configure and build of the linked native recorder fixture, depth/storage and resource-cache test targets, and all 125 runtime libraries (libstarget). All 13 submodule checkouts match the current source pins; the cached pinned FFmpeg package is reused. This is not a build of every project target or a run of the whole test suite. The earlier clean pre-fix build reproduced the private-constructor/construct_aterror; the two public factory calls remain in place.ctest -R '^agc_storage_cpu_snapshot$' --output-on-failure --no-tests=error --timeout 30: passed in 1.14 s with Vulkan core validation enabled, no skips or validation errors. Watched GPU-directoriginalcapacity is 0 bytes; untracked/comparison and CPU fallback capacities are 262,144 bytes. Refresh/write-back texels and tracking removal are checked by the fixture.APS5_WRITE_WATCH_IMPORTS=unwatchmodes (0.68/0.41 s), with core validation and no skipped cases/errors. On Windows, the private test overlay uses the existing shared-memory mapping fixture instead of private committed backing so the left-watch case actually executes. The peer production code is unchanged; neither its feature nor this test overlay is included in this public PR. Local Ollama Qwen authored the isolated test adaptation; Codex reviewed/applied/tested it.0a8b1d32b; all other runtime libraries, title executable/assets, settings and cache seed are identical. Samples use WindowsWorkingSetSizeat displayed startup-frame counters 251-256, with 0.25 s polling. Empty recompiled-shader cache; texture/staging caches 512/64 MiB and resource-cache entries 16. Both 8 GiB process guards and the available-RAM/commit-headroom guards remained enabled; none were hit. Full paired numbers and method are provided in my response to the resident-memory request.The startup A/B above is historical evidence from the earlier public revision against base
0a8b1d32b; it was not repeated on this rebased head. The startup counters and dynamic image counts vary slightly because of asynchronous progress and polling (17-19 storage-image instances). The A/B covers early startup only, not steady-state memory, menu/gameplay correctness, or an 8 GiB fit throughout. Linux follow-up execution was not run locally. Independent contributor validation on the original head reports a clean Linux build, four existing tests and an Astro Bot check; these are the contributor's results. Raw title logs and proprietary assets remain local.Checklist
main; checked current main and relevant open PR changes for an equivalent allocation change.mdfiles or images added to the repositoryqwen3.8:27bas the coding worker. Each correction used one generation; Codex reviewed the exact patches and verified the builds/tests.