gpu(descriptor,shadow): unpin idle loose window buffers on sweeper path (-4.7 GB Working Set) #508

Open
hingeowl wants to merge 1 commit from hingeowl/Darner:pr/unpin-idle-buffers into Main
Contributor

What it changes

  • The problem on main: loose window buffers (Arc::strong_count == 1, idle >= 15 s) can remain pinned by stale HostHeap::kept COM references (COM refs > 1), preventing shadow::let_go_idle from freeing them and inflating process Working Set during long city flights.
  • Adapted from ReTerryDavis/ReVIctory (5c47b6d8bc88ba11f07dae52c38bf9fe2edd80a3), sweeper-only path (intentionally omits the draw::heap_buffer_pass VirtualQuery probe, which regressed cam-city60 p95 by +17 ms / p99 by +37 ms in A/B testing):
    • Adds HostHeap::unpin_buffers and descriptor::unpin_idle_buffers.
    • Calls descriptor::unpin_idle_buffers(&targets) every 3 s in shadow::let_go_idle for idle loose windows so stale HostHeap::kept COM references release and let_go_idle can free them.

How it was tested

  • Tested revision: e20ecf3 (rebased onto main c8258f9)

  • Commands and results:

    • cargo xtask policy — pass
    • cargo clippy --workspace --all-targets --locked -- -D warnings — pass
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — pass
    • cargo test -p darner-gpu --locked — pass
  • Changes a default: yes (sweeper unpins idle loose window buffers automatically during let_go_idle).

  • A/B result (cam-city60, ABBA 4 runs on RTX 4090 + Ryzen 9 7950X3D, Series X, HW RT, --profile fast):

    Metric A (off) B (on, sweeper-only) Delta
    Peak Working Set 35,445 MB 30,719 MB -4,726 MB (-13.3%)
    Median frame time 107.0 ms 106.5 ms -0.5%
    P99 frame time 189.2 ms 184.7 ms -2.4%
    Overall FPS 9.00 9.09 +1.0%
  • Gates run on that revision: cargo xtask policy, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, cargo test -p darner-gpu --locked.

  • Gameplay: RTX 4090 (24 GB), Ryzen 9 7950X3D, Series X profile, HW RT.

  • Hardware dependence: likely general (reduces host RAM working set on all GPUs).

  • Coverage gaps: full workspace cargo test --workspace --locked not re-run on e20ecf3 (only darner-gpu, the only modified crate).

Checklist

  • I ran this change in the game.
  • 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

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found
  • Replaces or overlaps: none found
## What it changes - The problem on main: loose window buffers (`Arc::strong_count == 1`, idle >= 15 s) can remain pinned by stale `HostHeap::kept` COM references (`COM refs > 1`), preventing `shadow::let_go_idle` from freeing them and inflating process Working Set during long city flights. - Adapted from `ReTerryDavis/ReVIctory` (`5c47b6d8bc88ba11f07dae52c38bf9fe2edd80a3`), **sweeper-only path** (intentionally omits the `draw::heap_buffer_pass` `VirtualQuery` probe, which regressed `cam-city60` p95 by +17 ms / p99 by +37 ms in A/B testing): - Adds `HostHeap::unpin_buffers` and `descriptor::unpin_idle_buffers`. - Calls `descriptor::unpin_idle_buffers(&targets)` every 3 s in `shadow::let_go_idle` for idle loose windows so stale `HostHeap::kept` COM references release and `let_go_idle` can free them. ## How it was tested - Tested revision: `e20ecf3` (rebased onto `main` `c8258f9`) - Commands and results: - `cargo xtask policy` — pass - `cargo clippy --workspace --all-targets --locked -- -D warnings` — pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` — pass - `cargo test -p darner-gpu --locked` — pass - Changes a default: yes (sweeper unpins idle loose window buffers automatically during `let_go_idle`). - A/B result (`cam-city60`, ABBA 4 runs on RTX 4090 + Ryzen 9 7950X3D, Series X, HW RT, `--profile fast`): | Metric | A (off) | B (on, sweeper-only) | Delta | |---|---:|---:|---:| | Peak Working Set | 35,445 MB | 30,719 MB | **-4,726 MB (-13.3%)** | | Median frame time | 107.0 ms | 106.5 ms | -0.5% | | P99 frame time | 189.2 ms | 184.7 ms | -2.4% | | Overall FPS | 9.00 | 9.09 | +1.0% | - Gates run on that revision: `cargo xtask policy`, `cargo clippy --workspace --all-targets --locked -- -D warnings`, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`, `cargo test -p darner-gpu --locked`. - Gameplay: RTX 4090 (24 GB), Ryzen 9 7950X3D, Series X profile, HW RT. - Hardware dependence: likely general (reduces host RAM working set on all GPUs). - Coverage gaps: full workspace `cargo test --workspace --locked` not re-run on `e20ecf3` (only `darner-gpu`, the only modified crate). ## Checklist - [x] I ran this change in the game. - [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 ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found - Replaces or overlaps: none found
Adapted from ReTerryDavis/ReVIctory 5c47b6d8bc88ba11f07dae52c38bf9fe2edd80a3
(sweeper-only path; intentionally omits draw::heap_buffer_pass VirtualQuery probe
which regressed cam-city60 p95 by +17 ms / p99 by +37 ms):
- Add HostHeap::unpin_buffers and descriptor::unpin_idle_buffers.
- Call descriptor::unpin_idle_buffers(&targets) every 3 s in shadow::let_go_idle
  for idle loose windows (Arc::strong_count == 1, idle >= 15 s, COM refs > 1) so
  stale HostHeap::kept COM references release and let_go_idle can free them.

