xmem: trace the title budget once #553

Open
csj0oe wants to merge 1 commit from upstream-pr/553 into main
csj0oe commented 2026-11-29 22:34:07 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by csj0oe on 2026-11-29T22:34:07Z.


What

TUXBOX_TRACE_XMEM=1 prints the title memory budget once, on stderr, the first time a title asks for the working-set statistics:

xmem: budget selector=0x2000001f limit=13958643712 used=0 peak=0 physical_pages=0

This is the observable that the budget change needs: without it a launch cannot report GameLimit, GameUsed, the high-water mark or the live 64 KiB page count, so a with/without run has nothing to compare.

  • The line is formatted by a pure function and pinned by a unit test with fixed numbers and a zero ledger.
  • A one-shot flag and the environment check come first, so it is inert when the variable is unset; the same run without the variable prints nothing.
  • The guest PASS lines are unchanged.
  • Documented in docs/ENVIRONMENT.md beside TUXBOX_TRACE_XMEM_BACKING.

Verification

  • python build.py xmem; tuxbox.py verify --only xmem --backend wine — 12/12 PASS.
  • python tuxbox.py check --no-gpu — 9/9.
  • The line appears exactly once in the guest run with the variable set, and zero times without it.

Not run

lanes-selftest and the buffer cases of the D3D12 regression controls; NVIDIA is not available on this machine.

