GPU: reuse scratch for marked-page write-back #3604
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!3604
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3604"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 20:22 UTC · original
andrewpozdnakov7-jpg:codex2/marked-writeback-scratch→main· +14 −8 · 1 files · 1 commits · openKeep a temporary read buffer for the serial marked-page write-back loop. Grow it when the next clipped page interval needs more bytes. Each read uses a slice the size of its interval, and the existing read returns before the merge on failure. Windows read API
The existing assertions for GPU writes, later CPU writes and neighbouring bytes passed. The temporary allocation observer was removed. This measures buffer allocations for the copy-back path discussed in #3590.
The full diagnostics suite passed 246 project GPU tests plus the SDK identity check, with one ignored. Strict GPU Clippy passed with default and all features, and the asset policy check passed.
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 20:26 UTC · original
Windows CI passed on
63bd11f634f8e4170f17bf45288f41048397ea05. CI jobOn app-local Windows WARP the 31-full-page fixture made 31 scratch allocations on the parent and one on this commit. Both revisions passed the GPU-byte and CPU-neighbour assertions. The clipped 256- and 512-byte pages needed two allocations or growths on each revision and passed the cross-page shader readback. This measures allocations in the synthetic write-back path. The next step is maintainer review.
If you cherry-pick or rebase this commit, please retain its Git author. If you fold it into another commit, please include
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@upipibi on GitHub · 2026-11-27 22:54 UTC · original
Overlap, for whoever picks between them (read from the diffs, not run): three open PRs replace the same per-page
vec![0u8; n]inShadow::copy_back_markedwith a reused buffer.copy_back_marked, plus a test that a partial marked page after a whole one takes none of the first page's bytes (a_partial_marked_page_after_a_whole_one_takes_none_of_its_bytes). neonbyte1 measured it in game: copy-back 47.8 → 44.4 ms (comment).pooled(PAGE)buffer fromcopy_back_marks, and also batchestaken(the lost-write window KainanP reported there).Vecowned bycopy_back_marksand passed down, grown to the largest clipped interval.This PR and #3246 change the same lines of
copy_back_marked, so whichever goes in first, the other conflicts with it. #3341 (parallel copy-back with one scratch per worker) also replaces this allocation; neonbyte1 measured it 5-7 ms slower on copy-back (comment).AI-assisted (Claude Code, Claude Opus 5.5 read the four diffs).
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 23:07 UTC · original
Thanks for checking the overlap. #3246 covers the same allocation and was opened first. It already has a regression for a partial page following a full one and a reported copy-back improvement from 47.8 ms to 44.4 ms on the same RTX 5090 test setup. Independent measurement
These are competing changes to the same loop. #3246 is the tested choice for maintainers to review first. The scratch in #3604 belongs to the submission, which is relevant if the maintainers prefer that lifetime.
AI-assisted with OpenAI Codex.
@Desamodeth on GitHub · 2026-11-27 23:10 UTC · original
I ran the serial marked-page write-back on
main(63bcca43), #3604 (63bd11f6) and #3246 (c2e4507c) at a fixed 256 × 64 KiB per sample. Batching explains where the two scratch lifetimes differ. Median total milliseconds for the same 16 MiB, with half the pages changed on the shader side and a neighbouring CPU byte changed on one in sixteen:With one page per call, #3246 beat main in all 12 paired blocks (median 9.9% less time). #3604 had no consistent gain there. With 256 pages per call, both saved about 10% against main and the difference between them changed sign across blocks. When every marked page contained identical bytes, single-page calls showed the same split (1.096 / 1.099 / 0.997 ms).
Windows, Ryzen 7 9800X3D, software WARP, Rust 1.98.1,
diag. Six build orders run twice, eight measured iterations after two warm-ups. Timed onlycopy_back_marks; checked all bytes in title and shadow memory and all consumed mark bits after every iteration. A pages-per-call histogram from a title trace would show which rows matter most in practice. Reproducible test · frame profile. AI-assisted with Codex Astra 6.2 High.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.