watch: VICTORY_GUARD_PEEK, the guards' notes read from atomic bit mirrors (#8) #125
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!125
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-125"
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?
@Elsupremo20 on GitHub · 2026-11-30 15:54 UTC · original
Elsupremo20:guard-peek→main· +160 −9 · 1 files · 47 commits · closed without mergingFollow-up to #8, as suggested there:
guard's first look andpublishonly read the guards'clean,absentandheldnotes, yet both took theGUARDSlock to do it. This lets them read atomic mirrors of those three sets instead, so the lock is only taken to change something.What changes
Guards::clean,absentandheldare made withBlocks::mirrored: everyinsert/removealso sets/clears a bit in aBits(CLEAN_BITS,ABSENT_BITS,HELD_BITS). They are still only changed under the lock, with the sets.VICTORY_GUARD_PEEK=1:guardreadsABSENT_BITS(PROTECTEDis read first, as before);guard's first look (the "all clean, nothing beside, nothing unsettled" early return, and the list of absent-and-not-held blocks to ask Windows about) reads the bits.unsettledis checked before and after the clean bits: a fault settles by taking the clean bit, then clearingOPENING's, so a reader that seesOPENINGclear and then the clean bit sees it taken;publishsetsPUBLISHEDfrom the bits and then re-checks (clean/held still set, nothing beside, nothing unsettled), clearing it again if the block was taken or opened meanwhile.Blocks::removeclears the mirror bit before the caller clearsPUBLISHED, so either the re-check or the remover's clear wins.guard_locked's work after its first look is split out asguard_unsure(no behaviour change); both paths call it. The batched path (guard_ahead) still runs entirely under the lock.VICTORY_GUARD_PEEK=abturns it on and off every ten seconds and logs each turn, for an A/B in one run.Tests
askings_that_peek_tell_the_same: the single-thread view tests (a_write_through_another_view_is_reported_at_the_guarded_one,a_write_opens_the_view_it_goes_through,bits_go_at_every_view, ...) with peeking askings, with faults under the lock and without it.no_write_is_lost_when_askings_peek: the many-askers harness (writes_to_views_are_not_lost_peeking, apeekingmask besideunlocked) with peeking on every thread and on half of them; one view and three, resting blocks, faults that take no lock, and batched guards.victory-gpulib suite passes (473 passed, 37 ignored), and clippy is clean.Measurement
foxhound
mainat7281175(v0.8.2) plus this commit, release build. i7-13700K, RTX 4070 12 GB, 32 GB RAM, Windows 11, driver 610.88. Series S, DLSS Quality, frame generation x2. One run of 30 minutes of normal play in the open world withVICTORY_GUARD_PEEK=ab, so both sides saw the same places. Frame-rate lines that straddle a turn change were left out, and so were loading spikes over 200 ms.To count the lock waits in a release build I made
waitedcount outsidediagnosticsand loggedWAITSper frame at each turn change (a local change, not in this PR; the same counters as theguardspart oflock_waitsin diagnostics builds).GUARD_PEEKoffGUARD_PEEKonGUARDSlockGUARDSlockBy draws per frame (fps, mean of 5 s lines): 2,000–6,000: 16.2 → 17.2; 6,000–8,000: 13.0 → 13.1; over 8,000: 10.9 → 11.1. The "on" half had slightly lighter scenes on average, so part of the fps gap may be the scenes; the lock counts are per frame and do not depend on that as much.
What is left of the
GUARDSwait (23 ms a frame here) comes from the users of the lock this does not touch: the title's write faults that still go the locked way,guard's protect loop after its first look, andguard_ahead.An earlier, shorter run of the same A/B without DLSS (24 minutes, no lock counter) gave preparing 68.1 → 62.5 ms (median) and fps 10.1 → 10.3, i.e. the same direction, smaller. On trustno1-coder/VIctory-NVIDIA at 63b902f (before v0.8's lock changes) the same change had cut the refresh threads' time in
guardby about a fifth outdoors.All numbers are from one PC; I'd be glad to see how it measures on yours.
🤖 Generated with Claude Code
@readmet3xt-lab on GitHub · 2026-12-01 01:34 UTC · original
Thanks. On hold only for order: it is off by default, and
watch.rsis changed by several PRs being tested for the next release, so this will need a rebase onto main once they land. Please add theabcomparison on the current main with the rebase.Main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), so a follow-up has to start from the current main, or this branch be rebased onto it.
@readmet3xt-lab on GitHub · 2026-12-01 01:36 UTC · original
One more note: GitHub closed this pull request by itself when main's history was rewritten, and it cannot be reopened. That is not a rejection. The points above still apply; please open a new pull request from the current main when you have them.
Pull request closed