Stream shader archive scans in bounded batches #1185
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!1185
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1185/head"
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?
@Jitheswar on GitHub · 2026-11-24 16:22 UTC · original
shader-archive-streaming→main· +833 −253 · 5 files · 3 commits · closed without mergingvictory shader-infoandvictory translateread each input file whole and built a file-wide index before looking at any shader. On the title's shader archive that holds the whole file in memory, several hundred MB of RSS, for an offline scan.What changes
apps/victory/src/shader/source.rsscans a file in 1 MiB chunks for the container and record markers. It reads three bytes of lookahead so a marker straddling a chunk edge is found once, by the chunk that owns its start. It hands the caller batches of at most 16 MiB or 1,024 sources.sgd5::read_indexreads a shader database's index by seeking past the compressed shaders instead of loading them. Indexed records keep their order, names and engine hashes. A database with malformed effects is rejected, as the slice parser does, and the scan then falls back to markers.shader-infoandtranslateuse it.--disasmoutput is unchanged.Tests (synthetic): markers found once across chunk boundaries; indexed records preferred, with their engine hashes kept; an oversized source visited before the next candidate is read (an I/O failure is injected at the next header); large source sets visited in bounded batches.
Checked with the game's files (Grand Theft Auto VI, Xbox Series 1.0.2.1, my own dump; offline scan only, no game data in the PR):
shader-infoon the shader archive gives the identical summary on940d32fand on this branch, 26,503 containers and 26,698 decoded programs. Peak RSS for that scan fell from about 417 MiB to about 41 MiB (measured on the earlier base).Rebased onto
940d32f; upstream's new--disasmstage-I/O lines are kept. Thevictoryapp tests pass for the Windows target under Proton (14, including the four above). Windows-target clippy-D warningsis clean.AI-assisted (Claude Code, Codex).
🤖 Generated with Claude Code
@Zipettte on GitHub · 2026-11-24 18:00 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at c12892c:
cargo test -p victory -p victory-game -p victory-shaderpasses, 125 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Jitheswar on GitHub · 2026-11-24 20:55 UTC · original
Follow-up
f56f478flushes a full batch before the scanner reads another candidate. This keeps an oversized singleton from being retained during the next candidate read. The synthetic regression injects an I/O failure at that next header and checks that the completed batch has already been visited.I compared
shader-infoon the retail GTA VI Xbox Series 1.0.2.1 shader archive, using the same #1017 Linux build fixes for both builds. Both found 26,503 containers and decoded 26,698 programs. Peak process RSS was 426,856 KiB for the baseline and 41,512 KiB for the streaming branch. This was an offline scan.Linux workspace tests passed with #1017 applied locally, and the scanner regression passed in the Windows-target test executable under Proton. AI-assisted with Codex. No game data is included.
@Jitheswar on GitHub · 2026-11-24 21:57 UTC · original
Rebased onto
70564ae. Streaming now honors upstream’s SGD5 tables when present, preserving record order, names and engine hashes, with marker fallback when no table parses. The standard shader survey, translation, and cache warm-up scan shader payloads in batches. The dedicated effect and pipeline-pack readers keep their existing parsing paths.The Windows-target workspace suite under Proton added four passing synthetic scanner tests and reproduced the same 66 failures as the untouched base. The asset-policy check passed. The offline
shader-infooutput for the retail GTA VI Xbox Series 1.0.2.1 shader archive matched upstream exactly, including 26,503 containers and 26,698 decoded programs. No game files or extracted assets are included. AI-assisted with Codex.@Marvisak on GitHub · 2026-11-25 00:39 UTC · original · edited 2026-11-25 02:24 UTC
Automated triage for the maintainers.
Recommended for a maintainer's look.
shader-info,translateand the cache warm-up now read shader archives throughapps/victory/src/shader/source.rs, a 1 MiB chunked marker scan that hands out bounded batches. They used to read each whole file.sgd5::read_indexreads a database's index by seeking past the packed shaders, and keeps record order, names and engine hashes. The reported peak RSS drops from about 417 MiB to 41 MiB, andshader-infogives identical totals on the title's archive. It is offline tooling only. The tests cover markers across chunk edges, a preferred index, and batch bounds. Two points for the reviewer:IndexCursor::skip_effectduplicates the layouteffect()parses, so the two have to stay in sync.translateand the warm-up no longer skip files overMAX_FILE(2 GiB), whileshader-info's directory walk still does. Please confirm that difference is intended.It overlaps
translate.rswith #1017 and #1183. CI is passing.Generated by Claude Code
@Calvix2k on GitHub · 2026-11-25 02:54 UTC · original
Independent run on Windows 10 19045, your head
6dbfe79:cargo test -p victory --bins --locked: 14 passed, 0 failed, includingshader::source::tests::prefers_indexed_records_and_preserves_their_engine_hashes.cargo test -p victory-game --lib: 15 passed, 0 failed.(
cargo test -p victory-shader --libfails 75 here, but that is this host having no SM 6.6 device — the same on unmodifiedmain, tracked in #1829/#1991 — not your change.victory-shader's owndxbctests are inside that 172 that pass.)The chunked scan reads correct in the diff: the 3-byte lookahead means a marker straddling a 1 MiB edge is found by the chunk owning its start, each batch releases before the next source is read, and the 2 GiB per-source cap is unchanged. I have not run it against a real shader archive (I only have the title dump, and
victory translateover it takes longer than a review pass); if you want that measurement, say so and I will run it here with--listand report RSS and wall time against your branch andmain.@Calvix2k on GitHub · 2026-11-25 03:16 UTC · original
Measured here, as offered — this is the real archive, not a synthetic file.
main940d32f6dbfe79Setup: Windows 10 19045, Ryzen 7 5800X,
shaders.rpffrom the 1.0.2.1 dump (411,695,600 bytes), release builds of each commit into the same target dir,victory translate E:\…\shaders.rpf --list --jobs 10, peak working set sampled every 200 ms from the process.Correctness of the scan is unchanged: the two listings have the same 25,908 lines, and the refusal summary has the same counts (195 SGPR addresses, 40 lane-mask joins, 36 descriptors read as data, 8 lane masks read as data, …); only the example program quoted for each kind differs, because the chunked scan reaches them in a different order.
Caveat: one run each, no
--validate(the validator would dominate wall time and is orthogonal), and the host was otherwise idle. The 20% wall-time gain is larger than I expected for an I/O-bound scan — if it holds on a second run it is worth mentioning in the body, since the issue is framed as memory only.Pull request closed