GPU: remember guarded title blocks, keep the #141 crash fix #208
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/vktory6--VKtory!208
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-208"
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?
@TheRifai on GitHub · 2026-12-02 12:33 UTC · original
TheRifai:liveguard-known-view→main· +46 −4 · 2 files · 1 commits · closed without mergingWhat
Follow-up to #171, where the maintainer isolated the drop to #141 (
77a61b9) and asked what the sending waits look like in my logs. They do step up with #141 (6 → 53-61 ms/s in my bisect runs), and the cause is the shape they suggested:live_protectcallsis_viewfor every block it guards, and a faulted block is guarded again thousands of times a second.This PR remembers the blocks
is_viewaccepted in a newGuards::known_viewset. A re-guard of a known block skips the Windows query. The two ways a block can stop being title memory (title_memory_unmapping,title_memory_freed) clear the note, so a reused address is asked about again and #141's crash fix stays in force. Refused blocks were already counted inLIVE_NOT_TITLEand are never remembered — no switch, no fallback, no change to which blocks are guarded.Evidence
Answer to the maintainer's question, from my earlier matched bisect (1 s stats windows):
31c20c7had 8 sending waits/s, 6 ms/s and ~8k blocks guarded again/s;77a61b9(#141) had 14/s, 53 ms/s and ~13k/s;d59b4f8had 14/s, 61 ms/s and ~14k/s.slot_reads at Executestayed ~7 ms per slow frame, so the pause is on the sending path, not descriptor resolution. Evidence:/home/shlong/Documents/VKtory-capture/bisect-{old,current}/,/home/shlong/Documents/VKtory-capture/bisect{77,7c3209,1befc3}/.A/B/B/A of this patch against main
da2c3b1(same code asd59b4f8apart from a docs commit), RX 9070 XT / RADV 26.3.1, GE-Proton11-16, Series X 3840x2160, warm store, house savert3:110 s per run with W/I/K/J at 20/45/70/95 s. Static (no keys), 90 s per run: main 28.51 / 27.68 fps, 50.8 / 48.0 ms/s waits; patched 29.21 / 29.18 fps, 42.4 / 37.6 ms/s.
LIVE_NOT_TITLEstayed at 16 in every run — the same Wine stack blocks at0x100000000, so the filter still declines them. Validation-layer runs were not used for timing. Evidence:/home/shlong/Documents/VKtory-capture/liveguard-{ab,static}-{A1,B1,B2,A2}/.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited (rules 29/31)unsafeor translator output changed (rules 2/9b/33/35/36/27)cargo check -p victory-gpu --features diagnosticsandcargo test -p victory-gpu --features diagnosticspass;tools/build.shexit 0watch/live.rsextended to assert the note is made and cleared; they cannot execute on this Linux host@TheRifai on GitHub · 2026-12-02 13:19 UTC · original
Additional A/B/B/A in the maintainer's scene (prison cell), since #171's isolation used that save. Same pair of builds as the PR evidence, RX 9070 XT / RADV 26.3.1, GE-Proton11-16, Series X 3840x2160, warm store, named save
prison, 90 s per run, standing still:LIVE_NOT_TITLESo in the prison cell the memo gives about +3 to +4 fps and cuts the sending wait by roughly a quarter to a third; the refusal count stays at 16, the same Wine stack blocks. This is closer to the scene where the maintainer saw the drop (13.1/13.0 fps main, 21.6 without #141), and the patched arms land near their reverted-#141 rate while keeping #141's filter. Evidence:
/home/shlong/Documents/VKtory-capture/liveguard-prison-{A1,B1,B2,A2}/.@Flezzonkeys on GitHub · 2026-12-02 13:20 UTC · original
Thanks for the quick patch. I tested
f1301e5unmodified on the machine from #171 (RX 9070 XT, 9800X3D, Proton Experimental). It helps a little here, but most of the drop remains.First 41 world seconds of each run (
victory_gpu::hostlines with at least 1000 draws/frame), same save, played by hand:08adddc(2 runs)08adddcminus #141 (1 run)Only
victory.exediffers between these builds. The route was not scripted and the machine had several GB in zram swap.My guess, not proven: streaming unmaps and remaps title memory so often here that the remembered blocks are cleared and asked again. I had tried a similar cache myself before, with the same small effect. The log of this run shows no refused blocks at all, while you see 16.
About the red CI: the new test calls
known_view.contains(&(...)), butBlocks::containstakes ausize, so the lib test does not compile (E0308, 5 times). The code itself builds fine.I can test another version.
@TheRifai on GitHub · 2026-12-02 13:27 UTC · original
You were right on both counts, and I don't have a version that fixes the remaining drop.
The red CI was my test bug:
Blocks::containstakesusize, I passed&usizefive times. I pushed a corrected branchliveguard-known-view-v2(de28376) with only that test fix; no force-push, this PR stays as-is. Please use the v2 branch if you try again.On the effect size: your result is consistent with the remap-churn explanation. In my runs the memo saved 25-35% of sending waits and 1.5-3.5 fps, with 16 refusals per run; on your machine there are no refused blocks at all and remaps clear the note often, so there is little left to save. The memo only removes a repeated query — it cannot help the case where the blocks are genuinely new to the filter each time, and I have no further change to propose here without a profile of what
is_viewis being asked about after each unmap. The plain revert would recover more, but it reopens #139, so I am not proposing it.@Flezzonkeys on GitHub · 2026-12-02 14:12 UTC · original
Thanks for checking. I compared v2 with
f1301e5: only the five test lines differ, so I won't run it again. The CI here stays red until that fix is on this PR's branch.One more data point on what is asked after an unmap. Before your PR I tried two versions of this on
d59b4f8plus a few local commits:is_viewOne run each, played by hand, with several GB in zram swap, so only the rough size counts.
The third version should answer a freshly remapped view without
VirtualQuery, yet most of the wait stayed. So either many blocks are in none of those records, or the time is not mainly in the query. I did not count which. A counter for theVirtualQuerycalls fromlive_title_block, plus the time spent in it, would tell the two apart.@TheRifai on GitHub · 2026-12-02 14:40 UTC · original
Follow-up to your counter request. PR #216 (
GPU: count is_view calls and time in live guards) adds the count and ns aroundlive_title_block'sis_viewcall, plus a stats line. One 100 s house run on main963df8ewith GE-Proton11-16:is_view830 calls/s median, 80.6 ms/s median (128.8 mean), ~100 us per call; sending waits 28.3 ms/s median (74.4 mean). So the query path is larger than the wait it was blamed for, and ~100 us per call is far more than oneVirtualQuery— the hole walk inis_viewor umem-lock contention is the place to look, which fits your third version not helping much. No behaviour change; the #141 crash fix is untouched. Numbers and checklist are on #216; no plain revert proposed.@TheRifai on GitHub · 2026-12-02 14:40 UTC · original
Correction: the counter PR is #219, not #216 (I misnumbered it in the previous comment).
@Flezzonkeys on GitHub · 2026-12-02 14:51 UTC · original
Thanks for the counter, that helps a lot. I think ~100 us can be a single
VirtualQuery: Wine'sget_vprot_range_sizewalks the page bytes to the end of the region, withvirtual_mutexheld. The comment inwatch::guarddescribes the same cost (0.6 ms for a 174 MB heap).The title's GPU-only view space (0x801, 24 GiB) stays one untouched placeholder (
show_pool), so a query in it walks everything behind the address. I timed this with a small test program (Proton Experimental 11.0, 9800X3D, 24 GiB placeholder, 2000 calls each, no game running):VirtualQueryVirtualProtecton one block there takes 0.5 us, which would fit why the path was cheap before #141.Not proven: that the blocks asked about are in that space. Counting calls by
RegionSizein #219 would show it.If so, a possible fix is to ask the runtime's own record first.
title_placeholder_reservedalready keeps these reservations (TOLD), but only withVICTORY_HOLES_TOLD=1. Kept always and checked beforeis_view, it would answer both mapped blocks and holes there without a query. The Wine stacks from #139 are outside those reservations, so they would still be refused.@vktory6 on GitHub · 2026-12-02 15:41 UTC · original
Thanks. This and #219 found the cause, and Flezzonkeys' trace on this PR finished the job:
is_viewis aVirtualQuery, which under Wine walks the region's page bytes withvirtual_mutexheld (~100 µs per call). The memo here only kept accepted blocks, so every refused block was queried again on every guard, and those are the slow ones.I fixed it on our side in a different way (
github.com/vktory6/VKtory@3aea0e4): the guards now keep the record of what the runtime gave the title (allocations, commits, placeholder reservations, until a whole release) and answer from that and umem's ranges with no Windows call. Anything else is asked once, and a refusal is remembered until the title is given memory there. Wine's stacks stay unguarded as #141 made them; its test is extended for both cases.Measured on an RX 9070 XT, boat start, 141 world seconds each, A B B A: | run | build | fps |
|---|---|---|
| a1 | main fbf3e9d | 13.54 |
| b1 | fix | 25.01 |
| b2 | fix | 26.38 |
| a2 | main fbf3e9d | 14.18 |
"sending waits" in the stats line went from up to 174 ms a second to under 1 ms. No device loss, no refused-block lines in either build..
So I'm closing this one as superseded. The credit is in the commit message.
Pull request closed