AGC: overlapping 2560x1440 storage images in MXGP 26 are recreated and re-uploaded through the CPU path hundreds of times #6998

Open
opened 2026-10-17 03:32:04 +00:00 by milescoviello · 1 comment
milescoviello commented 2026-10-17 03:32:04 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T03:32:04Z.


What happens

In some runs of MXGP 26 (PPSA30839), overlapping 2560x1440 storage images keep re-uploading each other from guest memory through the CPU path. A normal run uploads about 10 storage images in 130 s. A run with this behaviour uploads 220–500, memmove takes about 29% of all samples, and in builds with #6921 the 100–110 s window drops from about 51 to about 24 presents.

Setup: Linux 6.8, NVIDIA GeForce RTX 4070 Ti (595.99.02), Release, pad input. main doesn't reach this scene, so all runs use main 143f130553 plus the PRs MXGP needs (#6814, #6094, #6160, #6308, #6184, #6455) and #6896's trace timer. It happens with and without #6917 and #6921 (details on #6921).

What a log of each CPU-path upload shows

The log is local, not for merging. In StorageTexture's CPU upload path it prints the address, size, uploadReason and version. A run with the re-uploads (252 uploads), the 2560x1440 ones near the start of the burst:

cpu upload 9  of 0x1232cf0000+0xf00000 2560x1440 reason first version 0
cpu upload 10 of 0x1223410000+0xf00000 2560x1440 reason first version 0
cpu upload 11 of 0x1224720000+0xf00000 2560x1440 reason first version 0
cpu upload 12 of 0x1224720000+0xf00000 2560x1440 reason first version 0
cpu upload 13 of 0x1223860000+0xf00000 2560x1440 reason first version 0
cpu upload 14 of 0x1224760000+0x3c0000 2560x1440 reason first version 0
cpu upload 15 of 0x1224b70000+0xf00000 2560x1440 reason first version 0
  • Several 2560x1440 images overlap in guest memory: 0x1224720000+0xf00000 covers 0x1224760000 and 0x1224b70000.
  • Images at the same address are created again (reason first, version 0: a new StorageTexture each time).
  • The log prints the first 60 uploads and then every power of two. Of the 62 lines in this run, the reasons are store 30, first 18, flushed 13 and keys 1. In two earlier logged runs, two of these images then upload alternately, dozens of times.
  • Every storage upload in MXGP takes the CPU path, in normal runs too: HostImportFor returns null for these ranges, the pages are accessible and committed, and the keys are uncompressed. So the cost comes from the number of uploads, not from the path changing.
  • Host imports don't fail (APS5_TRACE_HOST_IMPORT=1: 0 failures, about 4.4 GiB live).

How often

Build Runs with more than 100 storage uploads
stack, stack + #6917, two measurement builds 0 of 36
stack + #6917 + #6921 4 of 31
stack + #6917 + the upload log above 3 of 6
stack + #6917 + #6921 + the upload log 8 of 14

The log only adds work in that path (a HostImportFor and DescribeCommitted call per upload), and it makes the behaviour much more likely. That suggests the title's placement of these targets, or the order in which they're created, depends on timing, and the emulator handles an overlapping placement by flushing and recreating the images, not by aliasing them.

