Repository navigation
GPU: run submissions asynchronously on a host fence timeline (rebase of #595) - #1923
slatefield wants to merge 1 commit into
Conversation
Submissions are no longer waited for: each signals the next host fence value and joins a timeline of up to 16 in flight, finished in order (copy back, then bottom-of-pipe writes, then title fence signals) by a finisher thread or whichever thread first needs one. Allocators, preludes, scratch, kept objects, twins, dynamic descriptor leases and retired heap resources are released behind their submission's fence. A step touching title memory, host copies or texture staging waits only for in-flight submissions that write (or read) it. Rebased onto the page table, bindless heap views, twins and change journal: a list's after-run work and missed-memory checks move into the pending submission; bindless texture uploads, view heap refreshes and page table refreshes wait for in-flight writers like other steps, a page table is rewritten only with no reader in flight, and a page table user counts as writing every copy it names. A list named again in one submission gets its own prelude, and what its steps write into the list's own memory (upload memory, scratch, budget word) goes into an upload buffer of the submission that the repeat's prelude copies in on the GPU, so each run reads its own data with no CPU wait. List memory is a CPU-visible custom heap the GPU can copy into. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Submissions run asynchronously on a…: async submission path — big behavioral change; needs Windows stress testing.
|
Automated triage for the maintainers. This pull request does not merge cleanly into It will be reviewed once it is rebased onto the current Generated by Claude Code |
|
I put together a tested rebase of #1923 (
Conflicts resolved
Soundness fixes for async submissions + marked-page copy-backs
New synthetic concurrent marked-page tests (
|
… overlap
- runtime/src/xs_memory_waits.h:
* Resolve paired 24 GiB GPU-only <-> CPU-view aliases via rt::xmem::alias_address_fn
(or optional MemoryWaitAlias) in MemoryWaitLog::record_slot, probe_memory_wait,
MemoryWaitHolds::unmet, MemoryWaitHolds::poll, and MemoryWaitHolds::given_up so
waits whose primary VA reads 0x0 or faults immediately observe values written to the
paired alias instead of stalling for the 500 ms deadline.
* Mask 32-bit waits to 32 bits in MemoryWait::holds(), add mid-list work rejection
(MemoryWaitLog::note_work / MemoryWaitRecord::mid_list, adapted from
ThatRecompDev/five-star-recomp@efcc782, GPL-3.0), probe memory outside mutex_,
cascade newly given-up primary+alias addresses across all waiting queues in a single
poll(), add LEONIDA_MEMORY_WAIT_TIMEOUT_MS optional bound, and add lock-free-fast-path
notify_write() / set_wake_callback() / wait_for_change() for sub-ms write wakeups.
- runtime/src/vulkan_present.h:
* Implement clean N-1 frame overlap (concept adapted from Marvisak/VIctory#1923,
GPL-3.0): submit frame N immediately and wait on frame N-1's fence afterward so the
GPU stays fed with 1 frame in flight ahead of the CPU.
* Add LEONIDA_PRESENT_SYNC=1 opt-out (and set_sync_present/sync_present accessors) to
wait on frame N when needed for debugging or captures.
* Make LEONIDA_CAPTURE race-free and low-overhead under N-1 overlap: record exact
pending_capture_{number,extent,format}, copy to the staging buffer only on selected
disk-capture frames (unless enable_capture() readback is active), and harvest
completed captures non-blockingly via vkGetFenceStatus when the next frame does not
overwrite the staging buffer.
* Release stale plane VkImageViews right after each frame slot's fence completes.
- runtime/test/xs_memory_waits_test.cpp & runtime/test/xbox_present_test.cpp:
* Add 20 CPU checks for alias wakeup, faulting-VA fallback, mid-list rejection,
32-bit masking, cross-queue timeout cascade, and immediate notify_write wakeups.
* Add GPU/Vulkan validation tests for N-1 overlap bursts, LEONIDA_PRESENT_SYNC=1,
and race-free LEONIDA_CAPTURE disk output without enable_capture().
|
I built on @nathanbzrr's rebase of this PR ( What holds.
What I fixed (
Two synthetic tests (declared ranges and marked pages) place a title write between the read and the write-back. Both fail with the whole-piece write put back, and both fail with the recheck removed. Opt-in. Overlaps.
Still open.
Checks. The title was not used in these tests. AI-assisted |
Rebase of #595 onto current
main(4118f33). The original work is wbkepler's; the commit is kept with its author and message, only conflict resolution sits inside it. If #595 is updated first, take that one.Why it is the biggest frame-time change available:
Host::executewaits for every submission before copying back, so a world frame's ~150 submissions are fully serialized and the CPU and GPU never overlap. The author measured, on an RTX 5090 in the world: median 283 -> 267 ms/frame, mean 319 -> 286, GPU wait per frame 79 -> 1 ms, with no device removal over 7-minute runs; a 5070 tester saw 1.8-2.0 -> 2.0-2.5 fps. It also makes a list reset while it runs safe, which is what the title does every frame.The rebase, 5 conflict regions over 3 files:
descriptor.rs:maininlinedshader_slot()away; the PR's heap-id scheme (NEXT_HEAP_ID, id-basedrelease_dynamic) is applied to main's inlined code.host.rsx3: main'sid/ScratchChunkgrowth kept, the PR'sbudget/last/fresh_afterfields and spare-chunk pool added. One design choice: scratch allocation uses the PR'slist_buffer(L0 custom heap) rather than main'supload_buffer, because repeated-list preludesCopyBufferRegioninto scratch and a D3D12 upload-heap resource cannot be a copy destination.shadow.rs: main's newerupdate_busyand the PR'sstale/submission_donekept side by side.executenow callhost.drain(), as tester notes on the PR said.Checked here: Windows-target clippy for
victory-gpuandvictory(and whole workspace) with and without--all-features, clean; native tests green for the crates that build on Linux (shader 144, formats 38, game 15, core 13, pipeline 7);timeline.rsis pure std, compiled and its tests run natively (ordering, signals, conflicts) and pass;cargo xtask policy183 files ok.Not checked, needs a Windows GPU: the 9 new tests and the live numbers. Also worth knowing before merging, from the PR's own review thread:
refresh_conflictignores in-flight GPU reads (a reviewer reproduced it; the author deferred it), the AMD inbox repeated-recording test fails there while WARP passes, and present still drains the frame.ID3D12CommandQueue::Waitis a no-op onmain(queue.rs:167) and the synchronous wait is what hides it today; #32 is the PR that fixesWait, and it is worth landing near this one.If merged as-is, the next bottleneck is CPU preparation (the author measured 148 -> 241 ms, title-memory copies); their note is that shadow buffers in VRAM with GPU dirty tracking is the next target.