opt-in async HostList recycle with idle-pool work stealing #646

Open
RileyW wants to merge 1 commit from RileyW/Darner:pr/async-hostlist-recycle into Main
First-time contributor

Note: This exact Darner revision has not yet been run end-to-end in the game on Darner main. The same optimization has been running in gameplay on our Windows 10 (i7-8700, RTX 3080 20 GiB) fork, and this Darner port is opt-in (off by default via DARNER_ASYNC_RECYCLE=1) and verified with both pure-CPU and live RTX 3080 D3D12 unit tests plus all workspace gates.

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: In crates/darner-gpu/src/list.rs, recycle() resets every landed HostList synchronously on the caller thread (the landing thread in host::land() or the queue thread), running D3D12 ID3D12CommandAllocator::Reset(), ID3D12GraphicsCommandList::Reset(), and COM drops inline for the whole batch.
  • Real-world gameplay/runtime impact: During busy gameplay frames with roughly 200 command lists landing across submissions, synchronous D3D12 resets and COM releases inside list::recycle add avoidable CPU stalls to the landing and queue paths, delaying buffer landing and submission turnaround on CPU-bound systems.
  • What this does: Adds an opt-in DARNER_ASYNC_RECYCLE=1 switch (off by default via crate::asked_for!, compatible with DARNER_AB) that drops upload memory and dynamic descriptor state immediately on the caller thread and hands eligible landed HostLists (up to IDLE_MOST across IDLE plus pending) to a dedicated darner-recycle background thread. Surplus lists still return preludes and read-backs immediately via give_prelude() and recycle_read_backs(), thread-spawn failure cleanly falls back to synchronous recycle_one(), and fresh_list() steals and resets a pending list if IDLE is empty so no extra command allocators are created.

How it was tested

  • Tested revision: 0754d9b (PR branch on c8258f9) and 96096db (merged into riley/all with PR #631 for live Win10 SM 6.6 testing)
  • Commands and results:
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)
    • cargo xtask policy and cargo xtask policy --staged: passed (576 files ok)
    • cargo test -p darner-gpu --lib --locked list::tests::async_recycle_room_caps_total_idle_plus_pending -- --exact: passed (1 passed, 0 failed)
    • Live RTX 3080 GPU test on riley/all with DARNER_TEST_AGILITY_DIR pointing at Agility SDK 1.620: cargo test -p darner-gpu --lib --locked list::tests::async_recycle_resets_landed_host_list_into_idle_pool -- --exact --nocapture passed (1 passed, 0 failed, 0.29s)
  • Changes a default: no (opt-in behind DARNER_ASYNC_RECYCLE=1, off by default until an in-game A/B check on Darner main)
  • A/B result: Off by default. Checked via unit tests verifying pool cap bounds and end-to-end off-thread reset into IDLE on RTX 3080, plus prior gameplay use on our Windows 10 i7-8700 + RTX 3080 fork.
  • Gates run on that revision: all three workspace gates in AGENTS.md on 0754d9b and 96096db
  • Gameplay, when relevant: Windows 10 22H2, i7-8700, RTX 3080 20 GiB (prior gameplay use on fork; opt-in Darner main A/B pending)
  • Shader wave sizes tested, when relevant: n/a (CPU command-list pooling path)
  • Hardware dependence: general (all Windows GPUs; helps CPU-bound multi-core hosts)
  • Coverage gaps: Not yet A/B benchmarked in-game on Darner main (kept off by default for this reason).

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

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
Note: This exact Darner revision has not yet been run end-to-end in the game on Darner main. The same optimization has been running in gameplay on our Windows 10 (i7-8700, RTX 3080 20 GiB) fork, and this Darner port is opt-in (off by default via `DARNER_ASYNC_RECYCLE=1`) and verified with both pure-CPU and live RTX 3080 D3D12 unit tests plus all workspace gates. ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: In `crates/darner-gpu/src/list.rs`, `recycle()` resets every landed `HostList` synchronously on the caller thread (the landing thread in `host::land()` or the queue thread), running D3D12 `ID3D12CommandAllocator::Reset()`, `ID3D12GraphicsCommandList::Reset()`, and COM drops inline for the whole batch. - Real-world gameplay/runtime impact: During busy gameplay frames with roughly 200 command lists landing across submissions, synchronous D3D12 resets and COM releases inside `list::recycle` add avoidable CPU stalls to the landing and queue paths, delaying buffer landing and submission turnaround on CPU-bound systems. - What this does: Adds an opt-in `DARNER_ASYNC_RECYCLE=1` switch (off by default via `crate::asked_for!`, compatible with `DARNER_AB`) that drops upload memory and dynamic descriptor state immediately on the caller thread and hands eligible landed `HostList`s (up to `IDLE_MOST` across `IDLE` plus pending) to a dedicated `darner-recycle` background thread. Surplus lists still return preludes and read-backs immediately via `give_prelude()` and `recycle_read_backs()`, thread-spawn failure cleanly falls back to synchronous `recycle_one()`, and `fresh_list()` steals and resets a pending list if `IDLE` is empty so no extra command allocators are created. ## How it was tested - Tested revision: `0754d9b` (PR branch on `c8258f9`) and `96096db` (merged into `riley/all` with PR #631 for live Win10 SM 6.6 testing) - Commands and results: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed (0 warnings) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed (0 warnings) - `cargo xtask policy` and `cargo xtask policy --staged`: passed (576 files ok) - `cargo test -p darner-gpu --lib --locked list::tests::async_recycle_room_caps_total_idle_plus_pending -- --exact`: passed (1 passed, 0 failed) - Live RTX 3080 GPU test on `riley/all` with `DARNER_TEST_AGILITY_DIR` pointing at Agility SDK 1.620: `cargo test -p darner-gpu --lib --locked list::tests::async_recycle_resets_landed_host_list_into_idle_pool -- --exact --nocapture` passed (1 passed, 0 failed, 0.29s) - Changes a default: no (opt-in behind `DARNER_ASYNC_RECYCLE=1`, off by default until an in-game A/B check on Darner main) - A/B result: Off by default. Checked via unit tests verifying pool cap bounds and end-to-end off-thread reset into `IDLE` on RTX 3080, plus prior gameplay use on our Windows 10 i7-8700 + RTX 3080 fork. - Gates run on that revision: all three workspace gates in AGENTS.md on `0754d9b` and `96096db` - Gameplay, when relevant: Windows 10 22H2, i7-8700, RTX 3080 20 GiB (prior gameplay use on fork; opt-in Darner main A/B pending) - Shader wave sizes tested, when relevant: n/a (CPU command-list pooling path) - Hardware dependence: general (all Windows GPUs; helps CPU-bound multi-core hosts) - Coverage gaps: Not yet A/B benchmarked in-game on Darner main (kept off by default for this reason). ## 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 ## 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
TrustNo1 changed title from [pr-performance][rendering] opt-in async HostList recycle with idle-pool work stealing to opt-in async HostList recycle with idle-pool work stealing 2026-12-06 03:25:35 +00:00
Owner

