perf(gpu): offload synchronous land() from send_late() to late_helper #512
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!512
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-512"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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 UTCWhat this does
Removes the synchronous
land()call from the end ofHost::send_late()on thevictory-submitthread and instead wakeslate_helperviaLINE_MOVED(settingline.poke = truewhenlanded.len() > BURY_LAG). This keeps command-allocator resets and list recycling off the critical submission thread.Checks
late_helperalready performs the sameland()work asynchronously.Host::send_lateincrates/victory-gpu/src/host.rs.host::unit tests pass; offloading work to an existing helper thread has no distinct pre-existing unit-test failure.VICTORY_LATE_MOST) and #393 (pool).cargo xtask policypassed (359 files ok); no fork-only files, configs, or build outputs.Verified
cargo xtask policy—359 files okPKG=victory-gpu ./build.sh test --lib -- host:: --test-threads=1(Proton Wine on Linux, RX 9070 XT) —76 passed; 0 failed; 4 ignored, 0 warningsCost
None (moves landed-list reset/recycling from
victory-submitontolate_helper; 0 new warnings).AI-assisted: yes
@Kal0s-design on GitHub · 2026-12-04 21:02 UTC · original
Checked
d69f406on 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
landedafter 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.
landedonly 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
landedstayed 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, andlandedwent 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 whenlandedis well past BURY_LAG?AI-assisted: yes
d69f406bf5to420b9ae2b5@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:
poke/ extraLINE_MOVED.notify_one()insend_late()sincerelay_landalready setspokeand wakeslate_helper.landed.len() > (BURY_LAG as usize) * 4high-watermark fallback callingland()after droppinglineandsubmittedso allocator memory stays bounded iflate_helperever falls behind.@Kal0s-design on GitHub · 2026-12-05 00:48 UTC · original
Re-checked
420b9aeon 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
landedunder 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
landedstayed near 128. With the helper held for 5000 sendslandedpeaked 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