Repository navigation
watch: interval-skip absent placeholders, coalesce VirtualProtect runs, O(dirty) re-arm - #345
Open
Vladimir-Human wants to merge 1 commit into
Open
Vladimir-Human wants to merge 1 commit into
Vladimir-Human wants to merge 1 commit into
Conversation
This was referenced Nov 26, 2026
Open
- Keep placeholder_skip_enabled() OFF by default (enabled only via VICTORY_PLACEHOLDER_SKIP=1) while keeping O(1)-per-OS-region skipping. - Add zero-overhead OnceLock bisect switches: VICTORY_PLACEHOLDER_SKIP, VICTORY_WATCH_COALESCE, VICTORY_WATCH_ALIAS_BATCH (restoring inplace::views_between), and VICTORY_WATCH_SINGLE_LOCK. - Restore PAGE_READWRITE (unprotect_run_os_with) in title_memory_remapped when removing guarded blocks so concurrent guard() between MapViewOfFile3 and title_memory_remapped never leaves orphaned PAGE_READONLY pages. - Preserve upstream page_writes_mode / page_writes_tests verbatim and add tests for silent placeholder re-detection, bisect switches, remap writability, and multi-threaded remap + write-fault stress.
Vladimir-Human
force-pushed
the
perf/watch-guard-sparse-dirty
branch
from
November 26, 2026 16:36
edc6eae to
6f6ef4c
Compare
Author
|
Rebased onto latest Changes
Verification (on
|
Author
|
Noting that #409 ( |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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).