[pr-fix][memory] A title free reaches the paged copies even with nothing in place #321

Open
ntsthay wants to merge 1 commit from ntsthay/title-free-paged into main AGit
First-time contributor

Not run in the game. A unit test shows the problem: it fails on main and passes with this change.

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: a unit test. a_title_free_reaches_the_paged_copies_with_nothing_in_place fails on f3840d7 with left: [], right: [(1098842112, 65536)], because the free never reaches shadow::paged_freed.

watch::title_memory_freed told the copies held page by page about a free only through inplace::title_memory_freeing, and it called that only when something was in place (inplace::holds_any()). In play nothing is in place, so with DARNER_PAGE_BUFFERS=2 or 3 the paged copies never learn that the title freed or decommitted the memory under them. Under mode 2, tiles that lie wholly inside a freed range keep their memory. Under mode 3, which play sets, the report leaves out the bytes kept under freed tiles.

The telling now lives in tell_holders_of_freed_memory. When nothing is in place and a paged mode is on, it calls shadow::paged_freed itself, so each free reaches the paged copies once: through inplace when something is in place, directly when nothing is. freed_len replaces the two copies of the "length, or the whole allocation" computation.

The hook in shadow.rs is #[cfg(test)] only. It records the ranges paged_freed was asked about, since a real paged copy needs the adapter.

How it was tested

  • Tested revision: 6a00b27, this branch on f3840d7.
  • Commands and results:
    • cargo test -p darner-gpu --lib a_title_free: passes on 6a00b27, fails on f3840d7 with the message above.
    • cargo test -p darner-gpu --lib -- --test-threads=1 watch:: shadow::: 199 passed and 10 ignored on 6a00b27 (209 tests, the new one included); 198 passed and 10 ignored on f3840d7.
  • Changes a default: no. Behaviour changes only when a paged mode is on and the title frees memory with nothing in place.
  • A/B result: none. The PR makes no speed or memory claim.
  • Gates run on 6a00b27: gates 1 and 2 (cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features) are clean. Gate 3 ran under Wine (Proton on Linux, RTX 4080), not on Windows, and only the darner-gpu tests above count as passed. Under Wine some tests fail on f3840d7 too, such as tests::windows_is_not_wine, the run::tests::late_dll_* tests, and some darner-gpu font, panel and pipeline tests. None of them is in the files this PR changes.
  • Gameplay: not run.
  • Hardware dependence: likely general. The change is in title memory bookkeeping, not on the card.
  • Coverage gaps: no game run and no run on Windows.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

It was not run in the game. In play its effect is a count in the report under mode 3, or tiles given back under mode 2, and the unit test covers the path.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #300 and #310 also change watch.rs, for landed pages, which is a different problem.
  • Replaces or overlaps: none found
Not run in the game. A unit test shows the problem: it fails on `main` and passes with this change. ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: a unit test. `a_title_free_reaches_the_paged_copies_with_nothing_in_place` fails on `f3840d7` with `left: []`, `right: [(1098842112, 65536)]`, because the free never reaches `shadow::paged_freed`. `watch::title_memory_freed` told the copies held page by page about a free only through `inplace::title_memory_freeing`, and it called that only when something was in place (`inplace::holds_any()`). In play nothing is in place, so with `DARNER_PAGE_BUFFERS=2` or `3` the paged copies never learn that the title freed or decommitted the memory under them. Under mode 2, tiles that lie wholly inside a freed range keep their memory. Under mode 3, which `play` sets, the report leaves out the bytes kept under freed tiles. The telling now lives in `tell_holders_of_freed_memory`. When nothing is in place and a paged mode is on, it calls `shadow::paged_freed` itself, so each free reaches the paged copies once: through `inplace` when something is in place, directly when nothing is. `freed_len` replaces the two copies of the "length, or the whole allocation" computation. The hook in `shadow.rs` is `#[cfg(test)]` only. It records the ranges `paged_freed` was asked about, since a real paged copy needs the adapter. ## How it was tested - Tested revision: `6a00b27`, this branch on `f3840d7`. - Commands and results: - `cargo test -p darner-gpu --lib a_title_free`: passes on `6a00b27`, fails on `f3840d7` with the message above. - `cargo test -p darner-gpu --lib -- --test-threads=1 watch:: shadow::`: 199 passed and 10 ignored on `6a00b27` (209 tests, the new one included); 198 passed and 10 ignored on `f3840d7`. - Changes a default: no. Behaviour changes only when a paged mode is on and the title frees memory with nothing in place. - A/B result: none. The PR makes no speed or memory claim. - Gates run on `6a00b27`: gates 1 and 2 (`cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`) are clean. Gate 3 ran under Wine (Proton on Linux, RTX 4080), not on Windows, and only the `darner-gpu` tests above count as passed. Under Wine some tests fail on `f3840d7` too, such as `tests::windows_is_not_wine`, the `run::tests::late_dll_*` tests, and some `darner-gpu` font, panel and pipeline tests. None of them is in the files this PR changes. - Gameplay: not run. - Hardware dependence: likely general. The change is in title memory bookkeeping, not on the card. - Coverage gaps: no game run and no run on Windows. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none It was not run in the game. In play its effect is a count in the report under mode 3, or tiles given back under mode 2, and the unit test covers the path. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #300 and #310 also change `watch.rs`, for landed pages, which is a different problem. - Replaces or overlaps: none found
First-time contributor

Independent Windows build, gate, and code-read review of head 6a00b277ad8db247ff0187a6045b026683991567, based on main f3840d73d3504c30218debfbc8795b9225447317. Not run in-game.

