Formats: BCPack block histories without per-call allocation or zeroing #2034
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!2034
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2034"
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?
@StExpeditus on GitHub · 2026-11-25 03:49 UTC · original
StExpeditus:formats/bcpack-history-no-alloc→main· +109 −8 · 1 files · 2 commits · openPart of #703.
The per-call
vec![Default::default(); HISTORY]inplain/bc6/bc7cost one heap allocation plus a 10-30 KiB memset on everydecodecall. Ring entries are always written before they are read (block i writes sloti % HISTORY; a referencerof block i reads the slot blocki - rwrote, andr <= 255 < HISTORY), so the slots never need initialising.[MaybeUninit::uninit(); HISTORY]skips both the allocation and the zeroing; the oneunsafe(inpick) carries the invariant as its SAFETY comment.Measured with
bcpack_throughput's synthetic streams (cargo test --release -p victory-formats bcpack_throughput -- --ignored --nocapture, extended locally to small block counts):Small decodes are the mip-tail case that texture streaming does most, where the zeroing was proportionally heaviest.
cargo test -p victory-formats: 38 passed, 0 failed.The other per-call allocation (
recordsindecode, proportional to block count) and a fused streaming decode are left to follow-ups.@jeremygold02 on GitHub · 2026-11-25 03:55 UTC · original
Triage verdict — Keep the narrow history change, preserve a wraparound regression (
de45bec)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@StExpeditus on GitHub · 2026-11-25 09:05 UTC · original
Addressed the triage note: added
references_survive_the_dictionary_transition_and_the_history_wrap.assert_eq.cargo test -p victory-formats: 39 passed, 0 failed.@Marvisak on GitHub · 2026-11-25 09:18 UTC · original
Automated triage for the maintainers.
Merge candidate. In
crates/victory-formats/src/bcpack.rs, the per-callvec[..; HISTORY]history rings inplain,bc6andbc7become stack arrays ofMaybeUninit, andpickreads them with oneunsafeassume_init_ref. Recommending a look, not approving.What I checked:
referencesreturnsusize::from(u8), sor <= 255 < HISTORY(256). Slot(i - r) % HISTORYwas written by blocki - rand not overwritten since. Each block writes its slot only after bothpickcalls.Copy, so the array repeat is valid.references_survive_the_dictionary_transition_and_the_history_wrapcovers the dictionary-to-history transition and the ring wrap for BC4, BC6 and BC7.Notes for the maintainer:
unsafefor a micro-optimization. A safe stack array ([T::default(); HISTORY]) would also remove the allocation but keep the memset, if you prefer nounsafehere.CI: not run on this head (no check runs reported).
Generated by Claude Code
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.