xmem: report the console title memory budget #513

Merged
csj0oe merged 1 commit from upstream-pr/513 into main 2026-11-29 22:20:08 +00:00
csj0oe commented 2026-11-29 18:29:04 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by csj0oe on 2026-11-29T18:29:04Z.


What

A Series X leaves a title 13,312 MiB. TuxBox reported host RAM and the whole process commit instead, wrote the same number into GameLimit and GpuOptimalBandwidthLimit, and reported the whole process as the title's usage. A title that sizes streaming pools or texture caches from GameLimit − GameUsed made a different decision on every PC.

  • One process-wide title ledger: limit 13,958,643,712 bytes (13,312 MiB), used from live allocations the title owns, peak high-water, physical page count from live 64 KiB pages.
  • XMemGetWorkingSetStatistics accepts any selector with top nibble 0x2, zeroes the 120-byte result, fills the selected groups and returns TRUE. XMEM_WORKING_SET_ALL now works instead of returning FALSE.
  • XMemGetFreePageStatistics derives availability from limit − used and keeps the 7-word shape the guest and pixrt10.dll consume.
  • history.rs and diagnostics.rs read the same snapshot.

Verification

  • python tuxbox.py check --no-gpu: 7/7 passed.
  • The xmem-partitions gate passes, with the guest now asserting the 13,312 MiB limit and that the physical page count follows XMemAllocatePhysicalPages.
  • The full tuxbox.py check first reported 11 timeouts in the cpu, cpu-benchmark, present and lanes-benchmark gates. That run used the proton backend with parallel prefix batching while a game was running on the same machine. All 12 gates pass in isolation on this branch and on main under the same Proton GE prefix; the CPU gates were repeated three times per branch. The timeouts were contention, not this change, and route-game.exe imports only KERNEL32.dll.

Deviations from the plan

  • The plan's byte count and MiB gloss disagreed (13,955,973,120 is 13,309.45 MiB). The code uses the documented 13,312 MiB, 13,958,643,712.
  • Free-page availability does not subtract token bytes again; the ledger already charges them, so subtracting would double-count.
  • XMemTransferMemory no longer changes GameLimit; the control and gate now assert budget_stable=1.
  • GPU-optimal usage is charged for graphics device allocations and placements, and the 10,240 MiB split is labelled inferred in code, guest and README.
  • The guest PASS string and the two verify.py regexes changed to match.

Not covered

  • XMemVirtualAlloc reservations and commits are not in used, so a title's largest buffers can still be missing from GameUsed.
  • Provider VRAM (Place::Card) is not counted; the console has one pool, the PC does not.
  • The GPU-optimal split and the graphics-as-optimal classification are inferences, not console measurements.
  • STACK, KERNEL_POOL, TOOLS and CPU_PTE groups are accepted but zero.
  • No native Windows run; the gate ran under Proton GE on Linux. No NVIDIA run, and the lanes-selftest row for runtime/xmem was not run.

Game-run evidence needed

A with/without run of the same title: GameLimit and GameUsed from the provider, peak process RSS, and whether the world streams as before. The two runs differ only by this branch. No title launch was possible in this session.