Not checked

  • Whether the title really writes these ranges through other views, or only reuses the memory for differently-sized targets.
  • Other titles, Windows, AMD/Intel.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5894412209 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6998). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-17T03:32:04Z. --- ### What happens In some runs of MXGP 26 (PPSA30839), overlapping 2560x1440 storage images keep re-uploading each other from guest memory through the CPU path. A normal run uploads about 10 storage images in 130 s. A run with this behaviour uploads 220–500, `memmove` takes about 29% of all samples, and in builds with #6921 the 100–110 s window drops from about 51 to about 24 presents. Setup: Linux 6.8, NVIDIA GeForce RTX 4070 Ti (595.99.02), Release, pad input. `main` doesn't reach this scene, so all runs use `main` 143f130553 plus the PRs MXGP needs (#6814, #6094, #6160, #6308, #6184, #6455) and #6896's trace timer. It happens with and without #6917 and #6921 (details on #6921). ### What a log of each CPU-path upload shows The log is local, not for merging. In `StorageTexture`'s CPU upload path it prints the address, size, `uploadReason` and `version`. A run with the re-uploads (252 uploads), the 2560x1440 ones near the start of the burst: ``` cpu upload 9 of 0x1232cf0000+0xf00000 2560x1440 reason first version 0 cpu upload 10 of 0x1223410000+0xf00000 2560x1440 reason first version 0 cpu upload 11 of 0x1224720000+0xf00000 2560x1440 reason first version 0 cpu upload 12 of 0x1224720000+0xf00000 2560x1440 reason first version 0 cpu upload 13 of 0x1223860000+0xf00000 2560x1440 reason first version 0 cpu upload 14 of 0x1224760000+0x3c0000 2560x1440 reason first version 0 cpu upload 15 of 0x1224b70000+0xf00000 2560x1440 reason first version 0 ``` - Several 2560x1440 images overlap in guest memory: `0x1224720000+0xf00000` covers `0x1224760000` and `0x1224b70000`. - Images at the same address are created again (`reason first`, `version 0`: a new `StorageTexture` each time). - The log prints the first 60 uploads and then every power of two. Of the 62 lines in this run, the reasons are `store` 30, `first` 18, `flushed` 13 and `keys` 1. In two earlier logged runs, two of these images then upload alternately, dozens of times. - Every storage upload in MXGP takes the CPU path, in normal runs too: `HostImportFor` returns null for these ranges, the pages are accessible and committed, and the keys are uncompressed. So the cost comes from the number of uploads, not from the path changing. - Host imports don't fail (`APS5_TRACE_HOST_IMPORT=1`: 0 failures, about 4.4 GiB live). ### How often | Build | Runs with more than 100 storage uploads | |---|---| | stack, stack + #6917, two measurement builds | 0 of 36 | | stack + #6917 + #6921 | 4 of 31 | | stack + #6917 + the upload log above | 3 of 6 | | stack + #6917 + #6921 + the upload log | 8 of 14 | The log only adds work in that path (a `HostImportFor` and `DescribeCommitted` call per upload), and it makes the behaviour much more likely. That suggests the title's placement of these targets, or the order in which they're created, depends on timing, and the emulator handles an overlapping placement by flushing and recreating the images, not by aliasing them. ### Not checked - Whether the title really writes these ranges through other views, or only reuses the memory for differently-sized targets. - Other titles, Windows, AMD/Intel. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-17 04:52:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T04:52:22Z.


Likely cause, and a PR that addresses it: #6197.

StorageTexture::Refresh takes another image's pending units on the device (the alias exemption, borrowUnits) only when HostImportFor returns an import for the range. MXGP's 15 MiB storage images each cross an 8 MiB import window, so they never get one: every upload takes the CPU path, and overlapping images flush and re-upload each other instead. With #6197 (d7f5ffb043) on the same stack, those images import through a joined import:

  • CPU-path storage uploads drop from 9–13 to 2 per run.
  • The re-upload burst happened in 0 of 6 runs, against 4 of 12 without it (same upload log, same session for 6 of the 12).

Details on #6197. I'll close this once #6197 is merged and the burst stays away on main.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6229848164 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6998#issuecomment-6229848164). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-17T04:52:22Z. --- Likely cause, and a PR that addresses it: #6197. `StorageTexture::Refresh` takes another image's pending units on the device (the alias exemption, `borrowUnits`) only when `HostImportFor` returns an import for the range. MXGP's 15 MiB storage images each cross an 8 MiB import window, so they never get one: every upload takes the CPU path, and overlapping images flush and re-upload each other instead. With #6197 (`d7f5ffb043`) on the same stack, those images import through a joined import: - CPU-path storage uploads drop from 9–13 to 2 per run. - The re-upload burst happened in 0 of 6 runs, against 4 of 12 without it (same upload log, same session for 6 of the 12). Details on #6197. I'll close this once #6197 is merged and the burst stays away on `main`. 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#6998
No description provided.