shader: a bound on the structurizer's if-then-else answers #4788
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4788
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4787"
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?
@Trillazill on GitHub · 2026-12-01 08:16 UTC · original
Trillazill:perf/structure-memo-cap→main· +42 −0 · 1 files · 1 commits · openNo issue for this; found in a diagnostics run's big-block log.
What it changes
Bools::iteinvictory-shader/src/structure.rskept every if-then-else answer it worked out, for the whole shader. Its nodes are capped (MAX_NODES), but that table of answers is not. In a diagnostics build, 16 of the first 24 blocks of 64 MB or more thatvictory translatemade over the game's shaders were this table (structure.rs:240), 68 MB each, one for each translating thread. In a game start with ray tracing on (VICTORY_BVH_BUILDER=1), it made 6 more while it ran, four of 68 MB and two of 136 MB.The table only saves work, so this bounds it: at
MAX_MEMO(2^20) answers it starts over. A forgotten answer is worked out again to the same node, because nodes are shared throughunique. That keeps the table under 36 MB.A new test,
a_full_answer_table_starts_over_and_answers_the_same, builds the same random functions in a table that keeps every answer and in one that keeps 8. Both make the same nodes in the same order.How it was tested
GPU and profile: RTX 4080, Windows 11, 24 threads. Offline, no game run needed:
victory translate --list(diagnostics build) over the game's folder, which translates every shader in it (25,693 emitted).Output: the emitted shader hashes and every outcome line are the same as main's, at each bound tried below.
Before (main
5fabb46e, 3 runs): 46.0–49.8 s; peak private memory 4,273–4,411 MB.After (2^20, 3 runs): 47.6–49.2 s; peak private 3,783–3,922 MB. The table no longer appears among the blocks of 64 MB or more.
Other bounds (one run each unless noted):
2^19 saves more, but it made the pass about a fifth slower. 2^20 costs about 2 s (4%) over the full set, for about 0.5 GB less at the peak.
Peak private memory is sampled every 100 ms. Part of it is the tool reading whole archives (blocks up to 1.2 GB from
translate.rs:309), the same in both builds.Wave sizes: every shader the game ships, as it has them.
cargo test -p victory-shaderpassed: yes (537 passed, 10 ignored).cargo clippy -p victory-shader --all-targets -- -D warnings, plain and--all-features: clean.cargo xtask policy --staged: ok.Not measured in a full play session. In game, this only changes memory while shaders are being translated (preload, or a shader seen for the first time).
Checked for overlap
structure.rs(#4481, #4171, #3501, #3402, #2993, #831). None changesBools::iteor its table.🤖 Generated with Claude Code
@cloph-dsp on GitHub · 2026-12-01 13:23 UTC · original
Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.
Base
5fabb46eaf6ed8771321787f8871051abde69b9b, head6253c5689d18110a01b3c6afff5b49e55175aba4. The name already exists on the base (git grep -F a_search_that_remembers_answers_as_one_made_anew 5fabb46e -- .matches structure.rs), so this extends an existing test rather than adding one — say so if the bar is a new test name.git diff --check "5fabb46e..6253c568"→ no output, exit 0.Result:
running 1 test,test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 546 filtered out; finished in 0.35s.The test builds its control flow by hand; no title files, no GPU device opened, GPU/driver N/A. No game data.
@illuminatedfellow on GitHub · 2026-12-01 14:45 UTC · original
Tested on Linux, merged onto
main(5fabb46e):cargo test -p victory-shaderpasses (333). To stress the start-over path I also setMAX_MEMOto 4, so the table restarts constantly: all 332 existing shader tests still pass (only the new test fails, as expected, since it assumes the real limit), and fuzzing the translator with that setting (320,000 random and mutated programs throughir::buildto lowering, debug assertions on) found no panics. Merges cleanly.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.