<!-- greyfinch-sync:brcly/TuxBox:issue:5553758357 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/513). Originally posted by [csj0oe](https://github.com/csj0oe) on 2026-11-29T18:29:04Z. --- ## What A Series X leaves a title 13,312 MiB. TuxBox reported host RAM and the whole process commit instead, wrote the same number into `GameLimit` and `GpuOptimalBandwidthLimit`, and reported the whole process as the title's usage. A title that sizes streaming pools or texture caches from `GameLimit − GameUsed` made a different decision on every PC. - One process-wide title ledger: limit 13,958,643,712 bytes (13,312 MiB), `used` from live allocations the title owns, `peak` high-water, physical page count from live 64 KiB pages. - `XMemGetWorkingSetStatistics` accepts any selector with top nibble `0x2`, zeroes the 120-byte result, fills the selected groups and returns `TRUE`. `XMEM_WORKING_SET_ALL` now works instead of returning `FALSE`. - `XMemGetFreePageStatistics` derives availability from `limit − used` and keeps the 7-word shape the guest and `pixrt10.dll` consume. - `history.rs` and `diagnostics.rs` read the same snapshot. ## Verification - `python tuxbox.py check --no-gpu`: 7/7 passed. - The `xmem-partitions` gate passes, with the guest now asserting the 13,312 MiB limit and that the physical page count follows `XMemAllocatePhysicalPages`. - The full `tuxbox.py check` first reported 11 timeouts in the `cpu`, `cpu-benchmark`, `present` and `lanes-benchmark` gates. That run used the proton backend with parallel prefix batching while a game was running on the same machine. All 12 gates pass in isolation on this branch and on `main` under the same Proton GE prefix; the CPU gates were repeated three times per branch. The timeouts were contention, not this change, and `route-game.exe` imports only `KERNEL32.dll`. ## Deviations from the plan - The plan's byte count and MiB gloss disagreed (`13,955,973,120` is 13,309.45 MiB). The code uses the documented 13,312 MiB, `13,958,643,712`. - Free-page availability does not subtract token bytes again; the ledger already charges them, so subtracting would double-count. - `XMemTransferMemory` no longer changes `GameLimit`; the control and gate now assert `budget_stable=1`. - GPU-optimal usage is charged for graphics device allocations and placements, and the 10,240 MiB split is labelled inferred in code, guest and README. - The guest PASS string and the two `verify.py` regexes changed to match. ## Not covered - `XMemVirtualAlloc` reservations and commits are not in `used`, so a title's largest buffers can still be missing from `GameUsed`. - Provider VRAM (`Place::Card`) is not counted; the console has one pool, the PC does not. - The GPU-optimal split and the graphics-as-optimal classification are inferences, not console measurements. - `STACK`, `KERNEL_POOL`, `TOOLS` and `CPU_PTE` groups are accepted but zero. - No native Windows run; the gate ran under Proton GE on Linux. No NVIDIA run, and the `lanes-selftest` row for `runtime/xmem` was not run. ## Game-run evidence needed A with/without run of the same title: `GameLimit` and `GameUsed` from the provider, peak process RSS, and whether the world streams as before. The two runs differ only by this branch. No title launch was possible in this session.
brcly commented 2026-11-29 18:32:15 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T18:32:15Z.


I'm in 2 minds about this.

Although it is "correct", it's not necessary; all games I've tested so far have stayed within the 13.5GB budget.

<!-- greyfinch-sync:brcly/TuxBox:comment:7260560842 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/513#issuecomment-7260560842). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T18:32:15Z. --- I'm in 2 minds about this. Although it is "correct", it's not necessary; all games I've tested so far have stayed within the 13.5GB budget.
brcly commented 2026-11-29 20:37:59 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T20:37:59Z.


Thanks. Reporting the console's 13,312 MiB budget instead of host RAM is the right model. Since the title sizes its streaming pools and caches from GameLimit − GameUsed, this will change how much memory ProjectScarlett uses, possibly for the better. Before merging we need a game run with and without it: the reported numbers, peak process memory, and whether the world still streams in properly. If you can post that, great. Otherwise we'll run it here.

<!-- greyfinch-sync:brcly/TuxBox:comment:7262235644 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/513#issuecomment-7262235644). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T20:37:59Z. --- Thanks. Reporting the console's 13,312 MiB budget instead of host RAM is the right model. Since the title sizes its streaming pools and caches from `GameLimit − GameUsed`, this will change how much memory ProjectScarlett uses, possibly for the better. Before merging we need a game run with and without it: the reported numbers, peak process memory, and whether the world still streams in properly. If you can post that, great. Otherwise we'll run it here.
Sign in to join this conversation.
No reviewers
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
brcly/TuxBox!513
No description provided.