Page marks: shaders mark the pages they write, the compare hashes only those (opt-in; RTX 3080 18.3 → 20.0 fps) #3499
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3499
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3499"
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?
@remijn on GitHub · 2026-11-30 00:03 UTC · original
remijn:page-marks→main· +1025 −26 · 24 files · 2 commits · closed without mergingSummary
Opt-in page marks. With
VICTORY_MARK_WRITES=1, the translator adds to each buffer store or atomic whose view has a known title address a store that marks its 64 KiB page, in a table bound asu249(SLOT_WRITTEN). A program counts as "marks all it writes" only if every one of its stores is marked. The compare then reads the marks:VICTORY_WRITTEN_COMPARE=check: hashes everything as before, and counts pieces found changed whose page no shader marked (misses). This is the safety test.VICTORY_WRITTEN_COMPARE=skip: leaves unhashed the pieces of pages that only marking programs declared written.The compare gets 7 root constants (
main's 6 plus the page of piece 0), a 16-byte counters buffer (u2) and the pages table (u3). While the marks are on, plans are compared in single passes, because the batched compare doesn't read the marks. Independent of the relay and ofVICTORY_LAND_CAPTURE.Also included:
UnmarkedIndex). Lists are reused, so before this each one kept the unmarked ranges of every frame it had recorded: preparing took 311 ms a frame instead of 41, and stale ranges kept most pages out of the marks.VICTORY_DECLARED_BY(diagnostics): which shaders' declared writes the compare hashes, and how much of it changed.Defaults: unchanged. Everything is off unless set.
Measured
RTX 3080, Series S profile, no DLSS or frame generation,
play-foxhound.ps1's settings, diagnostics build, the same save, 40 s after a 20 s warm-up, one run each:skipcheck: 0.00 misses a frame throughout, with about 7,200 of 8,060 pieces a frame in marked-only pages.skip: about 7,000 pieces a frame left unhashed, still 0.00 misses.These runs used a build that also contained
VICTORY_LAND_CAPTURE(off). In this PR the marks have their own counters buffer instead of sharing capture's slots, so their results should be the same, but the split build hasn't been re-measured.Why opt-in
-Preloadonce first: without it, the title builds thousands of pipelines while it plays, which ran a 32 GB PC out of memory.Tested
cargo checkwith and withoutdiagnostics. 46 compare and marks tests pass, including the marking translator test (its DXIL validates),warp_card_compare_follows_the_pages_shaders_markandunmarked_index_finds_the_overlapping_ranges_of_the_copy. The hardware compare tests pass on the RTX 3080.Please test: preload once, then play a while with
VICTORY_MARK_WRITES=1 VICTORY_WRITTEN_COMPARE=checkand report the log linethe compare and the pages shaders mark ... (misses).Replaces part of #3446.
🤖 Generated with Claude Code
@DoubleD17 on GitHub · 2026-11-30 04:52 UTC · original · edited 2026-11-30 09:56 UTC
We ran a test of this PR on current main (
41adb551with this PR merged) withVICTORY_MARK_WRITES=1 VICTORY_WRITTEN_COMPARE=skip, after a preload withVICTORY_MARK_WRITES=1. The runs compiled nothing extra: about 30 shaders each, the same as main.The marks work here too. Each frame has about 9,440 pieces in spans that only marking shaders declared and about 790 hashed whole, and about 9,300 are left unhashed. Misses were 0.00 in all 366 lines of both runs.
But on this machine it is slower:
Both rounds agree, and the gap is much bigger than the spread of main's own runs in that session (1.6 ms).
Where it goes, from the 5 s lines (medians over each run):
This machine is limited by the submitting thread (about 64 ms of CPU preparation, against 40 in your runs), not by the card. So the card time the marks save does not show here, and the extra work on the submitting thread does. Our guess is the single-pass compare while the marks are on, but we have not profiled it.
Memory: about 1 GB more private memory (33.2 and 32.8 GB, against 31.9 and 32.1).
Picture: 0 defects in 160 frames with the marks on.
We ran
skip, not thecheckyou asked for. We will add acheckrun and post its line here.Setup:
41adb551with this PR and the two switches, against41adb551alone;AI Assisted
@remijn on GitHub · 2026-11-30 05:08 UTC · original
Thanks for the careful test: alternating runs, the same save, and the check that nothing extra compiled make this easy to trust. Your result is right, and it points at a flaw in how I measured this PR.
Why our numbers differed. Every marks run I did also had
VICTORY_LAND_CAPTURE=1on. Capture already forces the compare into single passes, so my baseline had already lost the batched compare, and the marks only showed their saving (less hashing). On plainmain, as in your test, the baseline uses the batched compare. Turning the marks on switches every plan to single passes, cut into runs of marked and unmarked pieces, with the planning that goes with that. That's the cost you measured.I've since measured that planning directly on an RTX 3080 / Ryzen 9 7900X3D (Series S, the
VICTORY_SEND_RUNSdiagnostics from #3726):card_recordtakes 2.6 ms a frame onmainand 5.3 ms with the marks on. On a machine bound by the submitting thread, like your 5800X at ~64 ms of preparation, that overhead weighs more and the GPU time the marks save doesn't show at all, so a net loss is what one would expect. Your +11 ms is larger than my +2.7 ms. I suspect it scales with the number of compared ranges per frame, which depends on the scene and settings (you ran Series X at 1440p), but I haven't verified that.I can't explain the +1 GB of private memory yet. The marks' page table is only 8 MB, so it's something else: plausibly the per-plan unmarked ranges, or a difference in what's cached. I'll measure it.
So this PR shouldn't be merged as it stands. The marks only pay off if their planning costs less than the hashing they save, and on
mainit currently doesn't. What I'll try:Then I'll measure again on plain
mainwith the marks alone, which is the comparison this PR should have had. Runningcheckwould still help: misses at 0.00 over long play is the other half of what the marks need before they could become a default.@DoubleD17 on GitHub · 2026-11-30 07:13 UTC · original
Follow-up with
VICTORY_WRITTEN_COMPARE=check, as you asked: two more 150 s runs (VICTORY_MARK_WRITES=1, same preload) between two main runs.Misses: 0.00 in all 370 lines of both runs. The last line of each:
Counting skip and check together, that makes 0 misses in about 740 five-second lines on a second card (RTX 5070) and a second profile (Series X).
The cost in check mode is the same as in skip mode: +12.9 ms of CPU preparation per frame and −7.0 % fps against main at that point. On the seconds where the idle camera shows the lighter views (about 7,500 draws a frame), it is +11.5 ms, against +11.6 ms for skip. So on this machine the extra time comes with the marks themselves (the marking shaders, or the single-pass compare while they are on), not with what skip leaves unhashed.
Picture: 0 defects in 160 frames.
AI Assisted
@remijn on GitHub · 2026-11-30 12:32 UTC · original
Follow-up: where the marks' cost comes from, and when they help
I measured this on an RTX 3080 / Ryzen 9 7900X3D (12 cores), Series S, DLSS Quality, FSR 3 frame generation, with capture off (as on
main) and onlyVICTORY_MARK_WRITEStoggled. Same save every run, diagnostics build. Three A/B pairs of 30 s each, run order alternated:card_recordSo the marks are about 7 % slower here too: the same direction as DoubleD17's −9.8 %, smaller on a faster CPU.
That includes two fixes to the marks' planning (on my branch, not pushed yet):
UnmarkedIndexis now one flat sorted vector instead of a hash map of per-copy vectors, and ranges with no unmarked overlap are planned as one run. They took the marks' extracard_recordtime from +2.5 ms to +1.5 ms a frame, but didn't close the gap.Where the rest goes: I profiled the submitting thread with marks off and on, using a build without identical-code folding (
-C link-arg=/OPT:NOICF) so function names are reliable, and diffed it:card_recordgoes from 6.3 % to 9.0 % of that thread (planning, the unmarked index, the clearing pass), about +1.5 ms a frame.Shadow::update,watch::writes,watch::guards) also take a larger share. The run counters show they do the same work in both cases: ~41 flushes of ~11,000 ranges a frame, ~540–555 blocks re-protected, ~235 write-watch queries over ~1.17 GB. They're just ~0.5–1 ms slower, and the guard waits summed over threads rise from ~30 to ~34 ms. That's CPU contention: the marks' extra work lands on a CPU whose cores are already all busy, and no separate mechanism shows up.So the marks only pay off when the GPU is the limit (higher resolution, ray tracing on, a slower card, or a much faster CPU). Where the submitting thread or the CPU as a whole is the limit, which is the case on both machines tested so far, they cost more than they save. I'm leaving this PR open for that case, with the marks opt-in as they are. It shouldn't become a default without measurements from a GPU-bound setup.
Pull request closed