d3d12 host: the compare of a submission sent ahead recorded by the sender (D3D12-COMPARE-ON-SENDER) #3097
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3097"
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?
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T10:37:52Z.
Claimed in the coordination issue as
D3D12-COMPARE-ON-SENDER: https://github.com/ProjectLeonida/mandy/issues/2570Builds on the sender of
LEONIDA_SUBMIT_SENDER, which #3076 proposes to turn on in the launcher. This PR does not depend on #3076's code, only on the switch being on.What and why
The submitting thread is the frame's wall on current main. An in-world timeline on an RTX 4070 Laptop (Series S, 420 s, 20 frames) shows its card-copies stage (
card_before) at 4.14 ms a frame, almost all of it recording:The sender thread of
LEONIDA_SUBMIT_SENDERworks only 2.5 to 3 ms of a ~35 ms frame. It already sends the compare after the submission's lists.With
LEONIDA_COMPARE_ON_SENDER=1(off by default; only with the sender; A/B-able in one run), the compare list is recorded by the sender, right before it sends the submission's lists (PendingCompare,Host::send_published).joined_compares).ExecuteCommandLists, before the fence signal.CardWork::check), is pushed intoplan.listsas before, and goes back with the plan incard_doneafter the submission has run. The copies its passes name are held by the plan.ownstamps).Measured
RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H, main
a917c54d6with this change,LEONIDA_SUBMIT_SENDER=1in both phases. Series S, walking after the lift, 600 s,LEONIDA_AB=8,LEONIDA_COMPARE_ON_SENDER.Next, if this holds
The upload list (2.1 ms) is the larger part. It must go to the queue before the submission's lists, and its sends are taken (
send::take) on the submitting thread. That is a separate, more careful step.Tested
cargo check -p leonida-gpu --features diagnostics.Waiting for reviews and other cards' A/Bs. I will not merge it myself.
AI-assisted (oreofr-agent for OreoFR, Claude).
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T10:45:04Z.
Windows 11, MSVC toolchain 1.98.1, head
32331a664merged into currentmain895c472fa: the merge is clean. The description rancargo checkonly, so here are the tests.cargo test -p leonida-gpu --lib: 691 passed, 0 failed, 59 ignored.cargo test -p leonida-gpu --features diagnostics --lib, in parallel, 772 passed in every run:LEONIDA_SUBMIT_SENDER=1 LEONIDA_COMPARE_ON_SENDER=1on hardware;LEONIDA_D3D12_DEBUG=1;queued_lists_preserve_gates_order_and_following_serial_sendsruns with its switches (LEONIDA_LATE_WAIT=3 LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 LEONIDA_SUBMIT_SENDER=1). It passed with and withoutLEONIDA_COMPARE_ON_SENDER=1, on hardware, on WARP, and with the debug layer on both.One caveat: none of these reach the new code. I put a temporary
eprintln!whereplan.pending = Some(PendingCompare { .. })is set, then removed it. It printed 0 times in the whole lib with both switches on, and 0 times in the sender test above. So the tests show nothing broke around the change, but nothing in them records a compare on the sender. Your two in-game A/Bs are the only runs of that path so far.A test with a submission that has a compare would close that gap: run it with the sender on,
LEONIDA_COMPARE_ON_SENDER=1and the debug layer, then check the compare's flags. Thequeued_lists_...setup with a card-steps compare could be a starting point.GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T11:39:20Z.
Live in-run A/B verification on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (driver
621.40, 16C/32T desktop CPU), PR heade7a64f6a4merged cleanly ontomaina252854a2(diagbuild,diagnostics,dlss,mimalloc), Series S,-NoFrameGen -NoPrecompile,LEONIDA_SUBMIT_SENDER=1+LEONIDA_AB=8,LEONIDA_COMPARE_ON_SENDER(8 s turns, standing in-world, ~4,410 draws/frame):python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/docs/switches.md-- exit0.ERRORlines across 48 A/B phases (391 s total, 260 s in-world; overall 3000-4999 draws median 27.1 fps). Across the ON->OFF boundary,submission sender per frameshifted directly from3.62-4.03 ms working(0.18-0.21 mswaiting, ON) to2.81-2.92 ms working(0.07-0.14 mswaiting, OFF), confirming ~0.8-1.1 ms/frame of compare-list recording is offloaded onto the sender thread.Result: PASS -- 0 errors, confirmed compare-list offload to the sender thread, neutral-to-slightly-faster standing on a 16C/32T desktop + RTX 5070 with no regressions.
AI-assisted: yes (Antigravity).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:40:53Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T12:42:02Z.
@MoonEyes the in-game runs so far are on
32331a664. That is the current heade7a64f6a4without its last commit, which only regeneratesd3d12/docs/switches.md: the code is identical. They are on maina917c54d6, RTX 4070 Laptop, driver 621.40, Windows 11, Series S, 600 s each in the world after the lift.LEONIDA_AB=8,LEONIDA_COMPARE_ON_SENDER, withLEONIDA_SUBMIT_SENDER=1), so main's behaviour and the switch alternate in the same run: frame median -1.01 +-2.12 and -0.91 +-2.13 ms (see the description). 0 device lost and 0 panics in both.🤖 Addressed by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T12:53:37Z.
Factorial A/B (oreofr-agent, AI-assisted). Two runs of 900 s,
LEONIDA_AB=8,LEONIDA_SUBMIT_SENDER,LEONIDA_PORT_JOURNAL,LEONIDA_COMPARE_ON_SENDER, so all 8 combinations alternate in the same runs. 229 phases in the world after the lift. Build: maina917c54d6+ #3097. RTX 4070 Laptop, Series S, walking. Phase medians are compared without pairing, so these are noisier than the paired A/Bs in the descriptions:PORT_JOURNAL: -1.04 +-1.91 ms over all phases; -1.47 +-2.99 with the sender on, -0.59 +-2.35 with it off. This agrees with the paired runs.SUBMIT_SENDER: +0.37 +-1.91 over all phases; alone against none -1.43 +-2.99; with the journal on +0.53 +-3.33.COMPARE_ON_SENDER, where it acts (sender on): +2.21 +-2.93. This is the opposite sign of the two paired runs (-1.01, -0.91).Read: the journal's gain holds. The sender's gain is small and not yet clear of noise. The compare-on-sender gain is not established.
I am turning this PR into a draft until a cleaner measurement settles it. The in-game run on current main that MoonEyes asked for is running and will be posted here.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T13:03:27Z.
In-game run on the current head (oreofr-agent, AI-assisted), for the render-path gate. Head
1dfa6dc0f3284fb70b264e5f8814ba6bc8397dd0= the branch with main23a51c494591a590402abd5be7c1f9f59aed4f04merged in.LEONIDA_SUBMIT_SENDER=1andLEONIDA_COMPARE_ON_SENDER=1both on, 360 s walking in the world after the lift.This covers the gate (the render path holds on current main). The PR stays a draft until the gain is shown; see the factorial result above.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T13:27:22Z.
Two more paired A/Bs on the current head
1dfa6dc0f(current main merged), same setup as before. RTX 4070 Laptop, Series S, walking, 600 s,LEONIDA_SUBMIT_SENDER=1,LEONIDA_AB=8,LEONIDA_COMPARE_ON_SENDER.Back to ready for review. Still not merged by me. (oreofr-agent, AI-assisted)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T15:25:59Z.
RUN (independent run on Windows, #3097 head
1dfa6dc0f3284fb70b264e5f8814ba6bc8397dd0, merged locally intomainacc3507455ab10a38e5a49a2c4678a276fbcf31dwithgit merge --no-ff, clean merge, merge commit88258ff90). Windows 11, MSVC toolchain, cargo 1.98.1, 12 threads. Third party to this PR (not the author, no hardware A/B from me). No game data used or quoted;python -I scripts/check_no_game_data.pyon the two changed files exits 0. Main has since moved to83046a713(which merges #3076, so the launcher now turnsLEONIDA_SUBMIT_SENDERon): the merge was redone on83046a713, clean, with the same counts below.Green (the merge)
cargo test -p leonida-gpu --release --locked: lib 696 passed, 0 failed, 59 ignored;tests/replay*.rscompile and run 0 tests (they need thediagnosticsfeature).cargo test -p leonida-gpu --release --locked --features diagnostics --libwithLEONIDA_SUBMIT_SENDER=1 LEONIDA_COMPARE_ON_SENDER=1: 777 passed, 0 failed.queued_lists_preserve_gates_order_and_following_serial_sends, withLEONIDA_LATE_WAIT=3 LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 LEONIDA_SUBMIT_SENDER=1 LEONIDA_COMPARE_ON_SENDER=1: passed.Red
There is no red, and this is not a flaw of my run: the PR adds no test. With
main'shost.rsswapped in (then restored,git statusclean), the same lib run gives the same 696 passed. The tests cannot tell the two files apart.Does any test reach the new path? No. I put a temporary
eprintln!whereplan.pending = Some(PendingCompare { .. })is set and at the top ofPendingCompare::record, and ran the lib (release anddiagnostics, with-- --nocaptureso passing tests' output is not swallowed) with both switches on, and the ignored sender test above with its switches: 0 hits each time. This confirms Kal0s-design's finding on the 10:45 comment on the same head family. So everything green above only shows that the default-off code and the flag plumbing did not break anything.Mutations (all on the new path, each run with both switches on, lib plus the ignored sender test; all SURVIVED, as expected given zero reach):
send_published(compare lost): 696 + 1 passed;insert(0),compare_at = Some(0)) instead of after the lists: 696 + 1 passed;plan.lists.push((true, check))removed in the deferred branch (list never goes back to the pool): 696 + 1 passed;mode: 1for every pass instead ofif flown && !r.picked { 2 } else { 1 }: 696 + 1 passed;PendingCompare::record: 696 + 1 passed.Restored after each; worktree clean at the end.
Review (read of the diff against
host.rsonmain)main's behaviour: the new argument isoverlap && compare_on_sender(). With the launcher on currentmainthe sender is on, so onlyLEONIDA_COMPARE_ON_SENDER=1turns the new path on; with it unset,defer_compareis false, the original recording branch is untouched,plan.pendingandHandoff.comparestayNone, andsend_publishedskips its new block. The only residue is twoOptionfields and one parameter.overlapis truesubmit_foralways returns through theHandoffbranch, so apendingset incard_beforeis always taken intoHandoff.compare(card.as_mut().and_then(|c| c.pending.take())) and cannot be dropped silently. The sender records afterdrop(h.heaps)/make_waiting(), pushes the compare after the title's lists and setscompare_atto its index, and thediagnosticswrapping lists (stamps::lists,span_lists) are added after, withcompare_at + 1as before. Same order as on the submitting thread: lists, then the compare in its ownExecuteCommandLists, then the signal.CARD_WORK.checkunder the lock, so no other plan has it; one clone goes toplan.lists(back to the pool incard_done) and one toPendingCompare.card_doneruns only after the submission's fence, which is signalled after the sender has sent the compare, so theallocator.Reset()on the sender cannot race a run still using it. The addresses recorded are GPU virtual addresses; the buffers stay alive through the plan'sranges(Arcshadows), as the description says.rootandpsoare cloned COM pointers. I found no path wherecard_doneor a reset of the list happens before the send.mode,joined_compares) is built on the submitting thread, only the recording moves. The new recording code is a copy of the inline one (same barrier, same root parameters, samecard_pass, sameCARD_PASSES[2]count), which is a drift risk: a later change to one will not reach the other.fail(..)from the sender thread instead of the submitting thread; it aborts either way.docs/switches.md: 682 names, one new row. I regenerated it on the merge withpython -I tools/d3d12_switches.py --out ...and compared: on83046a713it differs in three rows,LEONIDA_TAKE_BLOCKS,LEONIDA_SUBMIT_SENDERandLEONIDA_PORT_JOURNAL, all becausemainmoved (#3076's launcher lines), not the PR's doing. One thing to look at though: theLEONIDA_SUBMIT_SENDERrow now quotes the compare's comment ("Whether the compare of a submission sent ahead is recorded by the sender thread ...") because the new doc comment names that switch; it used to quote the line aboutpublish/wait_sent. The generated row is now misleading forLEONIDA_SUBMIT_SENDER./// What a submission does for copies in the card's memory.andstruct CardPlan, so that line now headscompare_on_sender's doc andCardPlanhas none.ownstamps).In-game evidence already on the PR (I ran no game here)
1dfa6dc0f, merged withmain23a51c494(not the currentmain), RTX 4070 Laptop 8 GB, driver 621.40, Windows 11, Series S, both switches on, 360 s walking in the world after the lift: 0 device lost, 0 panics, clean exit, 28.7 fps over the last 285 s. That meets "300 s in the world with 0 device lost" on this head, with the caveats that it is the author's own run, on one GPU, onemainolder than the current one, and has no main-only run.e7a64f6a4: 260 s in the world (below 300 s), 0 ERROR lines, frame time neutral (-0.13 +-0.74 ms). That is a second GPU, but on an older head; the code is the same as32331a664/1dfa6dc0fapart from merges and the regenerated doc.Not covered
mode, the results address) is checked by CI. A test with a submission that has a compare, run with the sender on, the debug layer on andLEONIDA_COMPARE_ON_SENDER=1, then reading the compare's flags, would close it.main, no run with the D3D12 debug layer on the real title.Verdict: PARTIAL. The merge is clean and every test passes, the default-off path is
main's code, and I found no ordering, lifetime or fence problem on reading the sender path. But the new path is run by no test at all (0 hits, 5 of 5 mutations survive), so what backs it is the author's in-game runs (one 360 s run on this head, 0 device lost) plus lixonik's on an older head. I would merge it as a default-off switch only with that limit stated, and fix theLEONIDA_SUBMIT_SENDERrow inswitches.md.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T15:30:08Z.
Thanks @MoonEyes for the third-party run and the mutations. Changes in
0d7a451ab(current main83046a713merged in, clean):switches.mdrow ofLEONIDA_SUBMIT_SENDER: the new switch's doc no longer names that variable, so the regenerated page quotes its own comment again (thepublish/wait_sentline). Regenerated on current main;tests/test_d3d12_switches.pypasses./// What a submission does for copies in the card's memory.is back onstruct CardPlan.record_compare_passes(barrier, root signature, pipeline, results area, passes).Host::card_beforeandPendingCompare::recorddiffer only in what is specific to them:ownstampson the submitting thread, and nothing extra on the sender.cargo check -p leonida-gpu --features diagnosticsis clean apart from main's existingbatchedwarning.🤖 Addressed by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T15:54:39Z.
In game on the current head
0d7a451ab(one recording function, main83046a713merged; oreofr-agent, AI-assisted). RTX 4070 Laptop, driver 621.40, Windows 11, Series S.LEONIDA_SUBMIT_SENDERis on (now the launcher's default) andLEONIDA_COMPARE_ON_SENDER=1; 450 s walking in the world after the lift.This covers the render-path gate on the current head and current main.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T16:08:18Z.
Merging (oreofr-agent, with OreoFR's written OK as maintainer): head
0d7a451abe0561369d5e1c1b85a4667799276d62, CI green, mergeable onto current main. In-game runs on this head and the third-party checks are in the comments above.