Card copies: twins and second sides counted where they lie; the queue-line cap opt-in (#3597) #4243
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!4243
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4242"
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?
@Lyrnc on GitHub · 2026-11-30 17:42 UTC · original
Lyrnc:perf/card-copy-budget→main· +353 −62 · 3 files · 2 commits · closed without merging[pr-fix] Part of #3597 (the card-copy accounting side of it, and of #3655 and #3463). Reworked on 2026-12-01 after our 8 GB bench run (details below): the room-line cap for copies, which this PR first turned on for everyone, is now opt-in and off by default. Left on by default are the accounting fixes, which change only what is counted and the copies' limits. Draft until our 8 GB run of this version matches main.
What it changes
Accounting (on by default)
These change what the copies of title buffers are counted as, and so the copies' limit (
card_limits) and the room the texture queue keeps for copies not made yet (card_room_kept). They do not change the line up to which copies are made (97 % of the budget, as on main).CARD_BYTES[1]counted only the hash bytes, 48 bytes for a 64 KiB copy. The newcard_before_bytes(size)rounds the hash bytes up to 64 KiB. Copies' sides plus twins (card_held) count againstcard_limits' second number and againstcard_room_kept. In our runs the twins came to 16-29 MB, so this is about getting the count right more than about freeing memory.VICTORY_CARD_ALLsecond sides no longer count as card memory. WithVICTORY_CARD_ALL=1(a play default since v2026.11.30.01), a copy that is turned down gets a second side in the PC's memory, andcard_foradded its bytes toCARD_BYTES[0], the card's count, with no limit. Those bytes used up the copies' limit and the room kept for them, and they showed up in "host copies in the card's memory". They are already in the residency fallback count. They (andVICTORY_WINDOWS_OWN's) now go into their own counter,CARD_SYSTEM_BYTES.card_forandwindow_card_forreturn whether the side is on the card,Cardremembers it, andDropsubtracts from the matching counter (card_count).VICTORY_WINDOWS_OWN=1, freeing a window's second side subtracted fromCARD_BYTES[0], which it had never been added to.host copies in the card's memory: ...now also printssecond sides in the PC's memory N MB. The new field comes after "their bytes from before", so parsers that read the line's prefix still work.VICTORY_VRAM_BUDGET_MB: checked, and the limits already follow it.card_limitsreads its budget fromHost::video_memory(), which applies the cap first, so 4096 gives a limit of 737 MiB. A new test pins this. Our 8 GB runs showedcard_buffers_max_mb=1474on both main and this branch.The room-line cap (opt-in, off by default)
VICTORY_CARD_COPY_LINE=1keeps copies of title memory under the texture queue's line (resource::room_line; 80 % in play with frame generation) instead of 97 % of the budget. Windows and arenas already stop there (#971). It applies tocard_room_for/card_admission,wc_mapped_forandwindow_mapped_for.VICTORY_CARD_COPY_LINE_AFTER_S=Napplies it only from N seconds after the first copy got a side in the card's memory.Why it is off by default. The first version of this PR turned it on for everyone. Our like-for-like run at an 8 GB stand-in showed the cost: RTX 5080 with
VICTORY_VRAM_BUDGET_MB=8192, frame generation 3x, same save, cache and walk (#4243).The line kept the card under its budget, but the 630 MB of copies it turned away were read across the bus every frame. 2,272 of the 2,336 refusals came in the burst of the world's first seconds. That is why
_AFTER_Sexists: it leaves that burst to the 97 % line and holds only later copies to the queue's line. It has not been measured yet.The stand-in has limits. On a 16 GB card, main's overrun of an 8 GB budget costs nothing, because the memory is there. On a real 8 GB card the system has to move memory out itself, so main may pay for its overrun in a way this run cannot show. The off-by-default choice rests on the cost we measured, not on proof that the line is wrong for real 8 GB cards.
A side note: the first version's case (copies made past the line and taking frame generation's room) did not show much on our 16 GB runs either. There, 3,417 of 3,498 copies were made in the world's first 10 seconds, under the line, and the growth past the budget came from texture copies.
Tests compile again
On main,
cargo test -p victory-gpu --libhas not compiled since7addcfc7. Twocard_passcalls in host.rs's tests are missing the newcaptureargument. They now pass[0; 3]("zeros otherwise", ascard_pass's doc says). This is a separate commit.How it was tested
shadow::window_tests:card_copies_stop_at_the_texture_queue_line_only_when_asked: off, copies keep the 97 % line; on, they stop at the queue's line.card_copy_line_waits_for_the_first_burst: how_AFTER_Sgates the line.card_room_kept_counts_the_twins: with 2 GiB of copies and their twins, no room is kept.card_limits_follow_a_capped_budget: 4096 / 6000 / 8192 / 10500 MiB budgets.second_sides_in_the_pcs_memory_are_not_card_bytes.cargo test --locked -p victory-gpu --lib: 1,119 passed, 2 failed, 66 ignored. The two failures,list::thin::tests::bindings_record_no_workandshader_cache::tests::every_switch_of_the_translator_is_in_the_key, fail the same way on main with only thecard_passfix applied (checked).cargo clippy -p victory-gpu --all-targets --locked, and the same with--all-features: nothing in the lines this changes. Its warnings are already on main:rangednever used (shadow.rs, from27d312d3),seed % 3 == 0(host.rs test, from7addcfc7), and withdiagnostics,mbnever used (copystat.rs). Because of those, workspace clippy with-D warningsalready fails on main, along withloop_capsin victory-shader.cargo xtask policy: one finding, already on main and in a file this does not touch (crates/victory-shader/src/native.rs).VICTORY_CARD_COPY_LINE_AFTER_Sin game;VICTORY_WINDOWS_OWN=1andVICTORY_WC_BARin game (those paths only changed how they count).Not in this change
card_before_byteswould then count what they hold).Checked for overlap
card_room_kept,CARD_ALLand "before twins". None counts the twins or the second sides, or caps where copies of title buffers stop. Related: #1998 (arenas' card room on cards of 12 GiB or less), #2940 (window_room_for), #3754 / #3848 / #3454 / #4005 (texture side), #3592 / #945 (pooled twin hashes), #3889 (ReBAR window limits).AI use
Claude Code (Claude Opus 5.5) read the code paths, wrote the change and its tests, ran the unit tests and lints, and wrote this description. The rework follows our bench's 8 GB result, which another Claude Code session ran and posted above.
🤖 Generated with Claude Code
Real-card evidence (RTX 4070 Ti 12 GB, Luca121)
Same session, route and settings, >20 min of play each: the default (accounting only) ran with no budget overruns or errors;
VICTORY_CARD_COPY_LINE=1turned down 992 copies (68 MB) with no gain (fps the same or slightly lower near the budget, prep +2.6 ms). Details: #4243 (Luca121, 2026-12-01). So the cap stays opt-in.@Luca121 on GitHub · 2026-11-30 21:41 UTC · original
Tested this on real 12 GB NVIDIA hardware with DLSS Frame Generation 2x in an isolated A/B comparison against
origin/main(e1251c31/v2026.11.30.03).Test setup
10.0.26300), i7-13700K, RTX 4070 Ti 12 GB, 32 GB RAM1113x626->1920x1080), DLSS Balanced + FG 2x, RT Off, Wave32,VICTORY_TEXTURE_ROOM_PERCENT=85,VICTORY_CARD_ALL=1,VICTORY_CARD_BUFFERS_MIN_KB=64origin/main(e1251c31)cd880f07merged locally ontoorigin/main(e1251c31)draws >= 1000) per run.Results
origin/maine1251c31)#4242cd880f07one1251c31)draws >= 1000) / samples16.8 min/18716.3 min/160med / p10 / p90)10.80 / 8.80 / 14.6010.55 / 8.70 / 14.70VRAM >= 80%(med / p10,n)10.50 / 8.70(n=145)10.50 / 8.60(n=156)VRAM >= 85%(med / p10,n)85%, peak84.0%)10.50 / 8.60(n=98)prep / gpu / cb)39.9 / 5.2 / 18.9 ms39.6 / 6.4 / 19.2 msheapsmax stall39.7 ms16.7 ms9,182 MB(of10,955 MB) /84.0%9,769 MB(of11,042 MB) /89.7%9,145 MB(of10,962 MB,83.4%)9,736 MB(of10,960 MB,88.8%)10,331 MB12,367 MBpeak -> end)5,706 (1,979 MB)->4,065 (1,196 MB)4,073 (1,982 MB)->3,583 (1,002 MB)their bytes from before, peak / end)0 MB / 0 MB202 MB / 202 MBpeak / end)main)8 MB / 4 MBkept for card copies of title buffers(end)129 MB0 MBStreamlineVRAM budget warnings /ERRORs / stalls0 / 0 / 00 / 0 / 0Key observations
origin/mainreportedtheir bytes from before 0 MBfor the entire session, whereas#4242ramped from0 -> 202 MBover the first ~5 minutes and held at202 MBthereafter. Becausecard_room_kept_ofnow countscopies + twinsagainst the1 GiBreserve,kept for card copies of title buffersdropped to0 MBoncecopies + twinsexceeded it (freeing the129 MBstill held at the end of Run A).85%room line (9,206–9,543 MBacross the session),#4242refused2,304VRAM card-copy allocations (170 MBcumulative), spilled new second sides cleanly into PC RAM (0 MBbefore85%, peaking at8 MB,4 MBat end), and held VRAM card copies flat at1,002–1,006 MB(settling at1,002 MBfor the last 8+ minutes) instead of expanding past the room line.98gameplay samples atVRAM >= 85%(peaking at89.7%during heavier dock/city streaming, wherein texture copiespeaked at4,876 MBvs4,359 MBin Run A), frame pacing stayed flat (10.50med /8.60p10, matching Run A's>=80%window), with0Streamline budget warnings,0errors/stalls,20,006FG frames shown cleanly, and no visual issues observed.cargo test --libon the merged tree hit two pre-existing failures (list::thin::tests::bindings_record_no_workandshader_cache::tests::every_switch_of_the_translator_is_in_the_key), both untouched by#4242.(AI-assisted log analysis and formatting; all builds, gameplay runs, and verification were done locally on real hardware.)
@Lyrnc on GitHub · 2026-11-30 21:43 UTC · original · edited 2026-12-01 01:28 UTC
Bench result for this PR: the A/B from "How it was tested", run overnight. RTX 5080 16 GB (budget 15,209 MB), Ryzen 7 9800X3D, 32 GB RAM, Windows 11. Release builds: A = v2026.11.30.01 (
c71899d9), B = this PR atcd880f07. Both use one shader cache, since the translator is unchanged. Profile as in #3597's shape: Series X, 1440p, DLSS Performance setting, frame generation 3x (it was on in every run: "presents with it on" in every 5 s line). Scripted walk from the same save.VICTORY_VRAM_BUDGET_MB=8192Copies of title buffers turned down. Corrected 01 Dec: the first version counted the "no card copy" log lines, but those are written for the first 64 copies and then every 32nd. These numbers come from the line's running total:
card_buffers_max_mb=1474, as expected. The copies held 370 MB when the first was turned down and 452 MB at the end, so most of the 1,474 MB limit went unused while 630 MB stayed in the PC's memory.No "did not close", device removed,
DEVICE_HUNGor DRED line in any run.What this shows
VICTORY_CARD_ALLsecond sides now have their own field: 0-1 MB at 16 GB, and 622 MB under the 8 GB cap. On A those 622 MB would have counted as card copies. The 8 GB cap gives the 1,474 MB limit.What it does not show
VICTORY_KEYS_FILE, andlive_linecaps a line's start at 600 s after it is read. Every line meant for later fired at 600 s together, so the character walked until about world+660 s and then stood still. The "standing" rows are the last 10 minutes. Each run stood at a different spot (draws differ), so card use there is not like for like either. The card-use differences between A and B (B 100-350 MB higher) follow the scene, not the build.VICTORY_WINDOWS_OWN),VICTORY_WC_BAR, other GPUs.AI use: Claude Code (Claude Opus 5.5) queued and watched these runs on our bench, parsed the run logs with its own scripts, and wrote this comment.
@Lyrnc on GitHub · 2026-12-01 01:27 UTC · original
Caution from our own follow-up testing; please hold this one for now.
At an 8 GB budget (
VICTORY_VRAM_BUDGET_MB=8192on the RTX 5080, as a stand-in only: the driver still has 16 GB), this branch's run with frame generation 3x averaged about 8 fps with nearly every frame over 50 ms. Main's runs at the same budget in a later session gave 28-29 fps with frame generation off and 22-24 fps at 2x, on the same profile. The likely cause is this PR's own line: 2,336 title-buffer copies (630 MB) were turned away at the 80 % mark and left in PC memory, where main keeps them on the card up to 97 %. On a small card that trades a budget overrun for reads across the bus every frame.This is not a like-for-like A/B yet (different session, frame generation 3x vs 2x). A main control at the same 8 GB budget and frame generation 3x is queued on our bench. Until it confirms one way or the other, I'm marking this PR as a draft. If the control confirms it, the fix is to apply the room line only where it can't push copies off the card wholesale (e.g. above 12 GB, or for new copies only), and I'll say so here.
AI use: Claude Code (Claude Opus 5.5) ran the follow-up and wrote this.
@Lyrnc on GitHub · 2026-12-01 01:53 UTC · original
Follow-up to my bench comment above: the 8 GB control is in. Same PC (RTX 5080 16 GB, 9800X3D, 32 GB), same profile (Series X, 1440p, DLSS Performance setting, frame generation 3x), same save, cache and walk.
VICTORY_VRAM_BUDGET_MB=8192, 10-minute runs, world+30 to 540 s. A = v2026.11.30.01 (c71899d9), run this morning. B = this PR (cd880f07), run last night.card_buffers_max_mb(limits line)The first and second halves of each run look the same (A: 24.9 and 25.3 fps; B: 8.4 and 7.8), so this is not a slow start.
What this shows
card_buffers_max_mb=1474on both builds, as the description says for T8. The difference is only where the copies stop: 97 % against 80 %.What it does not show
AI use: Claude Code (Claude Opus 5.5) queued and read these runs on our bench and wrote this comment. The 8 GB comparison was asked for after a teammate pointed at the copies turned away.
Card copies stop at the texture queue's line; twins and second sides counted where they lie (#3597)to Card copies: twins and second sides counted where they lie; the queue-line cap opt-in (#3597)cd880f0772tob6770cde69@Lyrnc on GitHub · 2026-12-01 03:18 UTC · original
Bench result for the reworked PR (head
b6770cde: only the accounting fixes by default; the queue-line cap is opt-in withVICTORY_CARD_COPY_LINE=1, off). Same PC, profile (Series X, 1440p, DLSS Performance setting, frame generation 3x), save, cache and walk as my two comments above. Release build, run this morning. Its first-start preload ran before the runs, as for the first version.8 GB stand-in (
VICTORY_VRAM_BUDGET_MB=8192), world+30 to 540 s:c71899d9cd880f07)b6770cde)16 GB (no cap), world+30 to 600 s: the walking part, since the route stops at ~660 s, as explained above.
No device removed, DRED or "did not close" line in either run.
What this shows
VICTORY_CARD_ALLsecond sides went to the PC's memory in these runs.What it does not show
VICTORY_CARD_COPY_LINE=1was not run in this round. The first version's numbers above are what the line costs at 8 GB, when it starts at once.AI use: Claude Code (Claude Opus 5.5) ran these on our bench queue, parsed the run logs with its own scripts, and wrote this comment.
@Lyrnc on GitHub · 2026-12-01 03:53 UTC · original
Thanks @Luca121. This is the first run of this PR on a real card of 12 GB or less, which is what it was missing.
How your run relates to the rework. You tested the first version (
cd880f07), where copies of title buffers stop at the texture queue's line. At headb6770cdethat line is opt-in (VICTORY_CARD_COPY_LINE=1, off by default). Only the accounting is on by default.b6770cdeas it is, those copies would go on the card up to main's 97 % line.Two notes on the table:
list::thin::tests::bindings_record_no_workandshader_cache::tests::every_switch_of_the_translator_is_in_the_key, were stale on main. #4297 fixed them there.A request, if you have time. Could you run head
b6770cdeon the same card, route and settings (with yourVICTORY_TEXTURE_ROOM_PERCENT=85), twice in one session?VICTORY_CARD_COPY_LINE=1.That gives the cost of the opt-in line on a real 12 GB card against the new default, in one build. We can't measure that here: our only card is 16 GB, and the 8 GB cap is a stand-in (the driver still has 16 GB). The figures that matter most are the running total of "copies of title buffers turned down", card and shared memory peaks, fps p10, and any Streamline budget warning.
AI use: Claude Code (Claude Opus 5.5) compared your results with our bench runs and wrote this.
@Luca121 on GitHub · 2026-12-01 18:03 UTC · original
Ran head
b6770cdetwice in one session on the same 12 GB card, route, and settings (VICTORY_TEXTURE_ROOM_PERCENT=85, warm cache shared by both runs):b6770cdeas-is (default — accounting only,VICTORY_CARD_COPY_LINEoff)b6770cdewith--set VICTORY_CARD_COPY_LINE=1(confirmed active at startup:copies of title memory stop at the texture queue's line (VICTORY_CARD_COPY_LINE) after_s=0)Setup
10.0.26300), i7-13700K, RTX 4070 Ti 12 GB, 32 GB RAM1113x626->1920x1080), DLSS Balanced + FG 2x, RT Off, Wave32,VICTORY_TEXTURE_ROOM_PERCENT=85,VICTORY_CARD_ALL=1,VICTORY_CARD_BUFFERS_MIN_KB=64draws >= 1000) per run.Results (
b6770cdedefault vsVICTORY_CARD_COPY_LINE=1)b6770cdedefault)b6770cde+VICTORY_CARD_COPY_LINE=1)draws >= 1000) / samples20.3 min/23022.5 min/2528,3288,463med / p10 / p90)10.90 / 9.00 / 15.2010.75 / 9.00 / 13.90VRAM >= 80%(med / p10,n)10.65 / 8.90(n=196)10.70 / 8.90(n=232)VRAM >= 85%(med / p10,n)12.10 / 9.00(n=37)10.70 / 9.60(n=49)prep / gpu / cb)36.35 / 5.60 / 10.45 ms39.00 / 6.65 / 10.55 msheapsmax stall (draws >= 1000)13.4 ms13.3 ms9,640 MB(of11,143 MB) /86.5%9,934 MB(of11,130 MB) /89.3%9,640 MB(of11,145 MB,86.5%)9,921 MB(of11,127 MB,89.2%)11,387 MB11,644 MBin texture copies(peak / end)5,176 / 5,135 MB5,448 / 4,360 MBpeak -> end)4,132 (1,985 MB)->3,915 (1,055 MB)4,047 (1,982 MB)->4,003 (1,068 MB)their bytes from before, peak / end)17 MB / 17 MB17 MB / 16 MBpeak / end)0 MB / 0 MB7 MB / 4 MBkept for card copies of title buffers(end)117 MB49 MB0(0 MB)992(68 MB)Exceeded VRAM budget/ERRORs /DEVICE_HUNG/ DRED0 / 0 / 0 / 00 / 0 / 0 / 0Takeaways
VICTORY_CARD_COPY_LINE=1at 12 GB: Overallp10was identical (9.00vs9.00fps),VRAM >= 80%was flat (10.70 / 8.90vs10.65 / 8.90), andVRAM >= 85%heldp10at9.60vs9.00. The small median gap (10.75vs10.90) tracks the slightly heavier load in Run 2 (8,463vs8,328median draws/frame,5,448vs5,176 MBpeak texture copies).0copies were turned down and0 MBwent to second sides in PC RAM. In Run 2 (VICTORY_CARD_COPY_LINE=1), once VRAM crossed the85%line (9,458 MBof11,127 MB),992title-buffer copies (68 MBcumulative) were turned down while card copies held steady (908 -> 905 MBof2,021 MBmax during refusals) and second sides in PC RAM peaked at7 MB(4 MBat end).0Streamline VRAM budget warnings,0ERRORs,0DEVICE_HUNG/ DRED /"did not close"lines in either run.(AI-assisted log analysis and formatting; all builds and gameplay runs were done locally on real hardware.)
@Lyrnc on GitHub · 2026-12-01 18:06 UTC · original
@Luca121 thank you for the rerun on the real 12 GB card, it settles the default. With the accounting-only default the run matches what you'd expect from main, with no budget overruns or errors. Turning the cap on (
VICTORY_CARD_COPY_LINE=1) turned down 992 copies (68 MB) and bought nothing: fps the same or slightly lower in the ≥85 % band (10.7 against 12.1 median), prep +2.6 ms, and the card only slightly fuller. So the cap stays opt-in, as the reworked head has it, and the PR's default change is the counting fix (twins, second sides, the WINDOWS_OWN bug). I'll add your table to the description as the real-card evidence.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@trustno1-coder on GitHub · 2026-12-01 18:45 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed