One shared DXGI reading of the card's memory (VICTORY_CARD_OWNER=read, off by default) #4744
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4744"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Jesper-Andersson on 2026-12-01T04:44:56Z.
Refs #4462 (step 1 of the plan there; it doesn't fix the issue on its own).
What it changes
Every room test asks DXGI for the card's budget and use on its own (
Host::video_memory), up to every 32 MiB of upload and per buffer made, and each sees a slightly different number. Step 1 of #4462 is one reading that every caller shares, so later steps have one budget and one use to work from.New switch
VICTORY_CARD_OWNER(off by default;read, or1/allfor every part merged so far). Unset, nothing changes:video_memoryasks DXGI on every call, as now. Withread(newcrates/victory-gpu/src/card.rs):VICTORY_CARD_OWNER_KEEP_MBreplaces the margin). Nothing acts on them yet; later steps would.card owner:line once a second with the lines, the reading, the estimate, the error at the last reading with its sign (+ = the estimate was high), event wake-ups against budget moves, and DXGI queries against asks.With
read, the existingvideo_memory()call sites onmain(about 34: the room checks for uploads and card copies, the read-ahead thread, the sweep, the shadow copies, the F3 panel and others) all get this shared reading, with the budget held through moves under 128 MiB and the estimated use (which can be off either way until the next reading), instead of a fresh DXGI reading each time. Their decisions can therefore change with the switch on. Frame time and distance past the budget have been compared with and without it on one card (@kraiy404, below); the decisions themselves have not been logged side by side.The pools mark their texture blocks as card memory (
Pool::on_card) so the estimate sees them. Unit tests cover the dead band, the lines, the state changes and when a reading is taken again. Line indocs/findings.md.How it was tested
main5fabb46ea+ this change, diag build,VICTORY_CARD_OWNER=readwith the switch set of our usual runs (listed in the log header; all present onmain), no frame generation, GPU clocks not locked; one run, 2026-12-01, an 81 s load then ~7 minutes in the world): at most 63 readings a second on the loading screen for up to 2,349 asks a second; in the world a median of 17.6 a second at 18.3 fps (one a frame); estimate off at a reading by 1 MB or less in 95 % of thecard owner:lines (316 lines over ~8 minutes; max 67 MB); 6,267 event wake-ups against 2 budget moves; card use peaked at 6,749 MB against a 6,826 MB budget. No panic, no device removal, picture normal in four shots. Not compared with the switch off, so whether callers decide differently with it on is not shown. Results in #4462 (comments of 2026-12-01). Split by phase: the large errors all came at the start and while the world loaded in (use rising by up to 1.26 GB between twocard owner:lines, which are about a second apart); once in the world the error at a reading stayed within 20 MB, and within 25 MB inside a period.v2026.11.30.03+ this PR's first three commits; their comment): four runs, no removed device (a fifth run, switch unset, texture room 88 %, lost the device after 12 minutes; the switch was unset, so not from it); withread, about one DXGI query a frame (median 19 and 16.6 a second); the state was hard in 83 % (Series S) and 92 % (Series X) of the lines; 261,928 and 91,430 event wake-ups against 2 budget moves each. Their extracts show the same phase split as ours: up to 175 MB at a reading and 364 MB inside a period during load-in; in the world within 16 MB at a reading and 64 MB inside a period. Frame time: Series S about the same (57.9 ms median with it, 60.0 without); Series X 69.0 ms with it and 88.9 ms without, one pair on a card that varies a lot between runs, so not shown to be the switch.f279fe874: the error's sign in the line, a corrected doc comment, a findings line;74977c768: a wording fix in that findings line):cargo test --locked -p victory-gpu --lib card::9 passed, including a new test for the sign; not run in the game (it changes the log line only).cargo testpassed for the crates it touches: yes,cargo test --locked -p victory-gpu --libon this branch, five full runs: 1,103 passed in four; in one,watch::tests::ask_rest_falls_back_per_piece_when_touching_unwatched_neighbourfailed (a test this change doesn't touch; it passed alone and in the other four runs).cargo clippy -p victory-gpu --all-targets --locked -- -D warningsstops on 5 errors thatmain5fabb46eaalready has (host/font.rs213 and 260,host/menu.rs667,host/panel.rs602 and 668), none in this change; thecheckjob fails onmain5fabb46ea(still the head ofmainon 2026-12-01) the same way, and on this PR's head74977c768.Spec dependence
Checked for overlap
host.rs,resource.rsandpool.rsare touched by many open PRs; the changes here are a few lines each.Drafted with AI assistance (Claude Code).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by rahmondg45 on 2026-12-01T04:51:03Z.
yes please fix vram overload on 8gb cards also using 29gb of regular ram as well
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kraiy404 on 2026-12-01T10:23:52Z.
Tested #4744 on an 8 GB card with the settings the PR lists as untested (Series X, DLSS frame generation), and compared with the switch off, which the PR says has not been done.
Setup
v2026.11.30.03(e1251c31) + only this PR's three commits (52a0dbe1,5e0533a2,69de6017). Release build, no other changes. Shaders preloaded before every run (1,664 of 1,664 pipelines in the library).Runs (no removed device in any of them)
VICTORY_CARD_OWNERSeries X is where it shows. Same profile, same route: 88.9 ms a frame at the median without the switch, 69.0 ms with it; the card sat 864 MB past its budget instead of 412 MB; 50 of 187 sampled seconds were over 100 ms without it, 7 of 131 with it. I would not call that proof — this card varies a lot between runs — but it is the one pair where frame time and over-budget distance moved the same way.
Series S does not show it: 60.0 against 57.9 ms, p99 in the same range. A second run of the Series S setting of A measured p99 113.8 ms instead of 648.8 ms, so run-to-run variance there is larger than any difference between the arms.
card owner:linesSeries S, run B (723 lines): DXGI queries median 19.0 a second (p95 31.5, max 62, about one a frame); estimate error at a reading median 0 MB, p95 1 MB, max 175 MB, worst in a period 211 MB; budget wake-ups 261,928 against 2 moves; state
hardin 598 of 723 lines (83 %),soft85,under40; B 6,954 MB, T 6,442, L 6,186, H 6,698; DXGI used median 6,966 MB, max 7,217 MB.Series X, run C (473 lines): DXGI queries median 16.6 a second (p95 52.8, max 61); estimate error median 0, p95 1, max 80 MB, worst in a period 364 MB; wake-ups 91,430 against 2 moves; state
hardin 436 of 473 lines (92 %); DXGI used median 7,342 MB, max 7,742 MB a gainst the same 6,954 MB budget.So on this class of card the state sits in
hard83 to 92 % of the time, the budget event fires 90,000 to 260,000 times while the budget itself moves twice, and the estimate is usually exact but once reached 364 MB in a period. That may be worth knowing for #4462's next steps.One crash, not from the switch: with frame generation 2x and texture room 88 % (Series X, switch unset) the device was removed after 12 minutes (
0x887A0005,0x887A0007): 32 of 129 sampled seconds over 100 ms, p99 10,206 ms, longest frame 12,192 ms, 7,305 over-VRAM warnings, card 286 MB over budget at the median (754 MB worst). With the room back to 72 % the same profile ran 187 s (run D) with no removed device.cardowner-A1-off-extract.log
cardowner-A2-read-extract.log
cardowner-B1-read-X-extract.log
cardowner-B2-off-X-extract.log
Available if you want them untrimmed.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Jesper-Andersson on 2026-12-01T13:38:56Z.
@kraiy404 thank you, this covers Series X and DLSS frame generation, which we hadn't run, and the switch-off pair we hadn't done.
The estimate error is a load-in effect. In your two
readextracts every line with 20 MB or more at a reading comes in the first ~35 lines, at the start and while the world loads in (DXGI use climbing up to about 1.2 GB a second, for example 3,797 → 4,981 → 5,522 → 5,879 → 6,486 MB in five lines at Series X). After that:Our run on this branch split the same way: up to 67 MB at a reading and 219 MB inside a period during load-in, then within 20 MB at a reading and 25 MB inside a period in the world. So it doesn't look like the error grows with frees during play.
Which way it was off the line didn't say: it printed only the size. Frees of committed textures make the estimate high until the next reading, and memory it doesn't count (buffers, other heaps) makes it low.
f279fe874, now on this PR, prints the error with its sign (+ = the estimate was high); it changes the log line only (unit tests pass; not run in the game). During load-in the sign would show which of the two it is.The Series X pair. In the world your callers asked a median of 109 (Series S) and 98 (Series X) times a second against 19 and 16.6 DXGI queries. On our card one query took about 0.55 µs (idle desktop), so the CPU time saved is well under 0.1 ms a second, far too little for 20 ms a frame. What does change is the number the callers see: one reading a frame plus our own deltas instead of a fresh reading each time, so their decisions could differ. With one pair, and your Series S repeat moving p99 from 648.8 to 113.8 ms, I can't tell that apart from run-to-run spread. If you have time for more, another Series X pair each way would help the most.
Noted on the 12-minute device removal at texture room 88 % with the switch unset.
Drafted with AI assistance (Claude Code).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kraiy404 on 2026-12-01T15:59:56Z.
As you asked, I ran a few more tests at Series X. The settings and the build are the same as before; only the switch changed.
Three more Series X runs (2026-12-01 evening)
Same save, same route, same build (
.03+ only this PR), same settings, Series X at 2560x1440 with DLSS Quality and frame generation 2x. Run order: on, off, off.VICTORY_CARD_OWNERThe crash is the part worth your attention: with the switch off, both of this evening's runs ended in
0x887A0005with reason0x887A0007(device hung, at about 3 and 5 minutes); with it on, the run finished. An earlier off run on the same profile went 187 s without trouble, so I am not calling this proof of anything — two crashes against one clean run is a small sample, and I have no mechanism to offer for why a shared reading would change it. But if you want a direction to look at, this is the only one in my data that is not just the log line.Frame times do not separate: medians 78.5 on against 69.4 and 70.3 off, with the off runs' p99 anywhere from 80 to 492 ms. The over-budget distance does not separate either (+506 on, +41 and +204 off).
On the estimate error: your load-in split holds in our extracts as well. Outside the first ~35 lines every reading was within 16 MB (Series X) and 15 MB (Series S), and the largest error inside a period was 64 MB, the same as yours. The 175 and 364 MB I reported earlier were all in load-in, so I agree with your reading.
Full play logs for these three runs are available if useful.
xrun-X-1-read.log
xrun-X-2-off-crash3min.log
xrun-X-3-off-crash5min.log
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T16:01:17Z.
On
74977c76, a reader can see the fresh DXGI use while it still sees the preceding allocation baseline. That adds the same allocation twice and can make the estimate cross a budget line during publication.d68953df makes the DXGI values, allocation baseline and timestamps one snapshot. The lock covers only the snapshot copy. The DXGI query runs outside it. A valid sample at startup also stays valid when the clock reads zero.
A focused Windows fixture paused a synthetic sampler during publication. For a 128 MiB allocation, the author code temporarily reported 1,280 MiB instead of 1,152 MiB. The patch reported 1,152 MiB throughout. Two reads at time zero made one query with this patch. Staged asset policy passed. Driver timing and frame pacing still need a hardware run to quantify.
Please keep the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change in.AI-assisted with OpenAI Codex.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Jesper-Andersson on 2026-12-01T16:31:52Z.
@andrewpozdnakov7-jpg thank you, the race is real and your fix is in.
The race. On
74977c76the thread taking a reading stored the four DXGI values (card.rs:240-242) before the allocation baseline (MADE_THEN,card.rs:243). A caller reading atcard.rs:253-254in that gap gets the freshused, which already holds what we allocated since the last reading, plusMADE - MADE_THENagainst the old baseline, which counts the same bytes again.say()(card.rs:269-271) could log the same mix.What I checked in d68953df. All of a reading (DXGI values, baseline, frame, time,
up_since) is now copied together under oneMutex. The lock is held only for that copy, and the DXGI query and the bookkeeping run outside it. Withnow_ms()counting from its first call, a reading taken at 0 ms used to look like "no reading yet" and was taken again;now.max(1)keeps it. Thecard owner:line prints the same fields as before, now from one consistent copy.One small thing, log only: the copy is taken before the thread wins the query flag, so a thread that wins it right after another one finished settles from the older budget and could count one budget move twice in
moves. Re-reading the copy after the flag is won would close it. I left it as is.Folded in as
dde8eb24on this PR, with your Git author kept.Tests (
dde8eb24, Windows 11, toolchain 1.98.1 fromrust-toolchain.toml):cargo test --locked -p victory-gpu --lib card: 76 passed, 0 failed, 8 ignored.cargo clippy --workspace --all-targets --locked -- -D warnings: fails only on five lints inhost/font.rs,host/menu.rsandhost/panel.rs, which come from main (3bde49236) and are the same five that failed thecheckjob on the previous commit (the run fordde8eb24is still pending). Nothing incard.rs.@kraiy404 thank you for the three extra Series X runs. Two hangs with the switch off against one clean run with it on is worth keeping in mind. Like you, I don't see how a shared reading would cause or prevent a device hang, so I'm not drawing a conclusion from it yet.
Drafted with AI assistance (Claude Code).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T16:39:13Z.
Thanks for taking the snapshot fix. I followed up on the stale copy you spotted at
dde8eb24.820c696f rechecks the snapshot, frame and event after winning the query flag. If another caller already refreshed it, this caller uses the new reading. A query that is still due starts from the latest budget and allocation baseline.
In a focused Windows fixture with a stub DXGI query, a caller paused between reading the snapshot and acquiring the flag. For startup plus one frame with a budget drop, the author head made three queries and counted two moves. With the patch it made two queries and counted one move. Event-triggered refresh and retry after a failed query still worked. Staged asset policy passed.
Please keep the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change in.AI-assisted with OpenAI Codex.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:33:42Z.
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