loader: reuse the file read buffer when preparing title images #4770
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!4770
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4769"
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?
@topangag on GitHub · 2026-12-01 06:47 UTC · original
topangag:pr/reuse-title-image-read-buffer→main· +33 −12 · 4 files · 1 commits · openWhat it changes
victory_loader::prepare(&[u8])cloned the full executable/DLL buffer (original.to_vec()) while callers inapps/victory/src/run.rsandcrates/victory-loader/src/windows.rsalready owned theVec<u8>returned bystd::fs::readand never neededoriginalagain.victory_loader::prepare_owned(Vec<u8>)sharing the implementation viaCow<'_, [u8]>, hashingoriginalbefore patching and mutating the owned buffer in place.apps/victory/src/run.rsandcrates/victory-loader/src/windows.rs(map_dll) toprepare_owned, and dropspreparedinmap_dllbefore recursing intomap_importsso nested title DLL buffers are not kept live across recursion.as_ptr()unchanged), identicaloriginal_hash, and identical patched bytes againstprepare.How it was tested
251.38 MiB, Peak Private Commit255.86 MiB, live private memory through prepare231.77 MiB,preparetime33.82 ms(reused=false).136.75 MiB(-114.63 MiB), Peak Private Commit140.99 MiB(-114.87 MiB), live private memory116.92 MiB(-114.85 MiB),preparetime18.66 ms(-15.16 ms,reused=true).cargo testpassed for the crates it touches: yes (cargo test --locked -p victory -p victory-loader -p xtaskpassed locally; full WindowsCIworkflow —Clippy,Clippy, diagnostics build, and workspaceTests— passed on the fork against a clean CI baseline applying existing unmergedmainfixes #4708 and #4143: https://github.com/topangag/VIctory-NVIDIA/actions/runs/46588428695).mainCI:maincurrently failsClippyon unrelated F1/F3 UI lints (addressed by #4708) and intermittently failsvictory-hle'sa_read_by_range_waits_only_for_a_remapping_that_meets_it(addressed by #4143); this PR intentionally leaves those untouched.Checked for overlap
@illuminatedfellow on GitHub · 2026-12-01 14:45 UTC · original
Tested on Linux, merged onto
main(5fabb46e):victory-loader's tests give the same results as onmain(the one failure is the Linux-onlytitle_patches_check_before_they_write, which #4932 addresses). Sinceowned_image_reuses_the_read_buffer_and_keeps_its_original_hashis Windows-only, I ran the same checks on Linux with the synthetic image fromtls_directory_at_the_top_of_the_rva_space_is_prepared:prepare_ownedreturns the same bytes andoriginal_hashasprepare, reuses the read buffer, and the hash is of the bytes before patching. 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.