Loader/Prepare: zero-alloc block-filtered DIR64 relocation clearing for TLS callbacks #2982
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!2982
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2982"
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/prepare-reloc-fast→main· +190 −25 · 1 files · 1 commits · openprepare()previously calleddir64_relocations(), which decoded everyIMAGE_REL_BASED_DIR64entry across the entire PE.reloctable into aVec<(usize, u32)>(hundreds of thousands to ~1M entries on a retail title executable) solely to clear the single entry targeting the TLSAddressOfCallBacksfield.Replace it with
clear_dir64_relocations(bytes, info, target_rva):.relocblock whose[page, page + 0xFFF]window does not containtarget_rvain O(1) without decoding its entries or allocating memory.u16comparison ((DIR64 << 12) | wanted_off).Measured (
--release bench_clear_dir64_relocations, median of 3 runs, 3,000 blocks × 250 entries × 50 iters)600.24 ms → 0.6024 ms(996×, -99.90%), zero heap allocations.Verification
--tests+--features diagnosticsclippy,xtask policy, full workspace tests): RVZO6/VIctory CI run #45738573777 (green, combined Wave 8 check on63bcca4).clear_dir64_relocations_matches_full_scan_and_preserves_neighborscomparing bit-for-bit against the full-table scan across first/middle/last/absent blocks and non-DIR64entries; existingpatches_own_test_binarycontinues to verify with the full-table scan.AI-assisted: T3 Code (Antigravity, gemini-4-neon).
46ebcb1f99toff0bf23591@pickles976 on GitHub · 2026-11-26 02:44 UTC · original
Independent Windows-target Wine check on a 16 GiB Linux host, exact head
46ebcb1f: relocation parity fixture 1/1 pass andpatches_own_test_binary1/1 pass. The ignored retail-sized synthetic benchmark (3,000 blocks × 250 entries × 50 iterations; debug build) printed old=1256.36 ms, new=19.2844 ms (65.1×). This did not instrument allocations or measure the late-title RAM peak; it does not yet establish that our guarded loading stop at 2,036 MiB available (2,048 MiB floor) is cleared. Logs.compat-runtime/logs/verify-pr2982-wine-{reloc-parity,patch-own-pe,reloc-bench}.log.@futurepro62 on GitHub · 2026-11-26 05:12 UTC · original
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
46ebcb1(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: 867 passed, 0 failed, 11 ignored.clear_dir64_relocations_matches_full_scan_and_preserves_neighbors.--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:23 UTC · original · edited 2026-11-26 07:19 UTC
Automated triage for the maintainers.
Needs work. Thanks for
ff0bf23. The benchmark is gone and there are edge cases foru32::MAXtargets and a corrupt block size.clear_dir64_relocations(crates/victory-loader/src/prepare.rs) still reads as equivalent to the old scan.The question from last time is still open. This step runs once per launch and costs about 12 ms, and no run shows an effect on startup time or peak memory. Without that, the PR replaces a simple scan with a more involved one and adds about 150 lines of test scaffolding: a hand-built PE and a reference scan. Note that this reference is not the removed code; it already includes the new checked arithmetic. The
corruptcase also has no assertion. If a startup-time or memory gain can't be shown, a much smaller PR with only thechecked_addon the TLS field RVA would be the part worth keeping.CI: passing (
check).Generated by Claude Code
@RVZO6 on GitHub · 2026-11-26 06:56 UTC · original
Addressed triage feedback in
ff0bf23:#[ignore]bench_clear_dir64_relocationsmicrobenchmark from unit tests.target = u32::MAXand corruptblock_size = u32::MAX) toclear_dir64_relocations_matches_full_scan_and_preserves_neighbors.victory-loader, both clippy profiles, andxtask policy. Not run: the title; any hardware GPU.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.