watch: interval-skip absent placeholders, coalesce VirtualProtect runs, O(dirty) re-arm #345
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!345
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-345"
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?
@Vladimir-Human on GitHub · 2026-11-26 10:36 UTC · original
Vladimir-Human:perf/watch-guard-sparse-dirty→main· +2296 −255 · 2 files · 1 commits · openSummary
Ports the
watch::guardsparse interval-skip, placeholder-hole skip,O(dirty)re-arm, and coalesced region-guidedVirtualProtectoptimizations fromfxceless/victory-fork#1279(addressingfxceless/victory-fork#1238) ontoAnyXboxX'sthird_party/victory/crates/victory-gpu/src/{watch.rs,inplace.rs}while preserving all existing AnyXboxX / Neptune concurrency and lock-free improvements (RwLockonJOURNAL/GUARDS, lock-freeCLEAN/ABSENT/PARTS/WHOLE/SUBS,watch_4k/stale_mask,ask_once_quiet,quiet_back,HOT/VICTORY_GUARD_HOT,VICTORY_GUARD_OPEN_AHEAD, and shardedMAPPING).What changed
Coalesced interval tracking & placeholder-hole skip (
watch.rs):BTreeSet<usize>sets inGuards(protected,clean,absent,aliased) with disjoint coalesced half-open intervals (BlockSet) plusplaceholder_absent: BlockSet.ABSENTtable to distinguishABSENT_NONE = 0,ABSENT_ORDINARY = 1, andABSENT_PLACEHOLDER = 2(with chunkedabsent_set_range/clean_set_range), allowing both the lock-free fast path andguard_lockedto skipNtQueryVirtualMemory(MemoryRegionInformationEx)-confirmedMEM_RESERVE_PLACEHOLDERholes with 0VirtualQueryand 0VirtualProtectsyscalls untiltitle_memory_remapped(VICTORY_ABSENT_ONCE=0opts out; ordinary non-placeholderMEM_RESERVE/SEC_RESERVEholes remainABSENT_ORDINARYand still probe viaVirtualQueryso silent commits are detected immediately).writes()checksguarded && known_view(first * PAGE)(lock-freeCLEAN/ABSENTfirst, thenguards_read()) to avoid wasted failingGetWriteWatchcalls on known views.guards_read()usesO(log K)g.clean.covers(first, last);writing()usesO(log K)intersects;title_memory_written()usescount_in;title_memory_remapped()usestake_range/remove_range(removing the duplicatealiasedloop).INSTALLED: AtomicBooland write-lock re-check after read-to-write lock upgrade inguard()to prevent TOCTOU races with concurrenttitle_memory_remapped.O(dirty)re-arm,protected ∩ absent == ∅, coalesced region-guidedVirtualProtect, & batched alias lookups (watch.rs,inplace.rs):guard_lockedskips contiguouscleanand confirmedplaceholder_absentintervals inO(log K), marks already-protectedblocks (e.g. alias-guarded)cleaninO(dirty)with 0VirtualProtectcalls (preservingVICTORY_GUARD_HOT), and coalesces adjacent unprotected dirty blocks into contiguous runs.note_protectedclearsabsent,placeholder_absent, and lock-freeABSENTsoprotected ∩ absent == ∅holds by construction;handle_protect_failurereturns exclusiveendand bothprotect_herefallback loops advance past it.protect_here,protect_alias_run, andunprotect_run_osissue one coalescedVirtualProtectper contiguous run withVirtualQuery-guided OS VM region fallback (unprotect_run_osskipsinfo.State != MEM_COMMITgaps without per-block failures), all guarded withchecked_mul(BLOCK).inplace::aliases_in_rangeandinplace::aliases_for_blocks(keepinginplace::pages_offorstays_openandours_through), a zero-allocation single-block unaliased fast path inopenfor VEH write faults, and strict lock-freeCLEANclearing before anyPAGE_READWRITEtransition.Unit, regression, stress, & deterministic benchmark tests (
watch.rs):block_set_interval_invariantssparse_placeholder_gaps_are_skipped_without_probing_or_protectingcontiguous_runs_coalesce_guard_and_unguard_syscallsaliased_views_coalesce_protect_open_and_o_dirty_rearmordinary_reserve_is_not_placeholder_and_silent_commit_is_detectedprotected_and_absent_sets_remain_disjoint_after_protectunprotect_run_os_skips_uncommitted_gap_without_per_block_failuresconcurrent_writers_and_guard_readers_stay_coherentbenchmark_guard_coalesce_and_absent_skipMeasurements (
--release, live Windows placeholders & aliased views)VirtualProtectcallsVirtualQuerycallsVirtualProtectcallsVerification
cargo test -p victory-gpu -- watch: 24 passed; 0 failed; 0 ignoredcargo test -p victory-gpu --features diagnostics -- watch: 24 passed; 0 failedcargo test -p victory-gpu -- inplace: 6 passed; 0 failedcargo test --release -p victory-gpu -- watch::tests::benchmark_guard_coalesce_and_absent_skip --exact --nocapture: PASScargo clippy -p victory-gpu --all-targets: 0 new warnings in modified codecargo run -p xtask -- policy --staged: asset policy: 2 files okPorted from
fxceless/victory-fork#1279(fxceless/victory-fork#1238).edc6eaef45to6f6ef4c8cf@Vladimir-Human on GitHub · 2026-11-26 16:36 UTC · original
Rebased onto latest
main(ce0f90f->6f6ef4c, preserving upstream715f7b3page_writes_mode/page_writes_testsandee8b92einplace.rscleanly) with safety fixes and bisect controls:Changes
placeholder_skip_enabled()is now OFF by default (opt-in only viaVICTORY_PLACEHOLDER_SKIP=1), while retainingO(1)-per-OS-regionuncommitted_end()region skipping.PAGE_READWRITErestoration intitle_memory_remapped: Fixed a race caught by our multi-threaded remap + write-fault stress test whereguard()could protect newly mapped pages betweenMapViewOfFile3andtitle_memory_remapped(), leaving OSPAGE_READONLYorphaned whentitle_memory_remappedremoved blocks fromg.protected.title_memory_remappednow restoresPAGE_READWRITEviaunprotect_run_os_withfor evicted guarded runs.OnceLock<bool>diagnostic bisect switches + VEH pre-warming:VICTORY_PLACEHOLDER_SKIP=0|1(default0)VICTORY_WATCH_COALESCE=0|1(default1;0uses per-blockVirtualProtect)VICTORY_WATCH_ALIAS_BATCH=0|1(default1;0falls back toinplace::views_between+pages_of, clearing lock-freeCLEANacross aliases before opening primary blocks)VICTORY_WATCH_SINGLE_LOCK=0|1(default1;0falls back to unconditionalinstall()+guards())install()pre-warmswatch_coalesce()andwatch_alias_batch().Verification (on
ce0f90f->6f6ef4c)cargo xtask policy:asset policy: 214 files ok.cargo clippy --no-deps -p victory-gpu --lib --tests(default &--features diagnostics): 0 warnings inwatch.rs/inplace.rs.VICTORY_D3D12_DEBUG=1 cargo test --manifest-path third_party/victory/Cargo.toml -p victory-gpu --lib -- --test-threads=1:watch:::29 passed; 0 failed(page_writes_testsincluded),inplace:::6 passed; 0 failed.victory-gpu --lib: default251 passed; 3 failed (pre-existing main failures in descriptor::host & indirect); 4 ignored;--features diagnostics:264 passed; 3 failed (same 3 pre-existing); 4 ignored.@Vladimir-Human on GitHub · 2026-11-26 19:19 UTC · original
Noting that #409 (
37d4686) replacedthird_party/victorywith the combinedavatarmanz + cool_foxbase, putting this branch inCONFLICTING.The equivalent clean PR is open at
fxceless/victory-fork#1279; happy to re-port onto37d4686+once#409settles if you want it here.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.