Upstream-Repository: https://github.com/ReTerryDavis/ReVIctory
Upstream-Commit: 5c47b6d8bc88ba11f07dae52c38bf9fe2edd80a3
Integration-Base: f64ece8d16e8c7cb27964d540f60909e84fe97c7
Validation: cam-city60 ABBA on RTX 4090 + 7950X3D (-4,726 MB / -13.3% peak Working Set, -0.5% med ms, -2.4% p99 ms, +1.0% overall fps); cargo clippy -p darner-gpu --features bench-remote --all-targets -- -D warnings
TrustNo1 changed title from [pr-performance][memory] gpu(descriptor,shadow): unpin idle loose window buffers on sweeper path (-4.7 GB Working Set) to gpu(descriptor,shadow): unpin idle loose window buffers on sweeper path (-4.7 GB Working Set) 2026-12-06 03:27:52 +00:00
Owner

Test needed — commit e20ecf34; what to check:

  • The problem on main: loose window buffers (Arc::strong_count == 1, idle >= 15 s) can remain pinned by stale HostHeap::kept COM references (COM refs > 1), preventing shadow::let_go_idle from freeing them and inflating process Working Set during long city flights.
  • Adapted from ReTerryDavis/ReVIctory (5c47b6d8bc88ba11f07dae52c38bf9fe2edd80a3), sweeper-only path (intentionally omits the draw::heap_buffer_pass VirtualQuery probe, which regressed cam-city60 p95 by +17 ms / p99 by +37 ms in A/B testing):
    • Adds HostHeap::unpin_buffers and descriptor::unpin_idle_buffers.
    • Calls descriptor::unpin_idle_buffers(&targets) every 3 s in shadow::let_go_idle for idle loose windows so stale HostHeap::kept COM references release and let_go_idle can free them.

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `e20ecf34`; what to check: - The problem on main: loose window buffers (`Arc::strong_count == 1`, idle >= 15 s) can remain pinned by stale `HostHeap::kept` COM references (`COM refs > 1`), preventing `shadow::let_go_idle` from freeing them and inflating process Working Set during long city flights. - Adapted from `ReTerryDavis/ReVIctory` (`5c47b6d8bc88ba11f07dae52c38bf9fe2edd80a3`), **sweeper-only path** (intentionally omits the `draw::heap_buffer_pass` `VirtualQuery` probe, which regressed `cam-city60` p95 by +17 ms / p99 by +37 ms in A/B testing): - Adds `HostHeap::unpin_buffers` and `descriptor::unpin_idle_buffers`. - Calls `descriptor::unpin_idle_buffers(&targets)` every 3 s in `shadow::let_go_idle` for idle loose windows so stale `HostHeap::kept` COM references release and `let_go_idle` can free them. Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
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 'pr/unpin-idle-buffers:hingeowl-pr/unpin-idle-buffers'
git switch 'hingeowl-pr/unpin-idle-buffers'

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 'hingeowl-pr/unpin-idle-buffers'
git switch 'hingeowl-pr/unpin-idle-buffers'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'hingeowl-pr/unpin-idle-buffers'
git switch 'hingeowl-pr/unpin-idle-buffers'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'hingeowl-pr/unpin-idle-buffers'
git switch 'Main'
git merge --squash 'hingeowl-pr/unpin-idle-buffers'
git switch 'Main'
git merge --ff-only 'hingeowl-pr/unpin-idle-buffers'
git switch 'Main'
git merge 'hingeowl-pr/unpin-idle-buffers'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
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!508
No description provided.