Retired objects dropped by a thread of their own, after the landing is told #2007

Closed
github-bot wants to merge 1 commit from github-bot/gh-2007 into main AGit
Owner

@⁠binarycleric on GitHub · 2026-11-29 07:07 UTC · original
up/bury-off-relay → main · +808 −52 · 3 files · 1 commits · closed without merging

What it changes

With the relay on, the thread that lands finished submissions spends about 16.8 ms a frame landing (play log, RTX 5070 Ti, Ryzen 7900X, about 17 fps in the first gameplay area, 2026-11-28). The landing line puts 6.99 ms of that in "the rest": the time from the last item to the end of the landing. That stretch is FINISHED.store, bury(last) and log_messages(), and log_messages() does nothing unless the debug layer is on.

bury() releases what the title and the host let go once the submissions that might use it are 64 submissions behind one that has finished: descriptor slots' old resources, host copies, host textures, command allocators. It ran on the relay after the finished count and before the line's ranges were updated and LINE_LANDED was signalled. So every relay wait on the submitting thread, and every present waiting for the line, waited for those releases too.

What changes

  • bury() takes what is due out of RETIRED exactly as before (same selection, same bury_lag()) and hands it, through a channel, to victory-bury: a below-normal-priority thread that only drops what it is given (host/grave.rs).
  • The relay hands it over only after FINISHED, the line's written/settling, LINE_MOVED and LINE_LANDED are published (tell_and_bury).
  • The settle path and the synchronous submission call bury() too, and also hand off.
  • Bounded: past 131,072 objects handed and not yet dropped, the burying thread drops a batch itself, at the old cost, until the thread catches up.
  • Logged: the relay's 5-second line now shows the objects dropped, the drop thread's time, its backlog and peak, and how many objects the burying thread dropped itself because the drop thread was behind. The landing line gets a "burying what was let go" field.
  • Safe to drop later and elsewhere:
    • Everything handed over is already past its last use on the card.
    • D3D12 objects are free-threaded.
    • Besides the releases themselves, the retired objects' drops only change counters and return budget slots to their pool, under that pool's own lock.
    • Neither depends on the thread that drops them.
  • VICTORY_BURY_ASIDE=0 restores the old behaviour: released on the thread that buries, and on the relay before the line is told. It's a toggled! switch, so VICTORY_AB can flip it while the title runs.

Tests

  • what_is_handed_is_dropped_on_the_thread: objects handed over are dropped on the grave's thread, and counted.
  • dropping_the_grave_drops_all_it_holds_and_ends_its_thread: when the grave is dropped, everything still queued is dropped and the thread ends without hanging.
  • a_grave_behind_hands_back_and_stays_bounded: past the bound, the caller drops the batch itself. Once the thread catches up, it takes batches again.
  • nothing_is_dropped_before_its_submission_and_the_lag: only objects whose submission is lag behind the finished count are due, and an object retired out of order holds back the ones after it.
  • bury_drops_on_the_grave_with_the_switch_and_here_without: bury_from drops on the grave with the switch, and on the calling thread before it returns without it.
  • a_landing_tells_before_it_buries_only_with_the_grave: tells, then buries, with the switch; buries, then tells, without it; buries nothing when no flight landed. Swapping the order makes it fail.
  • a_resource_a_running_submission_uses_goes_only_after_its_fence_and_the_lag, on the software adapter:
    • a buffer is copied from by a submission held on the queue behind a fence wait;
    • it isn't released while that submission waits, nor after it runs until lag more have finished;
    • then it's dropped on the grave's thread, and the runtime's reference count on it falls by one.
  • acceptance_burying_aside: 20,000 references to live textures, 100 buffers (64 KiB to 2 MiB) and 20 textures of 1024×1024 retired a frame, burying inline against handing to the grave, in alternating runs.
    • It prints medians of the lander's burying time and of a waiter's wait for the landing.
    • With VICTORY_ACCEPTANCE=1 in a release build, it fails unless both are at least ten times as short with the grave.

Measured, RTX 5070 Ti, release, 10 alternating runs of 30 frames, medians:

per frame VICTORY_BURY_ASIDE=0 VICTORY_BURY_ASIDE=1
20k references + 100 buffers + 20 textures: burying on the lander 13.9 ms 0.01 ms
the same: a waiter's wait for the landing 13.9 ms 0.01 ms
20k references only: burying on the lander 0.14 ms 0.008 ms
100 buffers + 20 textures only: burying on the lander 12.7 ms 0.009 ms

The cost is in the frees, about 0.1 ms per committed resource, not in the references. The grave's own dropping took 22.8 ms a frame. That's more than the 13.9 ms inline: it runs below normal priority and alongside the next frame's resource creation.

