GPU: coalesce nearby shadow-buffer refreshes without spanning huge heap gaps #1555
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!1555
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1555"
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?
@Texbirds on GitHub · 2026-11-24 19:07 UTC · original
Texbirds:perf/gpu-batch-coalesce-ranges→main· +171 −33 · 1 files · 1 commits · openProblem
In
crates/victory-gpu/src/host.rs,Batch::addcollapses all pending refreshes for aShadowbuffer into one[min(from), max(to))bounding range.When draws in a submission read small buffers at distant offsets inside a large shared GPU heap (e.g. a 174 MiB heap),
Batch::flushcallsshadow.updateover the entire span between them—scanning write-watch/guard pages and copying unrelated dirty or unwatched megabytes viaReadProcessMemorysynchronously beforeExecuteCommandLists.Fix
[from, to)intervals inBatchand sort/coalesce overlapping or nearby intervals withinCOALESCE_GAP(64 KiB, one guard block) before flushing, so adjacent buffers still coalesce into a single update while megabyte-wide gaps are never spanned.coalesce_ranges_merges_nearby_but_keeps_distant_ranges_separate.Verification
windows-latestCI (cargo clippydefault +--all-featuresandcargo test --workspace --locked).github-bot referenced this pull request2026-11-26 04:55:46 +00:00
@wwwwwwww3333333 on GitHub · 2026-11-24 21:51 UTC · original
On Windows,
cargo test -p victory-gpu --libdoesn't compile with this PR: head bfffb01 on mainffe310e(clean merge), Rust 1.98.1 MSVC.The new test
coalesce_ranges_merges_nearby_but_keeps_distant_ranges_separatesits inmod batch, which imports onlysuper::Batch.coalesce_rangesandCOALESCE_GAPare private items ofhost.rs(lines 1236 and 1240), so the module needs them too:use super::{Batch, COALESCE_GAP, coalesce_ranges};. This probably didn't show up off Windows because host.rs is Windows-only.Unit tests only, no game files. AI-assisted (Claude; I ran it on my machine).
@Texbirds on GitHub · 2026-11-24 21:54 UTC · original
Thanks for catching that — fixed in 51a046d by importing COALESCE_GAP and coalesce_ranges in mod batch.
@Marvisak on GitHub · 2026-11-25 03:30 UTC · original · edited 2026-11-25 18:42 UTC
Automated triage for the maintainers.
Needs work (measurement only). The PR changes
Batchincrates/victory-gpu/src/host.rs. It keeps a list of spans per host copy instead of one bounding range. Inflush,coalesce_rangesmerges spans less than 64 KiB (watch::PAGE) apart, so distant buffers in a large heap no longer pull the whole gap intoshadow.update.currentkeeps the disjoint spans that are up to date.addkeeps main'sshadow.clean()early return. The code reads correctly.coalesce_ranges_merges_nearby_but_keeps_distant_ranges_separateanddisjoint_ranges_skip_dirty_gap_pagescover the merge and the dirty pages in a gap. CI: passing (check).This is a performance change with a trade-off that needs data.
addnow scans every current span of a copy on each call, and pending spans grow untilflush. On a world submission that asks for about 9,000 copies, that could cost more than the gap copies it saves. Please post--features diagnosticsnumbers from the same retail scene onmainand on this branch: thepreparing: copies … ms … MBframe summary and thecopies per frameline. If they show a drop, this can go to the maintainer.On your reply: the build and log instructions for testers are clear. The verdict stays until such numbers are posted.
Generated by Claude Code
@Texbirds on GitHub · 2026-11-25 12:16 UTC · original
@DenRakEiw Thanks for testing and catching the
clippy::type_complexitywarnings — those are fixed inbf7bd1eusingPendingRefresh/CurrentRefresh, and CIcheckis now passing (along with theBatchdoc comment placement and thedisjoint_ranges_skip_dirty_gap_pagestest).Regarding the remaining triage point on real-submission numbers:
Step::Refresh(viaShadow::refresh) andStep::Heap(bindless::refresh) both submit sub-ranges intoBatch::addfor command lists that don't invokememory::prepare(Step::Memory). I don't have a retail capture setup locally to collect--features diagnostics(PREPARING/copystat) before/after numbers — if a tester with a retail build can comparebf7bd1evsmain(940d32f) with--features diagnosticsand share whetherPREPARINGbytes/time drop (or ifStep::Memorydominates in practice and makes this unnecessary), that would decide whether this is worth merging.@Texbirds on GitHub · 2026-11-25 16:31 UTC · original
Rebased onto
main(67e8ae1) in6d5f103. I keptmain's newshadow.clean()early return inBatch::add, nowlen == 0 || shadow.clean(), and dropped the texture parts thatmainremoved. The per-spanPendingRefresh/CurrentRefreshlogic and both tests are unchanged. The open triage point is the same: this still needs before/afterPREPARING/copystatnumbers from a real submission.@Texbirds on GitHub · 2026-11-25 17:13 UTC · original
For anyone able to run the diagnostics comparison, the current pair is
67e8ae1(main) and6d5f103(this PR). Build both with:Please run the same world scene with the same settings after warm-up and share a few matching log intervals with:
preparing: copies … ms … MBcopies per frameline, includingrefresh batchesandtitle memoryThose numbers will help show whether the time saved by skipping gap copies outweighs the cost of tracking spans. CI passed on
6d5f103. The retail comparison is still pending.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.