Refreshes: a submission guards the view memory it refreshes in one go #80
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/readmet3xt-lab--foxhound!80
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-80"
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?
@mgrein on GitHub · 2026-11-30 06:22 UTC · original
mgrein:batched-guards→main· +160 −12 · 3 files · 2 commits · merged 2026-11-30 07:57 UTCWhat's slow
Each refresh of a host copy of view memory guards its own range (
watch::guardfromwrites_into): 3 rounds of the guards' lock (GUARDS), plus one more topublish. This runs on the submitting thread and on the refresh helpers beside it, and they mostly wait for each other on that lock.Counted on a Ryzen 5 5600X with an RTX 4070 (Series S profile, DLSS, frame generation 2x), per frame:
Mutex::lock_contendedunderwatch::guardsThe fix
After its one asking, a submission guards every range its steps refresh of guarded copies in one go, on its own thread (
watch::guard_ahead, called fromHost::submitright afterask_once):guard(now split intoguard+guard_locked, which takes the held lock and hands it back), over the merged ranges, with them held (Askings::hold_or_all).publish).The refreshes then find those ranges published and answer from the journal without a lock. A block written after the batch (a title fault, our own write, a remap) is no longer published, so its range goes through its own
writes→guardas before. Nothing can be seen later than before, and the batch only does early what each refresh would have done.The ranges are the exact refresh ranges of guarded copies (
guarded_refreshes: theStep::Refreshes whose copy isGUARDED), not the copies' whole spans, so no extra blocks get protected.VICTORY_GUARD_BATCH=0turns it off.A second, small commit caches
wide_threads(): it calledavailable_parallelism(a question to Windows) several times per batch of refreshes, about 0.6 % of the submitting thread.Same idea as upstream VIctory's #3585 (one round of the guard lock per refresh batch), written for this tree's
writes/guardpath.Measured
Ryzen 5 5600X (6C/12T), RTX 4070 12 GB, 32 GB DDR4-3600, Windows 11.
victory run --execute --console series-swith the same switches (DLSS Quality, frame generation 2x), the same save and scripted input, 330 s; numbers over the last 3 minutes. Release builds, then thedistprofile with-C target-cpu=x86-64-v3:fafa3adf), releaseSubmitting thread profile (1 ms samples, 40 s), main → this PR:
lock_contendedwatch::writesShadow::update_freeguard_ahead(new)The same change on trustno1-coder/VIctory-NVIDIA took guards by refreshes from 156 to 60 a frame (20 → 7 ms), publishing from 5 to 1 ms, and frame p95 from 70.0 to 66.3 ms. A run there with
VICTORY_REFRESH_CHECK=1found no stale copy.Tests
watch::many_askers_tests::no_write_to_views_is_lost_with_batched_guards. The existing views stress test (8 writer threads over a pool and several views of the same pages, writes beside the guards, our own writes, faults that take no lock) runs with a batch of guards (guard_aheadof the asked range and another) before half the askings, for 1 and 3 views, resting and not.cargo test -p victory-gpu --libpasses (468 passed, 37 ignored).cargo clippy -p victory-gpu --all-targets -- -D warningsis clean, with and without--all-features.AI-assisted (Claude), tested on the hardware above with my own copy of the title.
🤖 Generated with Claude Code