DARNER_ASYNC_QUEUE=1: run the title's compute lists on a host compute queue (off by default) #530

Open
nastyhotdog wants to merge 1 commit from nastyhotdog/Darner:pr/async-compute-queue into Main
First-time contributor

Title:
[pr-feature] DARNER_ASYNC_QUEUE=1: run the title's compute lists on a host compute queue (off by default)


Contributor role (optional)

  • Fluxer ID: nasty_hotdog

What it changes

  • The problem on main: read from the code only. host/two_queues.rs plans which submissions could go to a second queue (DARNER_ASYNC_QUEUE=plan), but everything runs on the direct queue, and its log line says so.

With DARNER_ASYNC_QUEUE=1, the title's compute lists run on a host compute queue. Nothing changes unless it is set.

  • Which lists go to the compute queue. A title compute list is recorded as a direct list first and promoted after 30 clean recordings. Drawing-state calls are left out, a list that draws stays direct, and only an allow-list of compute-safe calls is accepted (list/thin.rs). Compute lists keep their type through host list swaps and have their own idle pool (list.rs).
  • How far the queues overlap (DARNER_ASYNC_OVERLAP).
    • 0 (default with the queue on): safe mode, where each queue waits for the other at every submission.
    • 1: the direct queue waits for compute work only before the part of a submission that needs it.
    • 2: compute work also starts behind only what it needs. A ledger records what each submission reads and writes and resolves it against what was actually sent. A third queue signals the submission fence, so neither queue waits for the other at a submission's end. Value waits a flight in the air will meet are placed at their part.
  • Two further options:
    • DARNER_ASYNC_PRELUDE=1: preludes that only move states a compute list may hold run on the compute queue.
    • DARNER_ASYNC_READS=1: a compute list reads sampled textures in the state they are in, without moving them there and back.
  • Diagnostics. A per-frame log line reports what each submission waited for and why: compute starts, handoffs, which queue signalled the fence. barstat.rs logs a compute list barrier that names a drawing state.

This PR does not make anything faster. In the one scene measured there was no gain (below). It is offered as an opt-in base for card-limited scenes, which are where overlapping compute with graphics can pay, and which have not been measured with it yet.