Test needed — commit 0754d9b2; what to check:

  • The problem on main: In crates/darner-gpu/src/list.rs, recycle() resets every landed HostList synchronously on the caller thread (the landing thread in host::land() or the queue thread), running D3D12 ID3D12CommandAllocator::Reset(), ID3D12GraphicsCommandList::Reset(), and COM drops inline for the whole batch.
  • Real-world gameplay/runtime impact: During busy gameplay frames with roughly 200 command lists landing across submissions, synchronous D3D12 resets and COM releases inside list::recycle add avoidable CPU stalls to the landing and queue paths, delaying buffer landing and submission turnaround on CPU-bound systems.
  • What this does: Adds an opt-in DARNER_ASYNC_RECYCLE=1 switch (off by default via crate::asked_for!, compatible with DARNER_AB) that drops upload memory and dynamic descriptor state immediately on the caller thread and hands eligible landed HostLists (up to IDLE_MOST across IDLE plus pending) to a dedicated darner-recycle background thread. Surplus lists still return preludes and read-backs immediately via give_prelude() and recycle_read_backs(), thread-spawn failure cleanly falls back to synchronous recycle_one(), and `fresh_li

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 `0754d9b2`; what to check: - The problem on main: In `crates/darner-gpu/src/list.rs`, `recycle()` resets every landed `HostList` synchronously on the caller thread (the landing thread in `host::land()` or the queue thread), running D3D12 `ID3D12CommandAllocator::Reset()`, `ID3D12GraphicsCommandList::Reset()`, and COM drops inline for the whole batch. - Real-world gameplay/runtime impact: During busy gameplay frames with roughly 200 command lists landing across submissions, synchronous D3D12 resets and COM releases inside `list::recycle` add avoidable CPU stalls to the landing and queue paths, delaying buffer landing and submission turnaround on CPU-bound systems. - What this does: Adds an opt-in `DARNER_ASYNC_RECYCLE=1` switch (off by default via `crate::asked_for!`, compatible with `DARNER_AB`) that drops upload memory and dynamic descriptor state immediately on the caller thread and hands eligible landed `HostList`s (up to `IDLE_MOST` across `IDLE` plus pending) to a dedicated `darner-recycle` background thread. Surplus lists still return preludes and read-backs immediately via `give_prelude()` and `recycle_read_backs()`, thread-spawn failure cleanly falls back to synchronous `recycle_one()`, and `fresh_li 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 has changes conflicting with the target branch.
  • crates/darner-gpu/src/list.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/async-hostlist-recycle:RileyW-pr/async-hostlist-recycle'
git switch 'RileyW-pr/async-hostlist-recycle'

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 'RileyW-pr/async-hostlist-recycle'
git switch 'RileyW-pr/async-hostlist-recycle'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'RileyW-pr/async-hostlist-recycle'
git switch 'RileyW-pr/async-hostlist-recycle'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'RileyW-pr/async-hostlist-recycle'
git switch 'Main'
git merge --squash 'RileyW-pr/async-hostlist-recycle'
git switch 'Main'
git merge --ff-only 'RileyW-pr/async-hostlist-recycle'
git switch 'Main'
git merge 'RileyW-pr/async-hostlist-recycle'
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!646
No description provided.