Draws short of dynamic slots wait for the next landing, not a settle under the submission lock, behind VICTORY_DYNAMIC_WAIT (port of fxceless 52dfd12) #821

Closed
xiepeixuan wants to merge 1 commit from upstream-pr/821 into main
xiepeixuan commented 2026-11-28 07:07:38 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xiepeixuan on 2026-11-28T07:07:38Z.


When a draw cannot get dynamic descriptor slots, it can settle all outstanding flights while holding the submission lock. That delays new submissions even when the next relay landing could free enough slots for the draw to continue.

Ported from fxceless/victory-fork 52dfd12 (fxceless), GPL-3.0 like this repository.

Measurement by fxceless, in that fork (run 402, 9,000–11,000 draws): 0.64 settles/frame at 19.7 ms each, and 12.4 ms/frame waiting for the submission lock. Frames with a settle took 92.7 ms versus 68.1 ms without one. These are not measurements of this port.

Scope and adaptations

  • host.rs: the wait and switch with their doc comments, a wait timing span, and the related rate-line counters. draw.rs: only the failed allocations for a bounded root UAV, a table-backed root SRV, and a fresh descriptor table. descriptor/host.rs: the free-slot low-water measurement feeding that line.
  • VICTORY_DYNAMIC_WAIT=1 opts in; unset, 0, and other values take the original sequence, shown explicitly in the diff: failed allocation → settle_for_fence() → one retry. The off path does not poll or record new statistics. The parser preserves the source's exact 1 test; there is no alt mode.
  • Kept upstream's flight and fence handling. relay() already requires late_stage() > 0 and the shadow relay, so no separate worker-start or late() change is needed. Both submission paths that enqueue flights start late_threads() first. The relay still waits for the GPU fence, lands the flight and its readbacks, then calls Detached::release_tables before notifying LINE_LANDED. Upstream's newer wait_host_fence validation is unchanged. No list reset or early table release is needed.
  • Added a 50 ms grace period to the source's 1 ms polling. A busy relay does not guarantee that a particular heap gets a large enough contiguous range (for instance when untranslated lists still own slots). Expiring the grace period returns to the old settle and one retry; it is not a timeout on the existing GPU fence wait.
  • Moved the new measurements behind the opt-in too. The low-water count and capacity are stored as one atomic pair so concurrent allocations across different heaps cannot report a minimum from one heap with another heap's capacity. The five per-frame counters are reduced on the stack.
  • Left out the ray-tracing changes in pipeline/make.rs, memory.rs, and host/card_steps.rs, the extra card-step diagnostics, the STOOD stats in queue/behind.rs, and all README changes. This overlaps the wait portion of #83, but does not take that PR's THIN gate, table reuse, or early releases.

Locking and fallback