How it was tested

  • Tested revision: gates on b914fb3 (this branch, on main c8258f9). The game runs used the same async-queue code on an older main (bd0de0c) with other local, off-by-default changes. b914fb3 itself was not run in the game.

  • Commands and results: see the gates below; there is a GPU test, gpu_tests::the_direct_queue_runs_on_while_the_fence_waits_for_compute_work, that runs on the card.

  • Changes a default: no.

  • A/B result: same scene (standing still, about 5,000 draws per frame), same settings and hardware, one run each. 5-second fps readings after the scene settled:

    A (off) B (on: DARNER_ASYNC_QUEUE=1, DARNER_ASYNC_OVERLAP=2, DARNER_ASYNC_READS=1, DARNER_ASYNC_PRELUDE=1)
    fps 24.8 (9 readings, 24.4-25.6) 25.1 (14 readings, 24.5-25.5)

    Both runs had DARNER_PASSES_HOT=300, and B also had DARNER_CARD_METER=0. A third run with neither switch measured 25.0 (7 readings, 24.2-25.6). The differences are within run-to-run noise.

    In run B the log showed, per frame: about 8 submissions with compute lists, 9 runs on the compute queue, and 15 of 18 submissions whose direct lists never waited for the compute queue.

    An Nsight Systems capture (10 s, on) explains the lack of gain in that scene:

    • Compute queue busy 0.70 s, of which 46% overlapped direct work.
    • The card idle 25% of the time. In 395 of 396 gaps of 1 ms or more, the next work came from the submitting thread after the card was already idle; only one gap was a fence wait.
    • So in that scene the frame is held by the CPU side, where a second queue cannot help.
  • Gates run on that revision (b914fb3), on the machine below:

    • cargo xtask policy: asset policy: 576 files ok.
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.
    • Gate 3, cargo test --workspace --locked: 3525 passed, 0 failed, 121 ignored. One test did not finish: darner-shader's oracle64::legacy_mul_forms_are_exact was stopped after more than 15 minutes in the debug build. This PR does not change darner-shader. The targets after it (darner-simd, xtask, the doc tests) were then run on their own with cargo test --locked -p darner-simd -p xtask and cargo test --workspace --locked --doc.
    • An earlier gate 3 run, on the previous revision of this branch, ended with display driver resets (nvlddmkm, event 153) while the darner-gpu tests ran. The cause was not confirmed. That revision's GPU test left its compute queue waiting on a fence if an assert failed first, so it now opens that fence however it ends. Since then, no driver errors have been logged in that test alone, in all of cargo test -p darner-gpu (1811 passed, 0 failed, 81 ignored) or in the gate 3 run above.
  • Gameplay: NVIDIA RTX 3070 Ti (8 GB), Intel i5-12600K, Windows 11 (10.0.26300), driver 591.44. Series S profile, 1920x1080 picture (the title's own 1280x720 scene), DLSS off, frame generation off, ray tracing off.

  • Shader wave sizes tested: not relevant (no shader change).

  • Hardware dependence: untested elsewhere; only on that NVIDIA card. How much compute can overlap depends on the card and driver.

  • Coverage gaps:

    • Not measured in a card-limited scene.
    • DARNER_ASYNC_OVERLAP=1, DARNER_ASYNC_READS and DARNER_ASYNC_PRELUDE were not A/B tested on their own.
    • Not tested with DLSS, frame generation or ray tracing, or on AMD or Intel cards.
    • Not tested with the Series X profile.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    The async-queue code ran in the game on the older base described above. This rebased commit was not run 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:
    • #93 (DARNER_LATE_FENCE, cross-queue fences; also changes queue/behind.rs).
    • Many open PRs change host.rs (41) and list/thin.rs (6); none of them changes host/two_queues.rs.
  • Replaces or overlaps: none found.

🤖 Generated with Claude Code

Title: [pr-feature] DARNER_ASYNC_QUEUE=1: run the title's compute lists on a host compute queue (off by default) --- <!-- Use Fixes #N for a complete fix or Refs #N for a partial change. --> ## Contributor role (optional) - Fluxer ID: nasty_hotdog ## What it changes - The problem on main: read from the code only. `host/two_queues.rs` plans which submissions could go to a second queue (`DARNER_ASYNC_QUEUE=plan`), but everything runs on the direct queue, and its log line says so. With `DARNER_ASYNC_QUEUE=1`, the title's compute lists run on a host compute queue. Nothing changes unless it is set. - **Which lists go to the compute queue.** A title compute list is recorded as a direct list first and promoted after 30 clean recordings. Drawing-state calls are left out, a list that draws stays direct, and only an allow-list of compute-safe calls is accepted (`list/thin.rs`). Compute lists keep their type through host list swaps and have their own idle pool (`list.rs`). - **How far the queues overlap (`DARNER_ASYNC_OVERLAP`).** - `0` (default with the queue on): safe mode, where each queue waits for the other at every submission. - `1`: the direct queue waits for compute work only before the part of a submission that needs it. - `2`: compute work also starts behind only what it needs. A ledger records what each submission reads and writes and resolves it against what was actually sent. A third queue signals the submission fence, so neither queue waits for the other at a submission's end. Value waits a flight in the air will meet are placed at their part. - **Two further options:** - `DARNER_ASYNC_PRELUDE=1`: preludes that only move states a compute list may hold run on the compute queue. - `DARNER_ASYNC_READS=1`: a compute list reads sampled textures in the state they are in, without moving them there and back. - **Diagnostics.** A per-frame log line reports what each submission waited for and why: compute starts, handoffs, which queue signalled the fence. `barstat.rs` logs a compute list barrier that names a drawing state. This PR does not make anything faster. In the one scene measured there was no gain (below). It is offered as an opt-in base for card-limited scenes, which are where overlapping compute with graphics can pay, and which have not been measured with it yet. ## How it was tested - Tested revision: gates on b914fb3 (this branch, on main c8258f9). The game runs used the same async-queue code on an older main (bd0de0c) with other local, off-by-default changes. b914fb3 itself was not run in the game. - Commands and results: see the gates below; there is a GPU test, `gpu_tests::the_direct_queue_runs_on_while_the_fence_waits_for_compute_work`, that runs on the card. - Changes a default: no. - A/B result: same scene (standing still, about 5,000 draws per frame), same settings and hardware, one run each. 5-second fps readings after the scene settled: | | A (off) | B (on: `DARNER_ASYNC_QUEUE=1`, `DARNER_ASYNC_OVERLAP=2`, `DARNER_ASYNC_READS=1`, `DARNER_ASYNC_PRELUDE=1`) | |---|---|---| | fps | 24.8 (9 readings, 24.4-25.6) | 25.1 (14 readings, 24.5-25.5) | Both runs had `DARNER_PASSES_HOT=300`, and B also had `DARNER_CARD_METER=0`. A third run with neither switch measured 25.0 (7 readings, 24.2-25.6). The differences are within run-to-run noise. In run B the log showed, per frame: about 8 submissions with compute lists, 9 runs on the compute queue, and 15 of 18 submissions whose direct lists never waited for the compute queue. An Nsight Systems capture (10 s, on) explains the lack of gain in that scene: - Compute queue busy 0.70 s, of which 46% overlapped direct work. - The card idle 25% of the time. In 395 of 396 gaps of 1 ms or more, the next work came from the submitting thread after the card was already idle; only one gap was a fence wait. - So in that scene the frame is held by the CPU side, where a second queue cannot help. - Gates run on that revision (b914fb3), on the machine below: - `cargo xtask policy`: asset policy: 576 files ok. - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. - Gate 3, `cargo test --workspace --locked`: 3525 passed, 0 failed, 121 ignored. One test did not finish: `darner-shader`'s `oracle64::legacy_mul_forms_are_exact` was stopped after more than 15 minutes in the debug build. This PR does not change `darner-shader`. The targets after it (`darner-simd`, `xtask`, the doc tests) were then run on their own with `cargo test --locked -p darner-simd -p xtask` and `cargo test --workspace --locked --doc`. - An earlier gate 3 run, on the previous revision of this branch, ended with display driver resets (`nvlddmkm`, event 153) while the `darner-gpu` tests ran. The cause was not confirmed. That revision's GPU test left its compute queue waiting on a fence if an assert failed first, so it now opens that fence however it ends. Since then, no driver errors have been logged in that test alone, in all of `cargo test -p darner-gpu` (1811 passed, 0 failed, 81 ignored) or in the gate 3 run above. - Gameplay: NVIDIA RTX 3070 Ti (8 GB), Intel i5-12600K, Windows 11 (10.0.26300), driver 591.44. Series S profile, 1920x1080 picture (the title's own 1280x720 scene), DLSS off, frame generation off, ray tracing off. - Shader wave sizes tested: not relevant (no shader change). - Hardware dependence: untested elsewhere; only on that NVIDIA card. How much compute can overlap depends on the card and driver. - Coverage gaps: - Not measured in a card-limited scene. - `DARNER_ASYNC_OVERLAP=1`, `DARNER_ASYNC_READS` and `DARNER_ASYNC_PRELUDE` were not A/B tested on their own. - Not tested with DLSS, frame generation or ray tracing, or on AMD or Intel cards. - Not tested with the Series X profile. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). The async-queue code ran in the game on the older base described above. This rebased commit was not run 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: - #93 (`DARNER_LATE_FENCE`, cross-queue fences; also changes `queue/behind.rs`). - Many open PRs change `host.rs` (41) and `list/thin.rs` (6); none of them changes `host/two_queues.rs`. - Replaces or overlaps: none found. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
two_queues.rs only planned which submissions could go to a second queue;
everything still ran on the direct queue. With DARNER_ASYNC_QUEUE=1 the
title's compute lists now run on a host compute queue:

