D3D12-SHADER-OPT-MERGE-WALK: keep the merge walk's tables between programs (full-archive wall -7 %) #2822
Open
bobcatchris wants to merge 2 commits from
upstream-pr/2822 into main
pull from: upstream-pr/2822
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
ProjectLeonida/mandy!2822
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2822"
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 bobcatchris on 2026-12-01T02:05:24Z.
Item: D3D12-SHADER-OPT-MERGE-WALK, claimed at https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7298213349 (second attempt at the released D3D12-SHADER-OPT-MERGE-KEYS, https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7297836058).
What
Module::merge(the FOLD/REUSE/FACTS/LOADS walk inemit/bitcode/opt.rs) made its three tables (known,dom_reads,lane_reads), its replacement list and itspath_has_writescratch new for every round of every program. The tables now live in aMergeWalkkept in a thread-local byoptimise, between rounds and between programs, cleared at the start of every round.path_has_writereuses a visited-stamp array and a frontier, the block body is compacted in place, andKey's argument lists are shared (Rc<[V]>) so a key clone is a refcount bump.The walk makes the same decisions: same keys, same insertion and removal order, no table is iterated. This is a pure speed change; the DXIL does not change.
Measured (Ryzen 7 7800X3D, Windows 11; no game run, no GPU involved)
Full-archive
leonida translate(LEONIDA_HOST_RDNA=1, local hash instrument for output identity), four alternating pairs againstmaind920d850d:main(The kernel drop is the bucket arrays' page faults; the last two pairs ran under background load that inflated both sides' kernel time. A first version with only the clone fix and per-
optimisereuse measured neutral, see the release comment; the saving is the growth between programs.)main; the single exception across runs was two containers of one compute program that also flip between runs of unmodifiedmain(pre-existing nondeterminism, reported as a finding in #2570). Byte-identical output makes validator results identical by construction.cargo test -p leonida-shader --lib: 403 passed, 0 failed (includes the optimiser fuzz testevery_pass_leaves_what_random_programs_store).cargo clippy -p leonida-shader --no-deps --all-targets: no new warnings (3 pre-existing, the same asmainon this toolchain).python -I scripts/check_no_game_data.pyon the changed file: clean.AI-assisted: Claude Sonnet 5.5
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T02:11:26Z.
Verified by OreoFR on macOS 27.2.1, Apple M5, Rust (rustup), head
edc3edfb0, mainbf19719ab. CPU only, no game archive.MEASURED
cargo test --release -p leonida-shader: main 242 passed, 0 failed, 2 ignored; main + this PR (merge-tree, no conflict) 242 passed, 0 failed, 2 ignored. The same counts with--features diagnostics. The build warning count is unchanged (2 / 2).READ IN CODE
MergeWalklives in athread_local!RefCell, borrowed mutably for the whole round loop inoptimise. That would panic ifoptimisere-entered on the same thread, but it doesn't. Outside the tests, the only caller isemit/shader.rs:706, andmerge,prune,guardsandchainsdon't call it.known,dom_readsandlane_readsare cleared at the start of every round.replis cleared and resized toinsts.len().path_has_write's visit stamps:seenis resized toblocks.len()per walk, andstamponly grows across programs (it is kept in the walk). A slot left over from a previous program therefore holds an older stamp and can never equal the current mark. On wraparound to 0,seenis zeroed and the stamp restarts at 1. Correct.Key::CallandKey::Gepnow holdRc<[V]>. Equality and hashing go through the slice contents, so keys compare as before. TheRcis notSend, but the walk is thread-local, so that's consistent.ASSUMED
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T02:21:47Z.
Verified on Windows: the crate is green with it, and the tests it touches pass with and without the change - which is what an optimisation is supposed to do, and also why this comment cannot tell you it works.
maind920d850d, cherry-picked (the branch is atmain,merge-base=d920d850d),cargo 1.98.1:So the suite does not distinguish the two trees, and that is the honest finding: "keep the merge walk's tables between" is a claim about work not done, not about answers changed, and a passing suite proves the answers did not change - which is the property you want, and it is not evidence that the tables are kept.
What would be evidence: the merge walk's cost on the same inputs. If the pull request has a measurement in its description, that is what to check, not this - and if it does not, one counter or one timing over a fixed corpus would settle it in a way the 403 tests cannot.
opt::has 17 tests and none of them measures the walk.What I can say it did not break: 403 tests, 0 failures, 5 ignored, and the crate's slowest suite (
358.89 s) is green - including the bitcode emission paths the walk sits in.AI-assisted: yes - DeepSeek v4.1 (flash), three runs of the shader crate.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-12-01T03:13:38Z.
Independent allocation count and bitcode comparison on native Windows. I built main
90c514437and the clean merge ofedc3edfb0into it (tree98e61082e) in Release with Rust 1.98.1/MSVC. Both used the same scratch-only test and the 400 stockrandom_programseeds.Each of two fresh processes per tree optimised the whole corpus on one thread in ascending, descending and strided seed order. A thread-local allocator probe counted requests only during
Module::optimise(ALL). Its one-allocation control passed. Program generation, interpreter checks and serialization ran outside the counter.That is about 14.4% fewer allocation calls on this synthetic corpus. Every order preserved the unoptimised interpreter stores for three input patterns per seed. The optimized bitcode matched byte for byte across all orders and across both trees, including in fresh processes. This measures allocator calls in the optimiser. Wall time and retained scratch capacity are outside the measurement.
AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T04:46:12Z.
Review: COMMENTED
Verified on this box, and with the right evidence this time: the Python semantic suite is not evidence for this diff.
tests/semantic/support.py:16-17importstools/rdna2spirv.py, the Python translator, and never loads the Rustleonida-shadercrate; I ran it anyway (553 files / 6,720 tests on both head and86c30fcea, 0 failed) and it is identical by construction.What does support the claim:
cargo test -p leonida-shader --lib-> 403 passed, 0 failed, 5 ignored (296 s), includingevery_pass_leaves_what_random_programs_store; matches your number.FOLD,REUSE,FACTS,LOADS,FOLD|REUSE,LOADS|FOLD,ALL), hashingModule::write()output afteroptimise. Head and main identical, 2,800/2,800 lines, combined hashebacbd16065ce4dcon both. That exercises the retained tables across thousands of programs in one thread, so "the same decisions" holds for the optimiser's own output.The mechanism reads correctly: every table is cleared before it is read (
opt.rs:913-917), the stamp is monotonic with a correct wrap that zeroesseen(885-889),kept <= rmakes the in-place body compaction non-destructive (1005-1087), and retention is bounded by the largest module a thread sees, not by the 25,689 programs.One non-blocking nit:
borrow_mutis held across the whole four-round loop (:282-299), includingprune/guards/chains, so a future pass that calledoptimisefrom inside it would panic on the borrow rather than start a fresh walk — a one-line comment there would save the next reader an hour.I could not replay the 25,689-program archive (this machine has no work folder with programs, and I did not copy game data), so that part of the body is still your run only.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T11:58:08Z.
Independent integration check of
edc3edfb0onbf30e2585.emit/bitcode/opt.rsconflicted with the merged hoist and FxHash changes. I resolved it locally by preserving the hoist before each reuse round and using the main branch’s FxHash maps in the reused scratch state.After that resolution, 246 native Rust shader tests passed and 2 were ignored. On the base and the combined version, 400 synthetic optimizer inputs in forward and reverse order produced byte-identical output across all 800 translations. This checks compatibility of the conflict resolution. Timing was outside this run.
AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T18:25:47Z.
Merged
main(d359a2f85, no rebase/force-push) and resolved the conflict ind3d12/crates/leonida-shader/src/emit/bitcode/opt.rs:hoist_handles()before eachmerge()round and switchedMergeWalk's maps toFxHashMap<Key, V>.WALK'sRefCell::borrow_mut()strictly aroundself.merge(...)sohoist_handles/prune/guards/chainscannot hit a re-entrant borrow (addressing @KelboLive's nit).cargo test --locked -p leonida-shader --lib bitcode::opt(18 passed, 0 failed) andpython -I scripts/check_no_game_data.py(clean).AI-assisted: Gemini 4 Neon (including an independent read-only reviewer pass).
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T04:50:58Z.
VERIFY-2822 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), no GPU device, no game files
Verdict: PASS. A production-only allocation/performance refactor of the D3D12 shader optimiser's merge walk. It is
behaviour-preserving: the whole
leonida-shadersuite gives the identical result on the merge base and on the pullrequest (246 passed, 0 failed, 2 ignored on both), and it introduces no new test — so there is nothing red/green to
show, and none is claimed.
Head
d359a2f8, base the currentmain(8422def7), merge base27613ab6, 1 file, +82/−35:d3d12/crates/leonida-shader/src/emit/bitcode/opt.rs.1. What it changes
Module::merge(the single dominator-tree walk behind theFOLD/REUSE/FACTS/LOADSpasses) rebuilt its scratchstorage on every call. The pull request hoists that scratch into one
MergeWalkstruct held in athread_local!,cleared at the start of every round instead of reallocated, so a thread translating thousands of programs grows the
tables once:
mergetakes&mut MergeWalkand clears/resizes each table (repl.clear(); repl.resize(...),walk.known.clear(), …) rather thanvec![None; ...]/FxHashMap::default(). Three concrete wins inside it:path_has_writereuses oneseen: Vec<u32>with a monotonically bumpedstamp(reset only onu32wrap) insteadof allocating
vec![false; has_write.len()]and a freshVec::new()stack on every call.body[kept] = i; kept += 1; … body.truncate(kept)) instead of building asecond
Vec::with_capacity(body.len())per block.Key::Call(u32, Vec<V>)/Key::Gep(Ty, V, Vec<V>)becomeRc<[V]>, so a key holds its argument list by referencecount:
Key::Call(*f, args.as_slice().into()). Since a walk keeps every key twice (inknownand in the block'slist of what it added), cloning a key is now a refcount bump, not a copy of the list.
The borrow of
WALKis taken only around themergecall — the comment notes this is so the other passes(
hoist_handles,prune) cannot hit a re-entrant borrow. Everything inMergeWalkis written and read inside onemergeround; nothing carries over that a later round reads.2. The new test checks the property that matters
There is no new test.
scripts/red_green.pyclassifies every hunk of the diff as touching production code (noneis a whole test file or a
#[cfg(test)]-only hunk), so the red side is "not constructible: the pull request changes notest". That is the correct outcome for a pure refactor and I did not manufacture a test for it. The property that
matters here — same optimisation decisions, no behavioural drift — is what the full-suite comparison in §3 checks.
3. What the tests do here
python3 -I scripts/red_green.py 2822 --crate leonida-shader(own work-dir and target dir):ok, none failedred not constructible(exit 1 — expected, not a failure of the pull request)Because red is not constructible, red_green can only report the green side. I therefore ran the whole crate suite
myself on both the merge base and the head, on clean target dirs (see §4 for why clean matters):
cargo test -p leonida-shader27613ab6246 passed; 0 failed; 2 ignoredd359a2f8(pr2822)246 passed; 0 failed; 2 ignoredIdentical counts, and the same two tests ignored on both sides (
emit::bitcode::tests::bench_write, a benchmark runonly under
--ignored;emit::lower::tests::a_missing_value_stays_missing_through_two_live_joins, gated onLEONIDA_STRICT_JOINS). No regression, no flake.4. Any failure I saw, and why it is not this pull request
I hit no failure attributable to this pull request. Two things I want on the record:
source_hash_testscan fail spuriously when a target dir is shared across worktrees. While iterating I reusedone
CARGO_TARGET_DIRfor several checkouts.build.rsbakesLEONIDA_SHADER_SOURCE_HASHinto the test binary atcompile time, but the test recomputes the hash from the
src/on disk at run time, so a stale binary carries abaked hash that no longer matches the checked-out tree. This produced
the_source_hash_leaves_the_test_modules_out/every_test_module_is_built_for_tests_onlyFAIL onmain, on themerge base and on the pull request alike. Re-running each commit with its own clean target dir passes 246/246 on
both sides (§3). It is an artefact of my harness, not of the code under test — and it reproduces on plain
main,which is what rules out the pull request.
no test hunk; it is not a defect in the pull request.
5. What I did not check
cargo testonly. I did nottranslate any real shader corpus through it, nor run the translated shaders on any GPU.
docs/design.md's rule thata change be confirmed "by a GPU test, a Mesa/LLVM reference, or a count over the corpus" is not satisfied by
what I did: I ran no corpus count, so I cannot say whether the refactor leaves translated output bit-identical —
only that the crate's own unit tests pass unchanged.
cargo clippy/cargo fmtgate; I rancargo teston Linux only.it is structurally fewer allocations by reading the diff, but I did not benchmark it, so I make no claim about
how large the win is or that it is measurable on any workload.
optimise.MergeWalkis per-threadthread_local, which is sound,and the borrow is scoped to
mergeonly; but I reasoned about this from the code, I did not run it under amulti-threaded stress or a data-race detector.
Rc<[V]>change's effect on the wider crate.Keyispub(crate)-internal to the optimiser, and the fullsuite passes, but I did not audit every construction site of
Key::Call/Key::Gepoutsideopt.rsby hand.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:27:39Z.
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 Kal0s-design on 2026-12-02T14:13:25Z.
Ran natively on Windows 11, head
d359a2f85merged into currentmain(128648cfe, merges cleanly now,opt.rsauto-merged), Rust 1.98.1 fromrust-toolchain.toml,--locked. I looked at what earlier comments did not cover: stale state when the kept tables move between programs of very different sizes, a panic in the middle of a walk, and wall time.Suite and lint on the merge
cargo test -p leonida-shader --libcargo clippy -p leonida-shader --no-deps --all-targetsemit/valu_tests.rs(frommain), none inopt.rsKept tables against fresh tables (throwaway tests, not committed)
The reference for each program is the same program optimised on a newly spawned thread, so its
MergeWalkstarts empty. The program under test is optimised on one long-lived thread that has already run everything before it. I comparedModule::write()bytes.FOLD,REUSE,FACTS,LOADS,FOLD|REUSE,LOADS|FOLD,ALL, with a zero-blockModule::default()optimised every 5th program (80 in all)insts, soresolvepanics partway through the walk with the tables already filled (catch_unwind; a backtrace check confirmed every panic came from insideModule::merge). Each panic is followed on the same thread by a smaller valid programRefCellwas not left borrowed and the next program was byte-identical to the fresh thread, 138/138So nothing I could provoke leaks from one program into the next. That covers a larger program before a smaller one, a zero-block module (it returns before touching the walk), and a walk abandoned by a panic. The reason is in the code: every table is cleared or resized before it is read, and
seenonly ever holds stamps older than the next mark.Wall time (release, synthetic corpus)
Module::optimise(ALL)over the 400 programs above, timing only the optimise loop. 10 repetitions per run, 5 alternating runs per tree, so 50 samples each, on one thread:mainThere's no difference I can call real on this corpus: min is 7 % lower, median 2 % higher, and other jobs were building on the machine. That doesn't contradict the body's full-archive figure (−7 % wall, −20 % kernel), which comes from thousands of real programs where the saving is growth avoided between programs. It just means a small synthetic corpus doesn't show it, and I can't confirm the speedup from here.
Not checked: the full-archive translation and its DXIL hashes (no game data here), multi-threaded
optimise, retained memory per thread, and the in-game run asked for above.GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:01:16Z.
Triage of head
d359a2f85(merge base27613ab6b, 369 commits behind;git merge-treeagainst currentmain45dc41f95: no conflicts).1 file:
d3d12/crates/leonida-shader/src/emit/bitcode/opt.rs(+82/-35).CI green on the head (6 checks).
Existing verification: Verified on this head by @imShangLi (Linux: identical suite result with and without), @Kal0s-design (native, stale-state checks across programs of different sizes), earlier by @OreoFR, @fiestorra and @ecox982745 (identical bitcode on 400 random programs, fewer allocations).
This check: Not re-reviewed in depth: a behaviour-preserving allocation refactor (the merge walk keeps its tables between programs). Identical bitcode over random programs is the right evidence for it.
I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.
Verdict: ready (behaviour-preserving refactor with identical-output evidence).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:21:26Z.
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T18:03:49Z.
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #2822, #2800, #2664 and #2661 merged into main
09273248c; this PR tested at its current headd359a2f85. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s, screen kept on.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.