HLE/DirectStorage: reuse per-worker DecompressorOxide and source/intermediate scratch buffers #2981
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!2981
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2981"
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?
@RVZO6 on GitHub · 2026-11-26 02:09 UTC · original
RVZO6:rvzo/dstorage-worker-scratch→main· +221 −22 · 1 files · 1 commits · openEach worker thread in
dstorage::work()processes requests sequentially, but previously constructed a fresh ~10.5 KiBminiz_oxide::inflate::core::DecompressorOxideand heap-allocated + zero-filled newVec<u8>buffers for file sources and zlib+BCPack intermediate buffers on every request.Keep a worker-local
WorkerScratchinwork()holding:DecompressorOxidereset viainit()before each zlib stream (matchingdecompress_slice_iter_to_slice(..., true, false)flags and status mapping bit-for-bit without re-zeroing Huffman tables).sourceandintermediateVec<u8>buffers, trimmed back after any outlier request exceeding 8 MiB (SCRATCH_RETAIN_CAP) so idle worker RSS stays bounded.Leaves
open_file,FACTORY_VTABLE,scheduler,read_into, andinto_destinationuntouched (zero overlap with #2904 and #2883; zero new dependencies).Measured (
--release bench_dstorage_worker_scratch, median of 3 runs)48.03 ms → 27.61 ms(1.74×, -42.5%)30.21 ms → 28.79 ms(1.05×, -4.7%)48.24 ms → 44.41 ms(1.09×, -7.9%)Verification
--tests+--features diagnosticsclippy,xtask policy, full workspace tests): RVZO6/VIctory CI run #45738573777 (green, combined Wave 8 check on63bcca4).reused_decompressor_matches_fresh_on_valid_and_error_streams(exact parity vsdecompress_slice_iter_to_sliceacross valid, short-output, empty, bad-header, bad-Adler32, truncated, output-too-small, and post-error recovery cases) andworker_scratch_reuses_capacity_and_trims_outliers.AI-assisted: T3 Code (Antigravity, gemini-4-neon).
@pickles976 on GitHub · 2026-11-26 03:26 UTC · original
16 GiB Linux/Wine laptop verification, exact PR head
fbfe80ed28using the Windows target under Wine 11.0: four focused DirectStorage tests passed 1/1 each — decompressor fresh-vs-reused success/error parity, scratch reuse and release above 8 MiB, queued file raw+zlib reads, and zlib+BCPack combined requests. Local logs:.compat-runtime/logs/verify-pr2981-wine-{decompressor-parity,scratch-trim,queued-file-zlib,zlib-bcpack}.log(not attached). No GPU host device, title run, process RSS or global available RAM was measured; these fixtures prove bounded scratch lifecycle and correctness, not relief from our VIctory world-load guard stop below 2 GiB free system RAM.This is a useful component of the larger host-RAM work, but the opt-in application-wide admission/reclaim budget is tracked separately in #3012. Please keep its RAM benefit claims scoped to measured scratch and add a guarded matched title/RAM sample before describing the world-load impact on a 16 GiB machine.
@futurepro62 on GitHub · 2026-11-26 05:16 UTC · original
NVIDIA full-suite run, to go with the reports above by pickles976, since none of them names a GPU run. Tested exact head
fbfe80e(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 11 ignored.reused_decompressor_matches_fresh_on_valid_and_error_streams,worker_scratch_reuses_capacity_and_trims_outliers.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@Marvisak on GitHub · 2026-11-26 05:48 UTC · original
Automated triage for the maintainers.
Merge candidate. Each
dstorage::workthread now keeps oneWorkerScratch: a boxedDecompressorOxide, reset withinit()per stream, plus reusable source and intermediate buffers, trimmed back above 8 MiB. This saves the per-request allocations and zeroing.What I checked:
inflatecallsdecompresswithPARSE_ZLIB_HEADER | USING_NON_WRAPPING_OUTPUT_BUFand noHAS_MORE_INPUT. That is whatdecompress_slice_iter_to_slice(.., true, false)does for a single final slice, and a stream that runs out of input is still an error.reused_decompressor_matches_fresh_on_valid_and_error_streamschecks this against the old call, including recovery after errors.read_intofills allsizebytes or fails (END_OF_FILE), and onlyintermediate[..n](the inflated length) reaches BCPack, as with the oldtruncate(n).Minor and optional: the
#[ignore]benchmarkbench_dstorage_worker_scratchcould be left out of the tests. The figures in the description are enough.CI: passing. A tester also ran the full suite on an RTX 5070 Ti with no new failures.
Recommending a look, not approving.
Generated by Claude Code
@kotekompotek on GitHub · 2026-11-26 02:28 UTC · original · reviewed
Verified: per-worker scratch is sound since each worker runs one request at a time. init() yields fresh decompressor state before each stream (tables included), flags match the old decompress_slice_iter_to_slice semantics (zlib header + non-wrapping output), and non-Done statuses still map to INVALID_DATA. The 8 MiB retain cap prevents one oversized request from pinning worker memory, and buffer reuse keeps the source/intermediate borrows disjoint.
@fuzeofficlal on GitHub · 2026-11-26 02:41 UTC · original · reviewed
Reviewed
fbfe80edagainstmain(63bcca43) — worker-local scratch andDecompressorOxidereuse looks sound:dstorage.rs:450-469),init()cleanly resetsminiz_oxide's state machine (preserving zlib header checks, Adler-32 validation, and error mapping), and the new test covers reuse after malformed, truncated, and output-limited inputs.8 MiBper retained buffer (16 MiBper worker), idle workers can retain up to16 MiB × worker_count(e.g.,~1 GiBat 64 workers), and scheduler staging accounting (514-530, 657-667) covers buffered file input without the zlib-to-BCPack intermediate buffer.dstorage.rs:461-465(worker loop callingexecute/count/finish), straightforward to combine by trimming scratch before reacquiring the lock and dropping #2987'sQueuedRequestbefore publishing completion.@Dukestar69 on GitHub · 2026-11-26 06:58 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-hle dstorage: all tests passed.cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Desamodeth on GitHub · 2026-11-26 18:35 UTC · original · reviewed
fbfe80edhas a repeatable allocation cliff on the file-source path. Alternate 5 MiB and 6 MiB requests on one worker:Vec::resizegrows the 5 MiB buffer to 10 MiB, thentrim()drops it. Both requests are below the 8 MiB cap. The intermediate buffer uses the same growth policy.Windows x64, Ryzen 7 9800X3D, Rust 1.98.1 release. I used the extracted
read_source/read_intofunctions on the same warm local file. Medians of 12 interleaved batches of 32 reads:63bcca43On the 5/6 trace, growth events fell from 32 to 2 and peak source
Veccapacity from 10 to 8 MiB. The revised worker retains 8 MiB at the end of that trace; the current PR retains zero. A second run in reversed order gave 29.60 → 11.48 ms. The above-cap control still released the buffer. Matched file bytes checked separately. These are file-read and scratch measurements only; no decompression, GPU, title run or process RSS measurement.Tested change for both resize sites
Call
grow_scratch(scratch, size)inread_sourceandgrow_scratch(intermediate, inter_size)inexecute, keepingtrim()as written. Regression case: grow both buffers to 5 MiB, then 6 MiB, then 8 MiB, trimming and checking both still hold the requested length after each step. Grow one to 8 MiB + 1 and check trimming releases only that buffer. Isolated checks passed; I did not run the workspace suite.AI-assisted with Codex.
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.