- Compute lists are learned as direct lists first and promoted after 30
  clean recordings; drawing-state calls are left out, lists that draw stay
  direct, and only an allow-list of compute-safe calls is accepted.
- Host lists keep their type through swaps; compute lists have their own
  idle pool. Preludes (state moves before a list) can run on the compute
  queue (DARNER_ASYNC_PRELUDE=1), and sampled textures can be read in the
  state they are in (DARNER_ASYNC_READS=1).
- DARNER_ASYNC_OVERLAP: 0 keeps the safe mode (each queue waits for the
  other at every submission). 1: the direct queue waits for compute work
  only where a submission needs it. 2: compute also starts behind only
  what it needs, from a ledger of what each submission reads and writes,
  resolved against what was actually sent; a third queue moves the
  submission fence, so neither queue waits for the other at a submission's
  end.

All of it is off unless DARNER_ASYNC_QUEUE=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from [pr-feature] DARNER_ASYNC_QUEUE=1: run the title's compute lists on a host compute queue (off by default) to DARNER_ASYNC_QUEUE=1: run the title's compute lists on a host compute queue (off by default) 2026-12-06 03:27:39 +00:00
Owner

Test needed — commit b914fb3f; what to check:

  • The problem on main: read from the code only. host/two_queues.rs plans which submissions could go to a second queue (DARNER_ASYNC_QUEUE=plan), but everything runs on the direct queue, and its log line says so.

