perf(gpu): offload synchronous land() from send_late() to late_helper #512

Manually merged
github merged 1 commit from github-bot/gh-512 into gh-pr/512/base 2026-12-05 17:32:43 +00:00 AGit
Owner

@⁠Not4Eric on GitHub · 2026-12-04 20:24 UTC · original
Not4Eric:perf/host-offload-send-late-land → main · +7 −4 · 1 files · 1 commits · merged 2026-12-05 17:29 UTC

What this does

Removes the synchronous land() call from the end of Host::send_late() on the victory-submit thread and instead wakes late_helper via LINE_MOVED (setting line.poke = true when landed.len() > BURY_LAG). This keeps command-allocator resets and list recycling off the critical submission thread.

Checks

  • N/A: pure scheduling optimization; late_helper already performs the same land() work asynchronously.
  • N/A: no switches added, changed, or removed.
  • No unrelated cleanup: diff is limited to Host::send_late in crates/victory-gpu/src/host.rs.
  • N/A: existing host:: unit tests pass; offloading work to an existing helper thread has no distinct pre-existing unit-test failure.
  • Checked open PR queue: independent of #385 (VICTORY_LATE_MOST) and #393 (pool).
  • cargo xtask policy passed (359 files ok); no fork-only files, configs, or build outputs.

Verified

  • cargo xtask policy — 359 files ok
  • PKG=victory-gpu ./build.sh test --lib -- host:: --test-threads=1 (Proton Wine on Linux, RX 9070 XT) — 76 passed; 0 failed; 4 ignored, 0 warnings
  • Also exercised in gameplay on GTA 6 Series S (Ryzen 5 7600X, RX 9070 XT, CachyOS + Proton); not benchmarked in isolation.

Cost

None (moves landed-list reset/recycling from victory-submit onto late_helper; 0 new warnings).

AI-assisted: yes

**@⁠Not4Eric** on GitHub · 2026-12-04 20:24 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/512) `Not4Eric:perf/host-offload-send-late-land` → `main` · +7 −4 · 1 files · 1 commits · merged 2026-12-05 17:29 UTC ## What this does Removes the synchronous `land()` call from the end of `Host::send_late()` on the `victory-submit` thread and instead wakes `late_helper` via `LINE_MOVED` (setting `line.poke = true` when `landed.len() > BURY_LAG`). This keeps command-allocator resets and list recycling off the critical submission thread. ## Checks - N/A: pure scheduling optimization; `late_helper` already performs the same `land()` work asynchronously. - N/A: no switches added, changed, or removed. - [x] No unrelated cleanup: diff is limited to `Host::send_late` in `crates/victory-gpu/src/host.rs`. - N/A: existing `host::` unit tests pass; offloading work to an existing helper thread has no distinct pre-existing unit-test failure. - [x] Checked open PR queue: independent of #385 (`VICTORY_LATE_MOST`) and #393 (`pool`). - [x] `cargo xtask policy` passed (`359 files ok`); no fork-only files, configs, or build outputs. ## Verified - `cargo xtask policy` — `359 files ok` - `PKG=victory-gpu ./build.sh test --lib -- host:: --test-threads=1` (Proton Wine on Linux, RX 9070 XT) — `76 passed; 0 failed; 4 ignored`, 0 warnings - Also exercised in gameplay on GTA 6 Series S (Ryzen 5 7600X, RX 9070 XT, CachyOS + Proton); not benchmarked in isolation. ## Cost None (moves landed-list reset/recycling from `victory-submit` onto `late_helper`; 0 new warnings). AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 20:27:40 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 21:02 UTC · original