Run again on this branch, with VICTORY_ACCEPTANCE=1, on a machine whose processors other jobs held fully, the frees were far slower, but the ratio held:

  • the lander's burying: 155.3 ms with the switch off, 0.011 ms on;
  • the waiter's wait: 155.4 ms off, 0.012 ms on;
  • the grave's own dropping: 1,070 ms a frame.

That last figure is what the bound and the relay line's "behind" count are for.

How it was tested

  • GPU and profile: RTX 5070 Ti 16 GB, Ryzen 9 7900X; Series X profile, 1440p native, DLSS off, frame generation off; ray-tracing passes left out (no structure builder)
  • Before: in play, the relay thread spent about 16.8 ms a frame landing, 6.99 ms of it in "the rest" (bury)
  • After: in play with VICTORY_BURY_ASIDE=1 on our integration branch (26–28 fps), the relay lands in 10.9–11.0 ms a frame; the burying thread drops 45,600–48,500 objects a frame in about 12 batches, 6.4–11.3 ms, and nothing waits behind it ("0 waiting for them now"). Other changes are in that build too
  • cargo test passed for the crates it touches: yes. Rebased onto main e1f2eb60: cargo test --release -p victory-gpu --lib, 597 passed, 0 failed, 44 ignored

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1358 also moves bury()'s drops to a victory-bury thread, and batches dynamic slot releases as well. This one differs in where the hand-off happens (after FINISHED, the line's ranges, LINE_MOVED and LINE_LANDED are published), its bound (past 131,072 objects the burying thread catches up itself), the settle path and synchronous submissions handing off too, and its counters and tests. Happy to fold the good parts of either into the other.
**@⁠binarycleric** on GitHub · 2026-11-29 07:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2007) `up/bury-off-relay` → `main` · +808 −52 · 3 files · 1 commits · closed without merging ## What it changes With the relay on, the thread that lands finished submissions spends about 16.8 ms a frame landing (play log, RTX 5070 Ti, Ryzen 7900X, about 17 fps in the first gameplay area, 2026-11-28). The landing line puts 6.99 ms of that in "the rest": the time from the last item to the end of the landing. That stretch is `FINISHED.store`, `bury(last)` and `log_messages()`, and `log_messages()` does nothing unless the debug layer is on. `bury()` releases what the title and the host let go once the submissions that might use it are 64 submissions behind one that has finished: descriptor slots' old resources, host copies, host textures, command allocators. It ran on the relay after the finished count and before the line's ranges were updated and `LINE_LANDED` was signalled. So every relay wait on the submitting thread, and every present waiting for the line, waited for those releases too. ### What changes - `bury()` takes what is due out of `RETIRED` exactly as before (same selection, same `bury_lag()`) and hands it, through a channel, to `victory-bury`: a below-normal-priority thread that only drops what it is given (`host/grave.rs`). - The relay hands it over only after `FINISHED`, the line's `written`/`settling`, `LINE_MOVED` and `LINE_LANDED` are published (`tell_and_bury`). - The settle path and the synchronous submission call `bury()` too, and also hand off. - **Bounded:** past 131,072 objects handed and not yet dropped, the burying thread drops a batch itself, at the old cost, until the thread catches up. - **Logged:** the relay's 5-second line now shows the objects dropped, the drop thread's time, its backlog and peak, and how many objects the burying thread dropped itself because the drop thread was behind. The landing line gets a "burying what was let go" field. - **Safe to drop later and elsewhere:** - Everything handed over is already past its last use on the card. - D3D12 objects are free-threaded. - Besides the releases themselves, the retired objects' drops only change counters and return budget slots to their pool, under that pool's own lock. - Neither depends on the thread that drops them. - `VICTORY_BURY_ASIDE=0` restores the old behaviour: released on the thread that buries, and on the relay before the line is told. It's a `toggled!` switch, so `VICTORY_AB` can flip it while the title runs. ### Tests - `what_is_handed_is_dropped_on_the_thread`: objects handed over are dropped on the grave's thread, and counted. - `dropping_the_grave_drops_all_it_holds_and_ends_its_thread`: when the grave is dropped, everything still queued is dropped and the thread ends without hanging. - `a_grave_behind_hands_back_and_stays_bounded`: past the bound, the caller drops the batch itself. Once the thread catches up, it takes batches again. - `nothing_is_dropped_before_its_submission_and_the_lag`: only objects whose submission is `lag` behind the finished count are due, and an object retired out of order holds back the ones after it. - `bury_drops_on_the_grave_with_the_switch_and_here_without`: `bury_from` drops on the grave with the switch, and on the calling thread before it returns without it. - `a_landing_tells_before_it_buries_only_with_the_grave`: tells, then buries, with the switch; buries, then tells, without it; buries nothing when no flight landed. Swapping the order makes it fail. - `a_resource_a_running_submission_uses_goes_only_after_its_fence_and_the_lag`, on the software adapter: - a buffer is copied from by a submission held on the queue behind a fence wait; - it isn't released while that submission waits, nor after it runs until `lag` more have finished; - then it's dropped on the grave's thread, and the runtime's reference count on it falls by one. - `acceptance_burying_aside`: 20,000 references to live textures, 100 buffers (64 KiB to 2 MiB) and 20 textures of 1024×1024 retired a frame, burying inline against handing to the grave, in alternating runs. - It prints medians of the lander's burying time and of a waiter's wait for the landing. - With `VICTORY_ACCEPTANCE=1` in a release build, it fails unless both are at least ten times as short with the grave. Measured, RTX 5070 Ti, release, 10 alternating runs of 30 frames, medians: | per frame | `VICTORY_BURY_ASIDE=0` | `VICTORY_BURY_ASIDE=1` | |---|---|---| | 20k references + 100 buffers + 20 textures: burying on the lander | 13.9 ms | 0.01 ms | | the same: a waiter's wait for the landing | 13.9 ms | 0.01 ms | | 20k references only: burying on the lander | 0.14 ms | 0.008 ms | | 100 buffers + 20 textures only: burying on the lander | 12.7 ms | 0.009 ms | The cost is in the frees, about 0.1 ms per committed resource, not in the references. The grave's own dropping took 22.8 ms a frame. That's more than the 13.9 ms inline: it runs below normal priority and alongside the next frame's resource creation. Run again on this branch, with `VICTORY_ACCEPTANCE=1`, on a machine whose processors other jobs held fully, the frees were far slower, but the ratio held: - the lander's burying: 155.3 ms with the switch off, 0.011 ms on; - the waiter's wait: 155.4 ms off, 0.012 ms on; - the grave's own dropping: 1,070 ms a frame. That last figure is what the bound and the relay line's "behind" count are for. ## How it was tested - GPU and profile: RTX 5070 Ti 16 GB, Ryzen 9 7900X; Series X profile, 1440p native, DLSS off, frame generation off; ray-tracing passes left out (no structure builder) - Before: in play, the relay thread spent about 16.8 ms a frame landing, 6.99 ms of it in "the rest" (`bury`) - After: in play with `VICTORY_BURY_ASIDE=1` on our integration branch (26–28 fps), the relay lands in 10.9–11.0 ms a frame; the burying thread drops 45,600–48,500 objects a frame in about 12 batches, 6.4–11.3 ms, and nothing waits behind it ("0 waiting for them now"). Other changes are in that build too - `cargo test` passed for the crates it touches: yes. Rebased onto main e1f2eb60: `cargo test --release -p victory-gpu --lib`, 597 passed, 0 failed, 44 ignored ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1358 also moves `bury()`'s drops to a `victory-bury` thread, and batches dynamic slot releases as well. This one differs in where the hand-off happens (after `FINISHED`, the line's ranges, `LINE_MOVED` and `LINE_LANDED` are published), its bound (past 131,072 objects the burying thread catches up itself), the settle path and synchronous submissions handing off too, and its counters and tests. Happy to fold the good parts of either into the other.
bury() released what waited for submissions bury_lag() older than one that
finished on the thread that finished it: with the relay, after the finished
count and before the line's ranges, LINE_LANDED and the waiters woken, in
what the landing line calls "the rest" (6.99 ms a frame in the first
gameplay area, RTX 5070 Ti, 2026-11-28). Now it takes them out of RETIRED
as before and hands them to "victory-bury", a below-normal thread that only
drops what it is given, and the relay does that after it has told and
woken everyone (tell_and_bury).

What is handed is past its last use on the card exactly as before (the same
selection, the same lag); dropping it later and elsewhere changes nothing
for the card. The retired objects' drops are D3D12 releases, counters, and
budget slots given back to their pool under its own lock; none needs the
thread that buries.

Bounded: past 131,072 objects handed and not dropped, the burying thread
drops a batch itself, at the old cost; the relay's 5-second line says how
many, with the thread's backlog, peak and dropping time. The landing line
says how long burying took. VICTORY_BURY_ASIDE=0 puts it all back;
VICTORY_AB can flip it while the title runs.

Measured (acceptance_burying_aside, RTX 5070 Ti, release, 10 alternating
runs of 30 frames, medians): 20,000 references to live textures plus 100
buffers and 20 textures freed a frame took the lander 13.9 ms with the
switch off and 0.01 ms on, and a waiter for the landing as long. The
references alone are 0.14 ms; the frees are the cost.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 07:10:41 +00:00
github-bot closed this pull request 2026-11-29 07:16:13 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2007
No description provided.