Environment

  • Windows 11 Pro 26H2 (build 26300.10075), Intel Core i9-14900K, NVIDIA RTX A2000 12GB (driver 621.47), Rust 1.98.1 (x86_64-pc-windows-msvc), MSVC 19.44.35230.

Measured results

  • Gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings): PASS.
  • Gate 2 (cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASS.
  • cargo xtask policy: PASS (asset policy: 555 files ok).
  • cargo test --locked -p darner-gpu --lib a_title_free: PASS (1 passed; 0 failed; 0 ignored).
  • cargo test --locked -p darner-gpu --lib watch:: -- --test-threads=1: 88 passed; 1 failed; 0 ignored. cargo test --locked -p darner-gpu --lib watch::tests::ask_once_by_res_splits_reservations_without_refusals -- --exact on current main: 1 passed; 0 failed; 0 ignored.
  • cargo test --locked -p darner-gpu --lib shadow:: -- --test-threads=1: 109 passed; 1 failed; 10 ignored. cargo test --locked -p darner-gpu --lib shadow::wide_tests::nested_wide_each_scoped_handles_overflow_concurrency_and_panics -- --exact also fails on current main (0 passed; 1 failed; 0 ignored).

Code-read audit

  • freed_len preserves the old explicit-length versus whole-allocation calculation. tell_holders_of_freed_memory avoids allocation queries when there is no consumer and no length, retains texture::remapped, and routes through inplace::title_memory_freeing when in-place state exists; otherwise it calls shadow::paged_freed directly (crates/darner-gpu/src/watch.rs:5903-5937). The in-place path already calls paged_freed once (crates/darner-gpu/src/inplace.rs:523-535), so the new branch avoids duplicate notification.
  • shadow::paged_freed keeps its existing mode-2 release and mode-3 accounting behavior; the added thread-local call recorder is test-only (crates/darner-gpu/src/shadow.rs:951-1007). The regression test clears and checks that recorder around a fresh allocation/free (crates/darner-gpu/src/watch.rs:6927-6953).
  • The broader-suite failures were not introduced by this diff: the shadow failure reproduces on main, and the watch failure is the known flaky test and passed isolated on main. The targeted regression passes on this head.

No blocking issue found.

Verdict: PASS.

AI-assisted: yes (GitHub Copilot, Auto mode).

Independent Windows build, gate, and code-read review of head `6a00b277ad8db247ff0187a6045b026683991567`, based on `main` `f3840d73d3504c30218debfbc8795b9225447317`. Not run in-game. ### Environment - Windows 11 Pro 26H2 (build 26300.10075), Intel Core i9-14900K, NVIDIA RTX A2000 12GB (driver 621.47), Rust 1.98.1 (`x86_64-pc-windows-msvc`), MSVC 19.44.35230. ### Measured results - Gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`): **PASS**. - Gate 2 (`cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`): **PASS**. - `cargo xtask policy`: **PASS** (`asset policy: 555 files ok`). - `cargo test --locked -p darner-gpu --lib a_title_free`: **PASS** (`1 passed; 0 failed; 0 ignored`). - `cargo test --locked -p darner-gpu --lib watch:: -- --test-threads=1`: **88 passed; 1 failed; 0 ignored**. `cargo test --locked -p darner-gpu --lib watch::tests::ask_once_by_res_splits_reservations_without_refusals -- --exact` on current `main`: **1 passed; 0 failed; 0 ignored**. - `cargo test --locked -p darner-gpu --lib shadow:: -- --test-threads=1`: **109 passed; 1 failed; 10 ignored**. `cargo test --locked -p darner-gpu --lib shadow::wide_tests::nested_wide_each_scoped_handles_overflow_concurrency_and_panics -- --exact` also fails on current `main` (**0 passed; 1 failed; 0 ignored**). ### Code-read audit - `freed_len` preserves the old explicit-length versus whole-allocation calculation. `tell_holders_of_freed_memory` avoids allocation queries when there is no consumer and no length, retains `texture::remapped`, and routes through `inplace::title_memory_freeing` when in-place state exists; otherwise it calls `shadow::paged_freed` directly (`crates/darner-gpu/src/watch.rs:5903-5937`). The in-place path already calls `paged_freed` once (`crates/darner-gpu/src/inplace.rs:523-535`), so the new branch avoids duplicate notification. - `shadow::paged_freed` keeps its existing mode-2 release and mode-3 accounting behavior; the added thread-local call recorder is test-only (`crates/darner-gpu/src/shadow.rs:951-1007`). The regression test clears and checks that recorder around a fresh allocation/free (`crates/darner-gpu/src/watch.rs:6927-6953`). - The broader-suite failures were not introduced by this diff: the shadow failure reproduces on `main`, and the watch failure is the known flaky test and passed isolated on `main`. The targeted regression passes on this head. No blocking issue found. **Verdict: PASS.** AI-assisted: yes (GitHub Copilot, Auto mode).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/321/head:ntsthay/title-free-paged'
git switch 'ntsthay/title-free-paged'

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 'ntsthay/title-free-paged'
git switch 'ntsthay/title-free-paged'
git rebase 'main'
git switch 'main'
git merge --ff-only 'ntsthay/title-free-paged'
git switch 'ntsthay/title-free-paged'
git rebase 'main'
git switch 'main'
git merge --no-ff 'ntsthay/title-free-paged'
git switch 'main'
git merge --squash 'ntsthay/title-free-paged'
git switch 'main'
git merge --ff-only 'ntsthay/title-free-paged'
git switch 'main'
git merge 'ntsthay/title-free-paged'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!321
No description provided.