Checked d69f406 on native Windows (one NVIDIA desktop card plus WARP, didn't run the game).

Tests match main. host:: gives 74 passed / 2 failed on the card and 76 / 3 on WARP with diagnostics and the debug layer, same on both sides (the pipeline library loads, plus a descriptor views test on WARP that fails on main too). Full victory-gpu lib is 352 / 5 on both, all known native failures. Clippy with and without diagnostics shows nothing new in host.rs. None of the existing tests reach send_late though, so all this shows is that nothing else broke.

The change looks safe to me. A list only gets into landed after relay_worker has seen its fence complete (host.rs:4161, 4198), and this PR only makes the reset later, never earlier. late_helper is always running by the time send_late is reached, because execute_parts calls late_threads() first (host.rs:4250) and there's no switch that turns the helper off. land() used to run on both the submit thread and the helper. Now it only runs on the helper, and the lock order is unchanged since the removed call came after drop(submitted).

The new poke is redundant. landed only grows in relay_land, and that already sets poke and calls notify_all right after (host.rs:4198, 4214, 4216). So when send_late sees more than BURY_LAG, poke is already set. It's harmless because it's all under the LINE lock, so no lost wakeup, but the PR could just be the two deleted lines.

I ran a throwaway test (not committed) that pushes 5000 empty lists through execute_late on the device. On main the submit-thread land() drained one list in about 4% of sends, so the helper was doing nearly all of it already and the saving is small. The one real difference is when the helper falls behind. I held it in a sleep for 5000 sends. On main landed stayed at 129 and no new lists were made. With the PR it grew to 5128, and whoever asked for a fresh list made a new list and allocator instead of reusing one (list.rs:254), about 4990 of them. In the test that pushed create+send from about 47 to 630 us per send on the card. Once the helper woke up, everything was recycled, the idle pool capped at 512, and landed went back to 128. The debug layer was on and reported nothing about allocators. So it's bounded, but it no longer has the submit-thread backstop. In the engine each backlogged list also holds its uploads and draw state until recycle. The helper is light and nothing I found holds a lock it needs across a submission, so this should only show up if the helper gets starved. Maybe keep a cheap fallback that runs land() on the submit thread only when landed is well past BURY_LAG?

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 21:02 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/512#issuecomment-7424146326) Checked d69f406 on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). Tests match main. `host::` gives 74 passed / 2 failed on the card and 76 / 3 on WARP with diagnostics and the debug layer, same on both sides (the pipeline library loads, plus a descriptor views test on WARP that fails on main too). Full victory-gpu lib is 352 / 5 on both, all known native failures. Clippy with and without diagnostics shows nothing new in host.rs. None of the existing tests reach send_late though, so all this shows is that nothing else broke. The change looks safe to me. A list only gets into `landed` after relay_worker has seen its fence complete (host.rs:4161, 4198), and this PR only makes the reset later, never earlier. late_helper is always running by the time send_late is reached, because execute_parts calls late_threads() first (host.rs:4250) and there's no switch that turns the helper off. land() used to run on both the submit thread and the helper. Now it only runs on the helper, and the lock order is unchanged since the removed call came after drop(submitted). The new poke is redundant. `landed` only grows in relay_land, and that already sets poke and calls notify_all right after (host.rs:4198, 4214, 4216). So when send_late sees more than BURY_LAG, poke is already set. It's harmless because it's all under the LINE lock, so no lost wakeup, but the PR could just be the two deleted lines. I ran a throwaway test (not committed) that pushes 5000 empty lists through execute_late on the device. On main the submit-thread land() drained one list in about 4% of sends, so the helper was doing nearly all of it already and the saving is small. The one real difference is when the helper falls behind. I held it in a sleep for 5000 sends. On main `landed` stayed at 129 and no new lists were made. With the PR it grew to 5128, and whoever asked for a fresh list made a new list and allocator instead of reusing one (list.rs:254), about 4990 of them. In the test that pushed create+send from about 47 to 630 us per send on the card. Once the helper woke up, everything was recycled, the idle pool capped at 512, and `landed` went back to 128. The debug layer was on and reported nothing about allocators. So it's bounded, but it no longer has the submit-thread backstop. In the engine each backlogged list also holds its uploads and draw state until recycle. The helper is light and nothing I found holds a lock it needs across a submission, so this should only show up if the helper gets starved. Maybe keep a cheap fallback that runs land() on the submit thread only when `landed` is well past BURY_LAG? AI-assisted: yes
github-bot force-pushed github-bot/gh-512 from d69f406bf5 to 420b9ae2b5 2026-12-05 00:05:53 +00:00 Compare
Author
Owner

@⁠Not4Eric on GitHub · 2026-12-05 00:00 UTC · original

Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this

Pushed updates addressing your review:

  • Removed the redundant poke / extra LINE_MOVED.notify_one() in send_late() since relay_land already sets poke and wakes late_helper.
  • Added a landed.len() > (BURY_LAG as usize) * 4 high-watermark fallback calling land() after dropping line and submitted so allocator memory stays bounded if late_helper ever falls behind.
**@⁠Not4Eric** on GitHub · 2026-12-05 00:00 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/512#issuecomment-7427750777) Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this Pushed updates addressing your review: - Removed the redundant `poke` / extra `LINE_MOVED.notify_one()` in `send_late()` since `relay_land` already sets `poke` and wakes `late_helper`. - Added a `landed.len() > (BURY_LAG as usize) * 4` high-watermark fallback calling `land()` after dropping `line` and `submitted` so allocator memory stays bounded if `late_helper` ever falls behind.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-05 00:48 UTC · original

Re-checked 420b9ae on native Windows (didn't run the game).

The redundant poke and notify are gone, and the fallback looks right. It sits after drop(submitted) (host.rs:4303), exactly where main's unconditional land() was, so the lock order matches main. land() on the submit thread racing the helper's land() is also what main already does on every send. Each call drains its own slice of landed under the line lock, so they never get the same lists.

I re-ran the stalled-helper test on the card with the debug layer. With the helper healthy the fallback never fired in 5000 sends and landed stayed near 128. With the helper held for 5000 sends landed peaked at 512, the fallback ran 12 times and about 380 new lists were made instead of ~4990. After release it went back to 128. The debug layer said nothing about lists or allocators. 4x BURY_LAG seems a sane threshold.

Full victory-gpu lib is 352 passed / 5 failed, the same known native failures as before, and clippy with and without diagnostics shows nothing new.

Looks good to me.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-05 00:48 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/512#issuecomment-7428648402) Re-checked 420b9ae on native Windows (didn't run the game). The redundant poke and notify are gone, and the fallback looks right. It sits after drop(submitted) (host.rs:4303), exactly where main's unconditional land() was, so the lock order matches main. land() on the submit thread racing the helper's land() is also what main already does on every send. Each call drains its own slice of `landed` under the line lock, so they never get the same lists. I re-ran the stalled-helper test on the card with the debug layer. With the helper healthy the fallback never fired in 5000 sends and `landed` stayed near 128. With the helper held for 5000 sends `landed` peaked at 512, the fallback ran 12 times and about 380 new lists were made instead of ~4990. After release it went back to 128. The debug layer said nothing about lists or allocators. 4x BURY_LAG seems a sane threshold. Full victory-gpu lib is 352 passed / 5 failed, the same known native failures as before, and clippy with and without diagnostics shows nothing new. Looks good to me. AI-assisted: yes
github-bot changed target branch from main to gh-pr/512/base 2026-12-05 17:32:41 +00:00
github manually merged commit 420b9ae2b5 into gh-pr/512/base 2026-12-05 17:32:43 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.