GPU: a submission's preludes of barriers can be recorded on several threads #2908
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2908
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2908"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 23:38 UTC · original
0xkn0wh3r3:gpu/submission-preludes-recorded-in-parallel→main· +294 −6 · 2 files · 2 commits · openWhat
At a submission, each list's prelude is decided and recorded on the submitting thread, list after list. The prelude is the barriers that bring the list's textures to the states its first uses need, plus depth-twin copies.
This PR splits that in two:
plan_preludedecides the prelude in submission order: the states each list leaves are the ones the next list starts from. A prelude with twin copies is recorded right there, because those copies read the states the lists before it left.record_preluderecords a barriers-only prelude: allocator reset, barriers, close. Nothing else.With
VICTORY_PARALLEL_PRELUDES=1(off by default), a submission of four or more lists, each submitted once, records its barriers-only preludes on several threads (texture::in_parallel) once they hold 2,048 barriers in all (on_threads). Below that, preludes are recorded in order as before, so small submissions take the same path with the switch on or off. Every prelude is recorded before the lists go to the GPU, in their original order.The diagnostics copies line now counts the state preludes the same way in both settings (it used to leave out the preludes recorded on threads), so the switch can be A/B tested on one build.
Whether it matters: measuring with a title
I can't run the title, so I don't know yet if prelude recording is a noticeable part of the frame. Here's how to find out:
cargo build --profile diag -p victory --features diagnostics(givestarget\diag\victory.exe).VICTORY_PARALLEL_PRELUDES, then withVICTORY_PARALLEL_PRELUDES=1. Let each run settle for a few report intervals. The report is logged every 5 s.… fps, … ms/frame (… preparing: …):ms/frameandpreparing.copies per frame:line, the partstate preludes X ms (N preludes, B barriers, T on threads). All values are per frame.Xis the time spent planning and recording preludes.Nis the number of preludes recorded.Bis the barriers in the barriers-only preludes.Tis how many preludes went on threads.How to read the results:
Tshould be 0 without the switch. IfTis also 0 with the switch, no submission reaches the threshold and the switch changes nothing for this scene.Xis a small fraction ofpreparingwithout the switch (say well under 1 ms), prelude recording doesn't matter for this title and this PR isn't worth taking.Xis a real share ofpreparingwithout the switch, and with the switchT > 0,Xdrops, andms/framedrops by about as much.Measurement (recording only, not a frame)
The test's timing loop (
VICTORY_PRELUDE_BENCH=1) records eight preludes in order and on threads. Release build, Ryzen 9 7900X, medians. The first rows are from the first version of this PR. The later rows come from a local run with the threshold bypassed, to find where the two cross:They break even at roughly 1,500 barriers in all, so below the 2,048 threshold the preludes stay in order. I haven't measured uneven splits, for example one large prelude next to three tiny ones.
Where it came from
From DexNom's fork, DexNom/VIctory@5f4c3df (
PlannedPrelude,record_preludes,parallel_preludes; opt-in there too, and their ordering-test idea). It's built on this tree's preludes and twins. Twin copies stay in order because this tree'sTwin::copytakes its transitions while recording. Credited withCo-authored-by: DexNom.Tested
host::tests::preludes_planned_in_order_record_on_several_threads: eight lists each move 400 textures through states of their own. Each planned prelude, replayed in the GPU's order (prelude, then list) by the debug layer's rule (replay), starts from the states the list before left, and the final states match the tracked ones. Recorded on threads (3,200 barriers), each prelude lands where its list's prelude goes.host::tests::small_submissions_record_their_preludes_in_order: eight preludes of 40 barriers stay in order, eight of 400 go on threads, and so do the cases at and around the threshold.cargo test -p victory-gpu --lib host::, by default, withVICTORY_PARALLEL_PRELUDES=1, and with--features diagnostics: everything passes except the known NVIDIA failuredynamic_slots_are_held_until_released. Two other descriptor tests failed once each across repeated runs and passed on rerun:views_bound_while_another_slot_gets_its_texture_do_not_waitanda_slot_rewritten_while_its_view_is_prepared_views_the_new_record. With--features diagnostics,host::present_plane_tests::compositor_failure_presents_primary_in_the_same_framecrashes the test process on the head before this change too, so it was skipped.cargo clippy -p victory-gpu --all-targets, with and without--features diagnostics: clean.cargo xtask policy: ok.Not tested
@Marvisak on GitHub · 2026-11-26 02:19 UTC · original
Automated triage for the maintainers.
Needs work. This splits
HostList::preludeintoplan_prelude/record_preludeinhost.rs, so that barrier-only preludes can be recorded on several threads withVICTORY_PARALLEL_PRELUDES=1(off by default). The planning still runs in submission order, and the test replays the states correctly. CIcheckpasses. The problem is the benefit: by the PR's own numbers inPARALLEL_PRELUDE_BARRIERS, eight preludes of 400 barriers go from 700 µs to 550 µs, and small ones get slower (200 µs vs 430 µs). That is a small, opt-in gain for a restructured submission path. What would change the verdict: a frame-time measurement from the title showing that prelude recording matters (for example the frame report's prelude time with and without the switch).Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-26 07:23 UTC · original
Thanks. Agreed: without numbers from the title, the gain is unproven. The recording microbenchmark doesn't show that preludes matter in a frame. I can't run the title, so
fe19554fmakes the A/B possible on one build instead.The frame report and preludes. The diagnostics
copies per frame:line already hadstate preludes X ms. With the switch on, though, it left out the preludes recorded on threads after the loop (host.rs,Host::execute), so on and off couldn't be compared. Now that recording is timed too. The field readsstate preludes X ms (N preludes, B barriers, T on threads), per frame, and is counted the same way in both settings.Measuring. Build with
cargo build --profile diag -p victory --features diagnostics. Run the same scene withoutVICTORY_PARALLEL_PRELUDES, then withVICTORY_PARALLEL_PRELUDES=1, and comparestate preludes X msandT on threadswithpreparingandms/frameon the frame line. Prelude recording matters only ifXis a real share ofpreparingwithout the switch, and with itT > 0,Xdrops, andms/framedrops by about the same. IfXis a fraction of a millisecond, orTstays 0, this PR isn't worth taking. These steps are in the PR description.Small preludes getting slower. The 40-barrier row (200 µs vs 430 µs) was measured with the threshold bypassed. In the PR, eight preludes of 40 barriers (320 in all) stay below
PARALLEL_PRELUDE_BARRIERS(2,048) and are recorded in order, the same as with the switch off. The decision is nowon_threads, andsmall_submissions_record_their_preludes_in_ordercovers it: 8×40 stays in order, 8×400 goes on threads, and so do the cases around the threshold. Rerunning the timing loop on the same CPU at more sizes, they break even at roughly 1,500 barriers (8×192: 393 µs in order, 374 µs on threads), so the threshold sits just above that. I haven't measured uneven splits, such as one large prelude next to three tiny ones. I also took the measurements out of the constant's doc comment; they're in the PR description now.If anyone can run a title with the diagnostics build, the two
copies per frame:lines (switch off and on) plus the frame lines would settle this either way.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.