<!-- greyfinch-sync:brcly/TuxBox:issue:5555869755 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/553). Originally posted by [csj0oe](https://github.com/csj0oe) on 2026-11-29T22:34:07Z. --- ## What `TUXBOX_TRACE_XMEM=1` prints the title memory budget once, on stderr, the first time a title asks for the working-set statistics: ``` xmem: budget selector=0x2000001f limit=13958643712 used=0 peak=0 physical_pages=0 ``` This is the observable that the budget change needs: without it a launch cannot report `GameLimit`, `GameUsed`, the high-water mark or the live 64 KiB page count, so a with/without run has nothing to compare. - The line is formatted by a pure function and pinned by a unit test with fixed numbers and a zero ledger. - A one-shot flag and the environment check come first, so it is inert when the variable is unset; the same run without the variable prints nothing. - The guest PASS lines are unchanged. - Documented in `docs/ENVIRONMENT.md` beside `TUXBOX_TRACE_XMEM_BACKING`. ## Verification - `python build.py xmem`; `tuxbox.py verify --only xmem --backend wine` — 12/12 PASS. - `python tuxbox.py check --no-gpu` — 9/9. - The line appears exactly once in the guest run with the variable set, and zero times without it. ## Not run `lanes-selftest` and the buffer cases of the D3D12 regression controls; NVIDIA is not available on this machine.
brcly commented 2026-11-30 04:12:12 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:12Z.


Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase.

  • Formatting: the whole workspace is now formatted with rustfmt (see the new rustfmt.toml).
  • Lints: every crate denies unwrap(), lossy as casts and undocumented unsafe outside tests.
  • CI: it now also runs cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.

The least painful way is to format your branch first, so the rebase only shows real changes:

git fetch origin
git checkout origin/main -- rustfmt.toml
cargo fmt --all && git commit -am "rustfmt"
git rebase origin/main

Then run python tuxbox.py check --no-gpu, which now includes the format step.

If clippy flags something new:

  • A cast: use From for widening, TryFrom for narrowing, and a mask for bit fields.
  • An unwrap(): use ?, or expect with the reason it can't fail.
  • An unsafe block: it needs a // SAFETY: comment.

CONTRIBUTING's "Code checks" section lists the commands. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7268560406 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/553#issuecomment-7268560406). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:12:12Z. --- Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase. - **Formatting:** the whole workspace is now formatted with rustfmt (see the new `rustfmt.toml`). - **Lints:** every crate denies `unwrap()`, lossy `as` casts and undocumented `unsafe` outside tests. - **CI:** it now also runs `cargo fmt --check`, rustdoc with warnings denied, and Miri on the providers' unit tests. The least painful way is to format your branch first, so the rebase only shows real changes: ```sh git fetch origin git checkout origin/main -- rustfmt.toml cargo fmt --all && git commit -am "rustfmt" git rebase origin/main ``` Then run `python tuxbox.py check --no-gpu`, which now includes the format step. If clippy flags something new: - **A cast:** use `From` for widening, `TryFrom` for narrowing, and a mask for bit fields. - **An `unwrap()`:** use `?`, or `expect` with the reason it can't fail. - **An `unsafe` block:** it needs a `// SAFETY:` comment. CONTRIBUTING's "Code checks" section lists the commands. Thanks!
brcly commented 2026-11-30 11:45:39 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T11:45:39Z.


Thanks for the rebase. The problem is when the line prints. It prints once, the first time the title asks for its statistics, which is at startup, before it has allocated anything. The example in the description shows exactly that: used=0 peak=0 physical_pages=0. So the one line a run gets reports only the limit, which is a constant. It can't show a with/without difference in what the title uses, and that difference is what you say the budget work needs.

For it to be the observable you describe, it needs to report use over the run. For example:

  • a line each time the peak passes a new step (every 256 MiB, say), with the selector; or
  • the same line every few seconds while the variable is set, the way TUXBOX_XCRD_LOG does.

Then please include the lines from one real run in the PR, so we can see it measure something. Until then I'm holding this, like the other diagnostic-only PRs.

<!-- greyfinch-sync:brcly/TuxBox:comment:7277483941 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/553#issuecomment-7277483941). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T11:45:39Z. --- Thanks for the rebase. The problem is when the line prints. It prints once, the first time the title asks for its statistics, which is at startup, before it has allocated anything. The example in the description shows exactly that: `used=0 peak=0 physical_pages=0`. So the one line a run gets reports only the limit, which is a constant. It can't show a with/without difference in what the title uses, and that difference is what you say the budget work needs. For it to be the observable you describe, it needs to report use over the run. For example: - a line each time the peak passes a new step (every 256 MiB, say), with the selector; or - the same line every few seconds while the variable is set, the way `TUXBOX_XCRD_LOG` does. Then please include the lines from one real run in the PR, so we can see it measure something. Until then I'm holding this, like the other diagnostic-only PRs.
brcly commented 2026-12-02 21:31:01 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-12-02T21:31:01Z.


Thanks, this looks good and we'd like to take it. It now conflicts with main: 03bf6918 (xmem: honor GDK allocation contracts and title memory profiles) changed runtime/xmem/src/title_memory.rs, and docs/ENVIRONMENT.md has moved too. Your new tests build Snapshot with the old fields and the LIMIT/GPU_LIMIT constants, so they'll need updating to the new snapshot. Could you rebase onto main? We'll merge once it's clean and CI is green.

<!-- greyfinch-sync:brcly/TuxBox:comment:7359390414 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/553#issuecomment-7359390414). Originally posted by [brcly](https://github.com/brcly) on 2026-12-02T21:31:01Z. --- Thanks, this looks good and we'd like to take it. It now conflicts with main: `03bf6918` (xmem: honor GDK allocation contracts and title memory profiles) changed `runtime/xmem/src/title_memory.rs`, and `docs/ENVIRONMENT.md` has moved too. Your new tests build `Snapshot` with the old fields and the `LIMIT`/`GPU_LIMIT` constants, so they'll need updating to the new snapshot. Could you rebase onto main? We'll merge once it's clean and CI is green.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/553:upstream-pr/553'
git switch 'upstream-pr/553'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/553'
git switch 'upstream-pr/553'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/553'
git switch 'upstream-pr/553'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/553'
git switch 'main'
git merge --squash 'upstream-pr/553'
git switch 'main'
git merge --ff-only 'upstream-pr/553'
git switch 'main'
git merge 'upstream-pr/553'
git push origin 'main'
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!553
No description provided.