GPU: ask for directly indexed SRVs' written pages once per span of title memory #600
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!600
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/600/head"
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?
@desplmfao on GitHub · 2026-11-24 05:20 UTC · original
desplmfao:perf/direct-srv-by-address→main· +1878 −92 · 10 files · 6 commits · closed without mergingStatus (2026-11-24): measured on the reworked #185; not pushed yet. This branch is built on #185's first two commits and #462 (closed). Ported locally onto #185 as it is now (head
1efd438), the same idea (ranges of several host copies in one private reservation share one write-watch question) needs a Wine fix inwatch::allocationfirst (aycow/VIctory#1); with both, same machine and world window (26 lines, medians):So the questions are nearly gone but frame time does not follow; what remains of a world frame is elsewhere. I'll either replace this branch with the port (about 120 lines on top of #185) or close it, depending on whether that remaining time turns out to need it. The description below is for the old base.
Problem
#185's
refresh_direct_srvsbrings each merged range up to date with its own question for written pages. The ranges are mostly in different, small host copies (one title buffer each) that lie close together in title memory, so merging per host copy does not reduce them: in the world here about 170,000 questions per frame, 1.5–2.7 s of it, and under Wine each question is a round trip. That is also what the measurement on #462 shows during loading (about 6,100 questions per frame).Change
refresh_direct_srvscollects the merged ranges of every host copy andrefresh_by_addresssorts them by address, groups those less than 1 MiB apart into spans, and asks once per span.watch::writes_splitanswers a span: once if the kernel takes it, else allocation by allocation, with the parts it cannot answer for listed separately. The written pages go to the shared journal as before.Shadow::update_answeredbrings a range up to date from that answer (pending GPU writes left out, as inupdate).Shadow::updateas before.VICTORY_NO_SPAN_QUESTIONS=1(diagnostics builds) goes back to one question per range, for comparing the two; the per-frameshadow trafficline gainsspan_questionsandspan_partial.Measured
RTX 5080, Linux (proton-cachyos, vkd3d-proton 3.2.0), Series X 1.0.2.1, diagnostics build of
maind2a4bae+ #185 + #436, #462, #440, #515, #514, #493 (+#336), #431, #259, #177, #151, story mode byVICTORY_KEYS. Before: the same stack without this change.In the world, 90 % of spans (about 21,000 of 23,000 per frame) reach view memory (the title's big GPU heap of physical-page views, which cannot be write-watched), so most ranges there still ask one by one. Guarding view memory per span, but only the blocks the ranges cover, is the next step. Bytes copied whole (not watched) were 0.85–1.0 GB per world frame in this run against 1–81 MB in the run before; not explained yet.
Tests
New
directly_indexed_srvs_of_neighbouring_buffers_ask_once_per_submission: 8 title buffers side by side in one write-watched allocation, each with its own host copy and a view; one question per submission with this change, 8 without it (fails on #185 alone), and each view reads the title's latest value. #185's other coherency tests pass on the GPU (vkd3d-proton,VICTORY_PC_DXCset).cargo clippyreports nothing new.Related
watch::writes;writes_splitdoes the same for spans.Batchrefreshes (asking about the untouched middle of a big range).AI-assisted (Claude Code).
🤖 Generated with Claude Code
@aycow on GitHub · 2026-11-24 06:31 UTC · original
@desplmfao Thanks for porting the cross-shadow batching and splitting out the Wine fix. Your matched report shows 110,864 → 4,112 write-watch questions and 662 → 22 ms per world frame from batching on top of the Wine fix. The 2.87 → 2.73 s frame interval is within the reported run spread.
If you push the port, please point me to its exact head. I can review the shared reservation proof, clipped ranges, per-shadow journal observations, remaps and pending GPU writes, and test it independently on Windows. For the remaining frame cost, could we hold the scene, stack and presentation window fixed and add aggregate timings for direct-SRV range construction, actual fill and fallback bytes, total submit preparation, queue wait/GPU intervals and post-fence copyback? Separate runs for timing and for attribution would make the comparison easier to interpret.
@desplmfao on GitHub · 2026-11-24 06:35 UTC · original · edited 2026-11-24 06:37 UTC
Thanks. The port is up as a PR against your branch: https://github.com/aycow/VIctory/pull/2 (head
9131c10, branchdesplmfao:perf/shared-spans). It sits on your1efd438plus the Wine fix (9e94c21, https://github.com/aycow/VIctory/pull/1), since without that fix no reservation is private under Wine and the sharing never triggers. The port itself is the one commit9131c10:Shadow::update_rangessplit intoready(clip + pending GPU writes excluded) andupdate_ready, plusfloor(yourwatch_floor) andanswered(update_watchedafter a shared answer).refresh_direct_srvscollects every copy's ready ranges;refresh_acrosssorts them by address and lets ranges of several copies inside one live private reservation, less than 1 MiB apart, share onegrouped_writesquestion with the oldest floor among them. Everything else goes through each copy'supdate_readyunchanged. The last reservation lookup is reused while ranges stay inside it.directly_indexed_srvs_of_neighbouring_copies_share_a_question(8 copies in one watched reservation): passes, and fails withVICTORY_NO_SHARED_SPANS=1; all 12 coherency tests pass here on vkd3d-proton withVICTORY_PC_DXCset.On the remaining frame cost: agreed, and the first timing run already narrows it. With the port, per world frame the copies themselves (
Shadow::copy, ~7,800 calls) take ~22 ms and all ofcopy_stale~20 ms, while the direct-SRV refresh as a whole takes 2.8–4.0 s of a ~3.3 s frame, so nearly all of it is range construction and planning before any fill. I've added per-phase timers (snapshot, visit/uncovered,ready,refresh_across,update_ready, allocation lookups) and will post timing-only runs separately from attribution runs, same scene, input and window.AI-assisted (Claude Code).
@desplmfao on GitHub · 2026-11-24 06:39 UTC · original
Closing: this was built on #185's first two commits and #462 (closed). The same idea, ported onto #185 as it is now, is https://github.com/aycow/VIctory/pull/2 against #185's branch (stacked on the Wine fix https://github.com/aycow/VIctory/pull/1). Discussion and timing follow-ups continue there.
AI-assisted (Claude Code).
Pull request closed