With DARNER_ASYNC_QUEUE=1, the title's compute lists run on a host compute queue. Nothing changes unless it is set.

  • Which lists go to the compute queue. A title compute list is recorded as a direct list first and promoted after 30 clean recordings. Drawing-state calls are left out, a list that draws stays direct, and only an allow-list of compute-safe calls is accepted (list/thin.rs). Compute lists keep their type through host list swaps and have their own idle pool (list.rs).
  • How far the queues overlap (DARNER_ASYNC_OVERLAP).
    • 0 (default with the queue on): safe mode, where each queue waits for the other at every submission.
    • 1: the direct queue waits for compute work only before the part of a submission that needs it.
    • 2: compute work also starts behind only what it needs. A ledger records what each submission reads and writes and resolves it against what was actually sent. A third queue signals the submission fence, so neither que

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 `b914fb3f`; what to check: - The problem on main: read from the code only. `host/two_queues.rs` plans which submissions could go to a second queue (`DARNER_ASYNC_QUEUE=plan`), but everything runs on the direct queue, and its log line says so. With `DARNER_ASYNC_QUEUE=1`, the title's compute lists run on a host compute queue. Nothing changes unless it is set. - **Which lists go to the compute queue.** A title compute list is recorded as a direct list first and promoted after 30 clean recordings. Drawing-state calls are left out, a list that draws stays direct, and only an allow-list of compute-safe calls is accepted (`list/thin.rs`). Compute lists keep their type through host list swaps and have their own idle pool (`list.rs`). - **How far the queues overlap (`DARNER_ASYNC_OVERLAP`).** - `0` (default with the queue on): safe mode, where each queue waits for the other at every submission. - `1`: the direct queue waits for compute work only before the part of a submission that needs it. - `2`: compute work also starts behind only what it needs. A ledger records what each submission reads and writes and resolves it against what was actually sent. A third queue signals the submission fence, so neither que 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/host.rs
  • crates/darner-gpu/src/host/stamps.rs
  • crates/darner-gpu/src/host/two_queues.rs
  • crates/darner-gpu/src/list.rs
  • crates/darner-gpu/src/queue/behind.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-compute-queue:nastyhotdog-pr/async-compute-queue'
git switch 'nastyhotdog-pr/async-compute-queue'

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 'nastyhotdog-pr/async-compute-queue'
git switch 'nastyhotdog-pr/async-compute-queue'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'nastyhotdog-pr/async-compute-queue'
git switch 'nastyhotdog-pr/async-compute-queue'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'nastyhotdog-pr/async-compute-queue'
git switch 'Main'
git merge --squash 'nastyhotdog-pr/async-compute-queue'
git switch 'Main'
git merge --ff-only 'nastyhotdog-pr/async-compute-queue'
git switch 'Main'
git merge 'nastyhotdog-pr/async-compute-queue'
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!530
No description provided.