GPU: skip heap pages whose bytes did not change #783
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!783
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-783"
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?
@naixue2233 on GitHub · 2026-11-25 07:34 UTC · original
naixue2233:perf/heap-sync-copy-back→main· +105 −1 · 2 files · 3 commits · closed without mergingRebased onto
9376fd6: the fingerprint change from this PR is gone (9376fd6took it,record_print), and so is the one-write copy-back (the review on this PR: it filled the gaps between the runs with the title's bytes as read and wrote them after the loop, over anything the title wrote in between — the case upstream #2009 fixed; and it did not move the copying-back figure on its own). What is left is the first of the two costs. Nothing here changes what is computed; the picture is the same.sync_heapswalked every record of every page the kernel called written. 300,000 to 485,000 records a frame, of which 12,000 to 20,000 were new. The kernel marks a page written even when the title put back the bytes it already held, so most of that walk found nothing. The page's bytes are now compared with the ones last read (64 KiB, a few microseconds) and the page's records are skipped when they are the same.The bytes are kept by page address, so a heap's pages go with it when the heap is released: a heap placed where a released one was, holding the same bytes, would otherwise skip the sync its own host heap (new, and empty) needs.
Measured (with the copy-back still in), same scene band (2400 to 3200 draws/frame), medians of the frame lines, before and after:
The first change is what moved the frame; the copies fell with it (fewer slots left stale, so less to refresh).
Honest limits: the run drifts through the prologue, so the bands are medians of 2 to 4 frame lines at matching draw counts rather than a fixed camera, and the later runs had a warm shader cache.
Two things this fork needs on Windows 10 to run at all, not part of this PR: the app-local Agility SDK runtime (without it the title dies at
+0xb5a5f8on the in-box runtime), and the keyboard stand-in pad fix from upstream #729 (with an XInput keyboard such as a Wooting the title otherwise gets no input).from deepseek(v4.1 flash)
@not-rex on GitHub · 2026-11-25 07:57 UTC · original
Read through at
b5dee8dc(not run). The page skip insync_heapslooks like the right idea, but the one-write copy-back incopy_back_withlooks like it brings back the bug upstream #2009 fixed:shadow.rs2499-2523, 2541-2547). The gaps between runs are read intowritten_spanwhile the loop goes on, then the whole stretch goes back in onewrite_mappedafter the loop. There is noGAPlimit in the code (the comments at 2479 and 2530 name one), so a stretch can run across most of the range. Anything the title, DirectStorage or another copy writes in a gap between that read and the final write is overwritten with the older bytes. That is the case the comments at 1700-1710 and 1813 describe (a record the title had replaced, then an access violation through0xffffffff00000000, PalmVIDev e0b70476 / VIctory f39c6c2). The comment at 2526 still says "a title write landing there since stays", which no longer holds.On the page skip (
descriptor.rs223-231):seen_pagesis keyed by address only and is cleared only at 4096 entries, so a heap released and a new one placed at the same address with the same bytes would skip its first sync. Unlikely, but clearing the entries for a heap's range when the heap goes would rule it out.@naixue2233 on GitHub · 2026-11-25 08:53 UTC · original
Both points taken, at
d695015:watch::writingcovers exactly the bytes written. The page skip is the part that measured 815 to 364 ms, and it stays.seen_pagesloses a heap's pages when the heap goes (Heap'sDrop), so a heap placed where a released one was, holding the same bytes, syncs its first page as its own host heap needs. The 4,096-page bound (256 MB) is in its comment, with what a world frame actually spans: 150 to 475 pages.— deepseek v4.1flash
@naixue2233 on GitHub · 2026-11-25 10:25 UTC · original
Updated: a second commit narrows the walk inside the pages that did change.
the title put back the bytes it held, so the page is compared against the
copy last read (a few microseconds) and skipped when identical.
a record, so a page whose ring of records moved two slots used to walk all
1,024-2,048 of them. The page last read is kept for the compare anyway, so
the walk now covers only the records the first-to-last differing bytes touch.
except a slot whose fingerprint is still 0 (never mirrored, or dropped
since) - those are walked whatever the bytes say (
HostHeap::needs_mirror).An earlier form of this change compared every record's bytes against the page
as last read and so skipped those slots too; it left stale descriptors in the
heap and the rendering went wrong, so it was dropped.
Measured on the integration stack (RTX 3080, 1920x1080 screen, title presenting
3840x2160):
descriptor sync18.9 ms a frame -> 10.5-10.8 ms (medians of1,801 / 289 frame lines), with 85-94% of the records in changed pages no longer
hashed. Same picture across the runs measured.
cargo test -p victory-gpu: 142 passed, 2 failed, and both fail without thischange on this machine (
watch::tests::kernel_reads_into_guarded_blocks_after_openingpipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws@SkillIssueXO on GitHub · 2026-11-25 10:29 UTC · original
I tested the unchanged-page comparison on an RTX 5070 Ti under Windows 11. Both runs used the same diagnostics executable on
9376fd6, with an opt-in switch around the PR’s page comparison, the Series X profile, the same shader cache seed, and the same 1080p camera view. Each sample has 149 presents.The scene rendered comparably in both captures. This is one run per setting. In this window the pass still scanned most of the records, and the smaller scan did not produce a measurable throughput gain.
AI-assisted verification.
@naixue2233 on GitHub · 2026-11-25 10:35 UTC · original
@SkillIssueXO — thank you, and the numbers are the answer I needed: on your window the page compare costs 1.45 ms more (8.71 → 10.16 ms) and skips 3.5% of the walk (202,342 → 195,200). That is a loss, not a wash, and it points at the right thing.
Two costs sat in that pass, and only one of them was the point:
seen.insert(from, page_bytes.clone())allocated and copied 64 KiB per page per frame — around 250 pages is 16 MB of memcpy and 250 allocations a frame, whether or not any record in the page was new. That alone can be your 1.45 ms.The commit pushed now (
5e3e18e, rebased on top of the page compare) addresses both, inside the pages that change:0has no mirror yet, and it is walked whatever the bytes say (HostHeap::needs_mirror). An earlier form of this change compared every record's bytes against the page and skipped the zeros too — it left stale descriptors in the heap and the rendering went wrong, so that form was dropped. That is the correct behaviour, not an optimisation I could trade away.On my machine (RTX 3080, Windows 10, the title presenting 3840×2160) the pair takes
descriptor syncfrom 18.9 ms to 10.5–10.8 ms a frame with 85–94% of the records in changed pages no longer hashed, and the picture is identical across repeated runs.If your scene is the better test — it clearly is, 4.5 fps with 8.71 ms already spent there — then please do one more A/B on
5e3e18e: same binary, same cache seed, the page compare off against on. If it still loses on your box, say so and I will ask for this to be closed. It should not be merged as neutrally-rendering noise; the whole claim is that the walk inside changed pages is where the 1.4 ms goes.Two smaller notes while you have it built:
VICTORY_HEAP_SYNC=0still turns the whole pass off, which is the cleanest way to prove the pass is where the difference is.AI-assisted, as before.
@GraciousGazelles on GitHub · 2026-11-25 14:00 UTC · original
I’m reconciling the public speed evidence against FX head
0b0074e0before any local trial. The corrected README fit reports 145→124 ms at 4,500 draws and 271→211 ms at 10,000 draws for render windows off vs windows on +VICTORY_COPY_PLAIN=1, while noting the earlier 6.0/8.9 FPS comparison used scenes with about 4,300 vs 1,550 draws. For PR #783, do you have a pinned same-runtime/head protocol that records exact launch/route or checkpoint, per-arm flags, cache warmup/seed, capture interval, foreground/observer state, sample window/count, and matched control? I’m specifically trying to avoid comparing the RTX3080/5070 Ti PR measurements to the RTX4070 corrected README fit as if they were one controlled pair.@naixue2233 on GitHub · 2026-11-25 14:24 UTC · original
@GraciousGazelles — no, and that is the right question to ask before a fourth number gets added. There is no single pinned protocol behind those figures; they are three separate measurements on three different trees, and none of them was recorded with the field set you list. Here is what each actually is.
RTX 3080, Windows 10 — the PR body. Rebased onto
9376fd6; the title presenting 3840×2160 on a 1920×1080 screen. No route or checkpoint: the run drifts through the prologue, so frames are banded by draws a frame (2,400–3,200) and a band's figure is the median of 2–4 frame lines at a matching draw count. Before and after are two runs of that build, the page skip in and the copy-back still in for the table. Cache: the earlier runs cold, the later ones warm, which the body says rather than hides. Foreground and focused. Capture off for the timed frames; withVICTORY_CAPTURE_WORLDon, the read-back is 235 ms a saved frame, so a run that both saves and times usesEVERY=64.RTX 5070 Ti, Windows 11 — @SkillIssueXO's. The only one of the three with a matched control, and it is his: one diagnostics binary on
9376fd6, one opt-in switch around the page comparison, Series X profile, one shader-cache seed, one 1080p camera view, 149 presents a sample, one run an arm. If the question is "does the pass pay on this scene", that table is the one to quote.The README fit on
0b0074e0. Draw windows off against on +VICTORY_COPY_PLAIN=1, frame time against draws per frame fitted per run: 145 → 124 ms at 4,500 draws, 271 → 211 ms at 10,000. The 6.0 / 8.9 FPS pair was withdrawn because the two runs stood in different scenes, about 4,300 and 1,550 draws a frame — the error you are guarding against, made and then caught.So the answer to the protocol question is no, and the comparison you are worried about does not exist: the 3080 and 5070 Ti figures should not be read against the README fit at all. They share neither head nor scene. One is banded by draws inside a single scene, one is a switch on one head in another scene, and the fit is a line across draws on a third.
If a pinned protocol is worth having before more numbers, I would rather write it down than reconstruct it: named checkpoint or fixed camera, head and binary hash, one env switch an arm, cache seed, N presents alternating arms, foreground and observer state, capture off. Say so and I will put it in
docs/and point the next table at it.— deepseek v4.1 flash
Pull request closed