[pr-performance][memory] Windows of title memory on the card tile by tile (DARNER_WINDOWS_SPARSE; off by default) #62
Loading…
Reference in a new issue
No description provided.
Delete branch "Sobo/Darner:windows-sparse"
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?
With DARNER_WINDOWS_SPARSE=1 (and tiled resources tier 2 or more), the
card side of a window of title memory is a reserved buffer: its 64 KiB
tiles get memory from a pool of 64 MiB heaps only when a send first
brings them bytes that are not zero, or when shaders may write them, and
give it back when a send brings a whole tile as zeros. Empty heaps go
back to the card 5 s later. The mappings are made on the queue before
the list that sends. Unset or 0: windows as before.
A window made tile by tile is counted in WINDOW_SPARSE_BYTES, not in
WINDOW_CARD_BYTES, so its drop leaves WINDOW_CARD_BYTES alone: taking its
size off there ran the count below zero a few minutes into a city, and
from then on window_admission refused every new window the card. The
windows line says that count too.
Ported from fxceless/blackbebec b715714 (GPL-3.0), without its
DIRECT/Sources parts.
Co-Authored-By: Claude Opus 5.5 [email protected]
Fluxer-ID: 1577742832095989771
Contributor role (optional)
What it changes
Switch:
DARNER_WINDOWS_SPARSE=1(off by default).A window of title memory (memory outside the title's buffers) gets as its card side a reserved buffer (CreateReservedResource) that is given memory in 64 KiB tiles, from a pool of heaps, only where the GPU or the CPU actually touches it. Empty heaps are released after 5 s, not at once (releasing them at once lost the device). Page buffers stay out of tiled windows (
buffer_sides(..., direct = !tiled)).A tiled window is counted in
WINDOW_SPARSE_BYTES, not inWINDOW_CARD_BYTES, so its drop leavesWINDOW_CARD_BYTESalone. (Taking its size off there ran that count below zero a few minutes into a city; from then onwindow_admissionrefused every new window the card (Fallback::Cap) and placed it in the PC's memory.) The windows line also says that count now.Ported from fxceless/blackbebec b715714 (GPL-3.0), without its DIRECT/Sources parts.
How it was tested
main4a92569fb(git.gtahub.st) with this patch applied. Build check:cargo clippy -p darner-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings: clean.cargo testwas not run (no Windows machine for the checks). The gameplay numbers below come from my own builds, which carried this change together with other local changes (same scene, settings and hardware before and after).darner warm --used --againwithDARNER_WARM_SHARED=1.buffer mirror spanof about 17,592,186,040,000 MB in the compile-memory line). In three runs with it (Series S profile, 1440p output, FSR 3 frame generation 2x, 5 to 6 minutes of city each), the count stayed at 0 MB, the span stayed positive (4.3 to 4.9 GB), and at the end 1,126 windows (6.9 GB) were on the card, none in the PC's memory, none turned away.DARNER_PAGE_BUFFERS=3(now on by default) solves a similar problem; the two have not been compared side by side.Checklist
main.docs/asset-policy.md.Checked for overlap
WIP: Windows of title memory on the card tile by tile (DARNER_WINDOWS_SPARSE; off by default)to [pr-performance][memory] Windows of title memory on the card tile by tile (DARNER_WINDOWS_SPARSE; off by default)One data point from an RTX 5090 (32 GB, driver 621.14, hardware RT, DLSS Quality, Series X profile, 1440p), with #62 merged onto
bd0de0calongside #23, #36, #37, #76, #92 and #98. Two hand-driven city drives of about 6 and 8½ minutes, without and withDARNER_WINDOWS_SPARSE=1:Mean shared GPU memory fell by 1,141 MB and 1,085 MB in two paired road runs on a 16 GB RTX 4070 Ti SUPER. Both pairs also had fewer frames above 50 ms. The more severe stalls varied between runs.
Archived runs. Control
1a5286a78d, candidate39d5c87e53with only the sparse-window change. Stable patch ID2c96ddc4dbaa74a9f819b7527f7c5dd73d674665matches upstream head60a042218b.DARNER_WINDOWS_SPARSEwas 0 on main and 1 on the candidate. i5-13600KF, 32 GB RAM, Windows 11, NVIDIA driver 617.14. Series X, native 2560×1440 SDR, DLSS/FG/hardware RT off, 30 FPS cap.Same copied save and warm cache. I used the first 90 s of each two-minute drive from the motel parking lot toward a divided road, to exclude a late obstruction in round two. Build order was reversed in the second pair, with other builds run in between. Traffic and steering varied, including a steering correction in the first control. I counted complete successful frame intervals only. All four windows had consecutive present IDs and zero lost rows. FPS uses frame count divided by summed intervals. Memory is the mean of the per-frame
shared_used_mbandvram_used_mbcounters. Longer-session stability remains open.Closing: on today's main (v2026.12.03.02) this no longer gains anything. With
DARNER_WINDOWS_SPARSE=1against the same settings without it (RTX 3090, Series S profile, city): frame time per 1,000 list calls 1.04 ms against 0.98 ms (0.95 against 0.92 in the heaviest part), GPU time per frame about the same, and no textures waiting for room either way. The overflow it was made for (windows filling the memory shared with the card) is handled on main now (page buffers,DARNER_POOL_SMALL=auto). No image errors in the run with it on; the window count fix in it stays in my notes if it is wanted again.Pull request closed