The waiter reads the queue and Line::settling under LINE, drops that guard before calling the allocator (which takes the heap's next mutex), and sleeps via LINE_LANDED.wait_timeout, which releases LINE. It holds neither LINE nor a heap lock when it calls the old settle. The relay releases a detached list's own draw state, not the title list's recording mutex; it does not take the submission mutex. List recycling and held-queue work remain on late_helper.

With relay off it goes straight to the old settle. With an empty line and no landing in progress, it retries once in case a landing freed slots just before the snapshot; if still short it does not sleep and falls back. An empty line while settling is true can still return slots. A missed notification causes at most one requested 1 ms poll before checking again, and a persistently busy, unhelpful relay returns to the old settle after the grace period. If the old settle and retry still return no slots, the existing draw/table failure paths are unchanged.

Uses audit

Symbol or state Other uses checked and effect
State::root_uav, root_srv_table, tables; new wait_for_slots The three allocation fallback sites are the only new callers of wait_for_slots. Their callers are State::bind: the UAV branch, both null and addressed SRV branches, and the table-build branch used by graphics and compute. No change to cache hits, first-attempt successes, or the failure return after the fallback.
HostHeap::dynamic, free, dynamic, next, too_long Other callers are the scratch allocation in memory.rs (still a single attempt) and descriptor unit tests (same return/reuse rules). Only opt-in telemetry was added on allocator success and failure. Capacity, cursor, fragmentation, and the release updates to these fields are unchanged.
Detached::release_tables, State::tables_done, descriptor::release_dynamic, HostHeap::release Both the relay and synchronous Host::settle still release at the same point and from the detached state. Queue-side list::tables_done calls (submission, split/wait and held-list paths) and the draw state's Drop still release the same slots; heap identity checks, allocator locking and lifetime rules did not change.
settle_for_fence, settle_now, Host::settle, Host::submitted The three fallback invocations moved into the new helper. The other callers—flush_for_bake, early_textures, external::finish_submitted, the fence's set_event_on_completion, and Streamline's check_run—retain their original settle. Present / FSR settles and the submission and late-helper lock sites are unchanged.
line(), LINE, Line::line, Line::settling, LINE_LANDED The new path only reads the line and adds a timed waiter. Existing checks for flights, ordering and title waits (flying, late_blocked, late_signal, late_met_known, late_met_by), the land/recycle helper, relay fetch and worker, and the send/present/submit/settle paths do not change. relay_wait retains its original predicates for full settle, stale/read ranges, and flight count. Host::relay_land is still the notifier, at the same point.
late(), relay(), late_threads, relay_worker, Host::relay_land The opt-in wait reads existing relay readiness. Existing late/relay selection and stages, fence handling, queue and present decisions, card-before/card-done work, helper wakeups, and flight submission/landing are unchanged. No new producer or notification.
late_line / dynamic_wait_line, DYNAMIC_WAITS, DYNAMIC_LOW, HostHeap::note_dynamic_low, timeline::span late_line is still called from the frame-rate report; the only new report/reset is for the opt-in wait and allocator sample. DYNAMIC_WAITS is updated only by the waiter; DYNAMIC_LOW is written only by the allocator and reset only by the report. The new wait span is the only change to timeline instrumentation.
dynamic_wait, dynamic_wait_mode, DYNAMIC_WAIT_LIMIT, dynamic_wait_delay New uses only: the wait and telemetry/report gates read the cached mode; the parser is otherwise used only by its test. The timed-wait policy and grace constant are used by the waiter and their tests only.

Checks

Windows workspace check: cargo check --workspace --locked passed on 4e99e53ffb3c107606c24181f760440c9564f4b6 (fork job). Both the targeted and full fork jobs checked out and asserted that exact source SHA; their workflow-trigger branch is separate and is not part of this PR.

Windows GPU library tests: cargo test -p victory-gpu --lib --locked -- --skip pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws passed: 455 passed, 36 ignored, 1 filtered out. Baseline on 63b902fe with the same command: 452 passed, 36 ignored, 1 filtered out. All three added tests passed (exact switch parsing, empty versus landing line, and the grace-period cutoff). In the unfiltered comparison, the only failure on both revisions was the same depth-bounds assertion in pipeline/host.rs:1466:9; that one test alone was excluded in the rerun.

Full Windows CI: the fork workflow stopped at the same two Clippy errors as upstream main 63b902fe:

  • clippy::let_and_return – crates/victory-shader/src/emit/mod.rs:2768:9
  • clippy::manual_is_multiple_of – crates/victory-gpu/src/shadow.rs:1708:32

No new diagnostic in any changed file. As on main, that Clippy failure skipped the later diagnostics build and workspace tests. No workspace-wide formatting.

Refs #756 (intra-frame settles) and #699 (submission-thread pacing).

AI-assisted (Codex). Not run in the game here. Off by default; needs a run with VICTORY_DYNAMIC_WAIT=1 in a busy scene (9,000+ draws) against =0.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5537723435 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/821). Originally posted by [xiepeixuan](https://github.com/xiepeixuan) on 2026-11-28T07:07:38Z. --- When a draw cannot get dynamic descriptor slots, it can settle all outstanding flights while holding the submission lock. That delays new submissions even when the next relay landing could free enough slots for the draw to continue. Ported from [fxceless/victory-fork 52dfd12](https://github.com/fxceless/victory-fork/commit/52dfd12ea1f2c3ec9dd80b983aa6558ce115b51e) (fxceless), GPL-3.0 like this repository. **Measurement by fxceless, in that fork (run 402, 9,000–11,000 draws):** 0.64 settles/frame at 19.7 ms each, and 12.4 ms/frame waiting for the submission lock. Frames with a settle took 92.7 ms versus 68.1 ms without one. These are not measurements of this port. ## Scope and adaptations - `host.rs`: the wait and switch with their doc comments, a wait timing span, and the related rate-line counters. `draw.rs`: only the failed allocations for a bounded root UAV, a table-backed root SRV, and a fresh descriptor table. `descriptor/host.rs`: the free-slot low-water measurement feeding that line. - `VICTORY_DYNAMIC_WAIT=1` opts in; unset, `0`, and other values take the original sequence, shown explicitly in the diff: failed allocation → `settle_for_fence()` → one retry. The off path does not poll or record new statistics. The parser preserves the source's exact `1` test; there is no `alt` mode. - Kept upstream's flight and fence handling. `relay()` already requires `late_stage() > 0` and the shadow relay, so no separate worker-start or `late()` change is needed. Both submission paths that enqueue flights start `late_threads()` first. The relay still waits for the GPU fence, lands the flight and its readbacks, then calls `Detached::release_tables` before notifying `LINE_LANDED`. Upstream's newer `wait_host_fence` validation is unchanged. No list reset or early table release is needed. - Added a 50 ms grace period to the source's 1 ms polling. A busy relay does not guarantee that a particular heap gets a large enough contiguous range (for instance when untranslated lists still own slots). Expiring the grace period returns to the old settle and one retry; it is not a timeout on the existing GPU fence wait. - Moved the new measurements behind the opt-in too. The low-water count and capacity are stored as one atomic pair so concurrent allocations across different heaps cannot report a minimum from one heap with another heap's capacity. The five per-frame counters are reduced on the stack. - Left out the ray-tracing changes in `pipeline/make.rs`, `memory.rs`, and `host/card_steps.rs`, the extra card-step diagnostics, the `STOOD` stats in `queue/behind.rs`, and all README changes. This overlaps the wait portion of #83, but does not take that PR's THIN gate, table reuse, or early releases. ## Locking and fallback The waiter reads the queue and `Line::settling` under `LINE`, drops that guard before calling the allocator (which takes the heap's `next` mutex), and sleeps via `LINE_LANDED.wait_timeout`, which releases `LINE`. It holds neither `LINE` nor a heap lock when it calls the old settle. The relay releases a detached list's own draw state, not the title list's recording mutex; it does not take the submission mutex. List recycling and held-queue work remain on `late_helper`. With relay off it goes straight to the old settle. With an empty line and no landing in progress, it retries once in case a landing freed slots just before the snapshot; if still short it does not sleep and falls back. An empty line while `settling` is true can still return slots. A missed notification causes at most one requested 1 ms poll before checking again, and a persistently busy, unhelpful relay returns to the old settle after the grace period. If the old settle and retry still return no slots, the existing draw/table failure paths are unchanged. ## Uses audit | Symbol or state | Other uses checked and effect | |---|---| | `State::root_uav`, `root_srv_table`, `tables`; new `wait_for_slots` | The three allocation fallback sites are the only new callers of `wait_for_slots`. Their callers are `State::bind`: the UAV branch, both null and addressed SRV branches, and the table-build branch used by graphics and compute. No change to cache hits, first-attempt successes, or the failure return after the fallback. | | `HostHeap::dynamic`, `free`, `dynamic`, `next`, `too_long` | Other callers are the scratch allocation in `memory.rs` (still a single attempt) and descriptor unit tests (same return/reuse rules). Only opt-in telemetry was added on allocator success and failure. Capacity, cursor, fragmentation, and the `release` updates to these fields are unchanged. | | `Detached::release_tables`, `State::tables_done`, `descriptor::release_dynamic`, `HostHeap::release` | Both the relay and synchronous `Host::settle` still release at the same point and from the detached state. Queue-side `list::tables_done` calls (submission, split/wait and held-list paths) and the draw state's `Drop` still release the same slots; heap identity checks, allocator locking and lifetime rules did not change. | | `settle_for_fence`, `settle_now`, `Host::settle`, `Host::submitted` | The three fallback invocations moved into the new helper. The other callers—`flush_for_bake`, `early_textures`, `external::finish_submitted`, the fence's `set_event_on_completion`, and Streamline's `check_run`—retain their original settle. Present / FSR settles and the submission and late-helper lock sites are unchanged. | | `line()`, `LINE`, `Line::line`, `Line::settling`, `LINE_LANDED` | The new path only reads the line and adds a timed waiter. Existing checks for flights, ordering and title waits (`flying`, `late_blocked`, `late_signal`, `late_met_known`, `late_met_by`), the land/recycle helper, relay fetch and worker, and the send/present/submit/settle paths do not change. `relay_wait` retains its original predicates for full settle, stale/read ranges, and flight count. `Host::relay_land` is still the notifier, at the same point. | | `late()`, `relay()`, `late_threads`, `relay_worker`, `Host::relay_land` | The opt-in wait reads existing relay readiness. Existing late/relay selection and stages, fence handling, queue and present decisions, card-before/card-done work, helper wakeups, and flight submission/landing are unchanged. No new producer or notification. | | `late_line` / `dynamic_wait_line`, `DYNAMIC_WAITS`, `DYNAMIC_LOW`, `HostHeap::note_dynamic_low`, `timeline::span` | `late_line` is still called from the frame-rate report; the only new report/reset is for the opt-in wait and allocator sample. `DYNAMIC_WAITS` is updated only by the waiter; `DYNAMIC_LOW` is written only by the allocator and reset only by the report. The new wait span is the only change to timeline instrumentation. | | `dynamic_wait`, `dynamic_wait_mode`, `DYNAMIC_WAIT_LIMIT`, `dynamic_wait_delay` | New uses only: the wait and telemetry/report gates read the cached mode; the parser is otherwise used only by its test. The timed-wait policy and grace constant are used by the waiter and their tests only. | ## Checks **Windows workspace check:** `cargo check --workspace --locked` passed on `4e99e53ffb3c107606c24181f760440c9564f4b6` ([fork job](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46119166974/job/140899641615)). Both the targeted and full fork jobs checked out and asserted that exact source SHA; their workflow-trigger branch is separate and is not part of this PR. **Windows GPU library tests:** `cargo test -p victory-gpu --lib --locked -- --skip pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws` passed: 455 passed, 36 ignored, 1 filtered out. [Baseline on `63b902fe`](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46119166974/job/140899641799) with the same command: 452 passed, 36 ignored, 1 filtered out. All three added tests passed (exact switch parsing, empty versus landing line, and the grace-period cutoff). In the [unfiltered comparison](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46118831425), the only failure on both revisions was the same depth-bounds assertion in `pipeline/host.rs:1466:9`; that one test alone was excluded in the rerun. **Full Windows CI:** the [fork workflow](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46119166969) stopped at the same two Clippy errors as [upstream main `63b902fe`](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46104876336): - `clippy::let_and_return` – `crates/victory-shader/src/emit/mod.rs:2768:9` - `clippy::manual_is_multiple_of` – `crates/victory-gpu/src/shadow.rs:1708:32` No new diagnostic in any changed file. As on main, that Clippy failure skipped the later diagnostics build and workspace tests. No workspace-wide formatting. Refs #756 (intra-frame settles) and #699 (submission-thread pacing). AI-assisted (Codex). Not run in the game here. Off by default; needs a run with VICTORY_DYNAMIC_WAIT=1 in a busy scene (9,000+ draws) against =0.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!821
No description provided.