gpu: sync_heaps walks regions with VirtualQuery instead of a kernel read per page #3356

Closed
borosf wants to merge 3 commits from upstream-pr/3356 into main
borosf commented 2026-11-26 20:21:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T20:21:51Z.


What

descriptor::sync_heaps probed every 64 KiB page of a written heap range with a ReadProcessMemory call just to test mapped-ness (the title unmaps heap pages too). It now walks the range once with VirtualQuery: a page is synced iff its region is MEM_COMMIT and not PAGE_NOACCESS/PAGE_GUARD — exactly the pages the kernel read fails on, so the synced slot set is identical. Fewer kernel calls (one per region instead of one per page) and one sync_slots call per region instead of per page.

Claimed on #1633 (comment 7202563021).

Measurement (Windows 11 x64, Intel Arc B580, synthetic VirtualAlloc only, no game data)

New test descriptor::tests::a_region_walk_classifies_pages_like_per_page_reads asserts the page sets are identical (including a PAGE_GUARD page in the middle, excluded by both) and prints:

cargo test -p victory-gpu --lib --locked -- --test-threads=1 --exact descriptor::tests::a_region_walk_classifies_pages_like_per_page_reads --nocapture
256 MB, 4095 pages: per-page reads 5.167ms, region walk 648.1µs   (8x)

At FIND-31's ~13,624 pages opened per frame, that is ~17 ms → ~2 ms per frame on the probe alone, plus fewer sync_slots lock acquisitions.

Verification

  • cargo test -p victory-gpu --lib --locked --no-fail-fast — 230 passed, 2 failed: only the known B580 baseline (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views, #1744/#1829)
  • cargo clippy --workspace --all-targets --locked -- -D warnings and --all-features — clean
  • fmt gate: descriptor.rs 83 hunks vs 94 at the origin/main baseline (decreased, none added)
  • cargo xtask policy — ok

Synthetic tests only; no game data used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5516651453 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356). Originally posted by [borosf](https://github.com/borosf) on 2026-11-26T20:21:51Z. --- ## What `descriptor::sync_heaps` probed every 64 KiB page of a written heap range with a `ReadProcessMemory` call just to test mapped-ness (the title unmaps heap pages too). It now walks the range once with `VirtualQuery`: a page is synced iff its region is `MEM_COMMIT` and not `PAGE_NOACCESS`/`PAGE_GUARD` — exactly the pages the kernel read fails on, so the synced slot set is identical. Fewer kernel calls (one per region instead of one per page) and one `sync_slots` call per region instead of per page. Claimed on #1633 (comment 7202563021). ## Measurement (Windows 11 x64, Intel Arc B580, synthetic VirtualAlloc only, no game data) New test `descriptor::tests::a_region_walk_classifies_pages_like_per_page_reads` asserts the page sets are identical (including a `PAGE_GUARD` page in the middle, excluded by both) and prints: ``` cargo test -p victory-gpu --lib --locked -- --test-threads=1 --exact descriptor::tests::a_region_walk_classifies_pages_like_per_page_reads --nocapture 256 MB, 4095 pages: per-page reads 5.167ms, region walk 648.1µs (8x) ``` At FIND-31's ~13,624 pages opened per frame, that is ~17 ms → ~2 ms per frame on the probe alone, plus fewer `sync_slots` lock acquisitions. ## Verification - `cargo test -p victory-gpu --lib --locked --no-fail-fast` — 230 passed, 2 failed: only the known B580 baseline (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`, #1744/#1829) - `cargo clippy --workspace --all-targets --locked -- -D warnings` and `--all-features` — clean - fmt gate: descriptor.rs 83 hunks vs 94 at the origin/main baseline (decreased, none added) - `cargo xtask policy` — ok Synthetic tests only; no game data used.
Dukestar69 commented 2026-11-26 20:29:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T20:29:59Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Replacing per-64 KiB-page ReadProcessMemory probes in sync_heaps with a VirtualQuery region walk (MEM_COMMIT and neither PAGE_NOACCESS nor PAGE_GUARD) preserves exact page classification while cutting syscall overhead dramatically.
  • cargo test -p victory-gpu --lib descriptor:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: 22 passed, 0 failed (including a_region_walk_classifies_pages_like_per_page_reads).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6080177229 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356#pullrequestreview-6080177229). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T20:29:59Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Replacing per-64 KiB-page `ReadProcessMemory` probes in `sync_heaps` with a `VirtualQuery` region walk (`MEM_COMMIT` and neither `PAGE_NOACCESS` nor `PAGE_GUARD`) preserves exact page classification while cutting syscall overhead dramatically. - `cargo test -p victory-gpu --lib descriptor:: -- --skip dynamic_slots_are_held_until_released --test-threads=1`: 22 passed, 0 failed (including `a_region_walk_classifies_pages_like_per_page_reads`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 20:38:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:38:13Z.

Review: CHANGES_REQUESTED


Tested locally merged onto origin/main (63bcca43) at PR head eace224f (Windows 11 x64, NVIDIA RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1).

Blocking issue: end - start underflow in sync_heaps() when a placed heap is not 64 KiB-aligned

In crates/victory-gpu/src/descriptor.rs (L190-L204), sync_heaps() rounds at down to a 64 KiB boundary (let mut at = from & !(page_size - 1);) and then steps by VirtualQuery's RegionSize, which has 4 KiB OS-page granularity:

let mut at = from & !(page_size - 1);
while at < to {
    ...
    let next = (info.BaseAddress as usize + info.RegionSize).max(at + 1).min(to);
    if info.State == MEM_COMMIT && info.Protect & (PAGE_NOACCESS | PAGE_GUARD) == 0 {
        let (page, end) = (at.max(from), next.min(to));
        let (first, last) = ((page as u64 - start) / step, (end as u64 - start).div_ceil(step));

If a placed descriptor heap starts past a 64 KiB boundary (e.g. start = pool + 0x2000, so from = pool + 0x2000 and at = pool) and [pool .. pool + 0x1000) is a separate committed 4 KiB region (for instance, [pool + 0x1000 .. pool + 0x2000) is decommitted or has a different protection), VirtualQuery(pool) returns next = pool + 0x1000 < start. Then end = next.min(to) = pool + 0x1000 < start, so (end as u64 - start) underflows:

  • In debug builds: panics immediately. Reproduced locally via a placed shader-visible heap at pool + 0x2000 with [pool + 0x1000 .. pool + 0x2000) decommitted:
    panicked at crates\victory-gpu\src\descriptor.rs:204:72: attempt to subtract with overflow
  • In release builds: wraps end - start near u64::MAX, clamping last to heap.desc.count and walking the entire descriptor heap from an unrelated preceding region.
  • On pristine origin/main (63bcca43), the same test passes because each step advances by a full 64 KiB page_size, keeping page + page_size > from >= start.

Verified fix

VirtualQuery already rounds any address down to its containing OS region's BaseAddress, so starting directly at let mut at = from; (and dropping the unused page_size local) guarantees next > at >= from >= start while also avoiding querying memory before from. Using (info.BaseAddress as usize).saturating_add(info.RegionSize) also avoids any high-address overflow.

Verified locally with let mut at = from;: the unaligned-heap reproducer plus all descriptor::tests:: pass (9/9 on RTX 5090 and 9/9 on WARP), keeping the ~8.5x region-walk speedup (4.56 ms -> 538.6 µs on 256 MB). cargo xtask policy (191 files ok) and strict clippy (default + --all-features) are clean. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6080264906 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356#pullrequestreview-6080264906). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T20:38:13Z. **Review:** CHANGES_REQUESTED --- Tested locally merged onto `origin/main` (`63bcca43`) at PR head `eace224f` (Windows 11 x64, NVIDIA RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`). ### Blocking issue: `end - start` underflow in `sync_heaps()` when a placed heap is not 64 KiB-aligned In `crates/victory-gpu/src/descriptor.rs` (`L190-L204`), `sync_heaps()` rounds `at` down to a 64 KiB boundary (`let mut at = from & !(page_size - 1);`) and then steps by `VirtualQuery`'s `RegionSize`, which has 4 KiB OS-page granularity: ```rust let mut at = from & !(page_size - 1); while at < to { ... let next = (info.BaseAddress as usize + info.RegionSize).max(at + 1).min(to); if info.State == MEM_COMMIT && info.Protect & (PAGE_NOACCESS | PAGE_GUARD) == 0 { let (page, end) = (at.max(from), next.min(to)); let (first, last) = ((page as u64 - start) / step, (end as u64 - start).div_ceil(step)); ``` If a placed descriptor heap starts past a 64 KiB boundary (e.g. `start = pool + 0x2000`, so `from = pool + 0x2000` and `at = pool`) and `[pool .. pool + 0x1000)` is a separate committed 4 KiB region (for instance, `[pool + 0x1000 .. pool + 0x2000)` is decommitted or has a different protection), `VirtualQuery(pool)` returns `next = pool + 0x1000 < start`. Then `end = next.min(to) = pool + 0x1000 < start`, so `(end as u64 - start)` **underflows**: - In debug builds: panics immediately. Reproduced locally via a placed shader-visible heap at `pool + 0x2000` with `[pool + 0x1000 .. pool + 0x2000)` decommitted: `panicked at crates\victory-gpu\src\descriptor.rs:204:72: attempt to subtract with overflow` - In release builds: wraps `end - start` near `u64::MAX`, clamping `last` to `heap.desc.count` and walking the entire descriptor heap from an unrelated preceding region. - On pristine `origin/main` (`63bcca43`), the same test passes because each step advances by a full 64 KiB `page_size`, keeping `page + page_size > from >= start`. ### Verified fix `VirtualQuery` already rounds any address down to its containing OS region's `BaseAddress`, so starting directly at `let mut at = from;` (and dropping the unused `page_size` local) guarantees `next > at >= from >= start` while also avoiding querying memory before `from`. Using `(info.BaseAddress as usize).saturating_add(info.RegionSize)` also avoids any high-address overflow. Verified locally with `let mut at = from;`: the unaligned-heap reproducer plus all `descriptor::tests::` pass (9/9 on RTX 5090 and 9/9 on WARP), keeping the ~8.5x region-walk speedup (`4.56 ms` -> `538.6 µs` on 256 MB). `cargo xtask policy` (191 files ok) and strict clippy (default + `--all-features`) are clean. Synthetic tests only.
borosf commented 2026-11-26 20:45:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T20:45:33Z.


Fixed at f38b294 with exactly your fix: the walk now starts at from itself (readable_regions, extracted as a testable helper) — VirtualQuery rounds down to the containing region's base, so every next is past at >= from >= start, and BaseAddress.saturating_add(RegionSize) removes the high-address overflow. The old round-down-to-64-KiB start is gone.

Regression test descriptor::tests::readable_regions_of_an_unaligned_start_never_reach_before_it: decommits a 4 KiB page inside a pool and walks from pool + 8192 (unaligned, past the hole) — asserts the first region starts at from and every range is within [from, to) with end > start. The aligned-start case asserts the hole is skipped. On the old code this input is the debug-build attempt to subtract with overflow at the slot math.

Re-verified at f38b294 (Windows 11 x64, B580): both new tests pass; full victory-gpu lib 231 passed / 2 failed (only the known #1744/#1829 baseline); workspace clippy clean -D warnings default + --all-features; fmt gate 84 hunks vs 94 baseline; cargo xtask policy ok. Speedup kept: 256 MB probe 4.80 ms per-page reads vs 786 µs region walk this run (~6-8x). Synthetic tests only; no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7203043065 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356#issuecomment-7203043065). Originally posted by [borosf](https://github.com/borosf) on 2026-11-26T20:45:33Z. --- Fixed at `f38b294` with exactly your fix: the walk now starts at `from` itself (`readable_regions`, extracted as a testable helper) — VirtualQuery rounds down to the containing region's base, so every `next` is past `at >= from >= start`, and `BaseAddress.saturating_add(RegionSize)` removes the high-address overflow. The old round-down-to-64-KiB start is gone. Regression test `descriptor::tests::readable_regions_of_an_unaligned_start_never_reach_before_it`: decommits a 4 KiB page inside a pool and walks from `pool + 8192` (unaligned, past the hole) — asserts the first region starts at `from` and every range is within `[from, to)` with `end > start`. The aligned-start case asserts the hole is skipped. On the old code this input is the debug-build `attempt to subtract with overflow` at the slot math. Re-verified at `f38b294` (Windows 11 x64, B580): both new tests pass; full `victory-gpu` lib 231 passed / 2 failed (only the known #1744/#1829 baseline); workspace clippy clean `-D warnings` default + `--all-features`; fmt gate 84 hunks vs 94 baseline; `cargo xtask policy` ok. Speedup kept: 256 MB probe 4.80 ms per-page reads vs 786 µs region walk this run (~6-8x). Synthetic tests only; no game data.
fuzeofficlal commented 2026-11-26 21:11:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T21:11:16Z.

Review: APPROVED


Thanks for the quick turnaround — re-verified at b1349a7f merged onto origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1):

  • readable_regions (crates/victory-gpu/src/descriptor.rs:175-198) starting directly at from with (info.BaseAddress as usize).saturating_add(info.RegionSize) completely resolves both the unaligned placed-heap (end - start) underflow and high-address overflow.
  • Re-ran the exact end-to-end placed-heap reproducer (start = pool + 0x2000 with [pool + 0x1000 .. pool + 0x2000) decommitted, calling sync_heaps() directly) plus high-address readable_regions(usize::MAX - 4096, usize::MAX) and all descriptor::tests::*: 10/10 pass on RTX 5090 and 10/10 pass on WARP, keeping the ~10.8x probe speedup (4.45 ms -> 413.7 µs over 256 MB / 4,095 pages).
  • cargo xtask policy (191 files ok) and cargo clippy --locked -p victory-gpu --tests -- -D warnings (both default and --features diagnostics) are clean.

One tiny non-blocking nit for a quick cleanup if you touch this again: at crates/victory-gpu/src/descriptor.rs:168-200, inserting readable_regions between the existing #[cfg(windows)] attribute (line 168) and pub(crate) fn sync_heaps() (line 200) left duplicate #[cfg(windows)] attributes (and sync_heaps's doc comment) on readable_regions while leaving sync_heaps() without #[cfg(windows)] (Windows CI is unaffected, though non-Windows cargo check of victory-gpu will see it).

LGTM!

<!-- greyfinch-sync:Marvisak/VIctory:review:6080515082 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356#pullrequestreview-6080515082). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T21:11:16Z. **Review:** APPROVED --- Thanks for the quick turnaround — re-verified at `b1349a7f` merged onto `origin/main` (`63bcca43`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`): - `readable_regions` (`crates/victory-gpu/src/descriptor.rs:175-198`) starting directly at `from` with `(info.BaseAddress as usize).saturating_add(info.RegionSize)` completely resolves both the unaligned placed-heap `(end - start)` underflow and high-address overflow. - Re-ran the exact end-to-end placed-heap reproducer (`start = pool + 0x2000` with `[pool + 0x1000 .. pool + 0x2000)` decommitted, calling `sync_heaps()` directly) plus high-address `readable_regions(usize::MAX - 4096, usize::MAX)` and all `descriptor::tests::*`: **10/10 pass on RTX 5090 and 10/10 pass on WARP**, keeping the ~10.8x probe speedup (`4.45 ms` -> `413.7 µs` over 256 MB / 4,095 pages). - `cargo xtask policy` (`191 files ok`) and `cargo clippy --locked -p victory-gpu --tests -- -D warnings` (both default and `--features diagnostics`) are clean. One tiny non-blocking nit for a quick cleanup if you touch this again: at `crates/victory-gpu/src/descriptor.rs:168-200`, inserting `readable_regions` between the existing `#[cfg(windows)]` attribute (line 168) and `pub(crate) fn sync_heaps()` (line 200) left duplicate `#[cfg(windows)]` attributes (and `sync_heaps`'s doc comment) on `readable_regions` while leaving `sync_heaps()` without `#[cfg(windows)]` (Windows CI is unaffected, though non-Windows `cargo check` of `victory-gpu` will see it). LGTM!
KainanP commented 2026-11-27 12:31:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-27T12:31:15Z.


Contention numbers for the SHADER_HEAPS wait in #3425, this PR (b1349a7) against its base 63bcca4:

base #3356
sync_heaps, RTX, 12 runs 9.6 ms 13.4 ms (+40 %)
title-thread wait per frame 49.5 ms 69.1 ms
game-shaped heap (1,245,184 slots, pages past the cap too), 5 runs 7.9 ms 14.2 ms
Intel UHD (a78b), 5 runs 10.1 ms 15.8 ms

It was slower in every setup. My guess at the cause: the bench heap is a MEM_WRITE_WATCH allocation like the title's, and our guards split it into many small regions with different protections. VirtualQuery is slow on such pools (watch::runtime_pages notes "asking VirtualQuery costs milliseconds in the runtime's big pools"). a_region_walk_classifies_pages_like_per_page_reads times a plain committed allocation, which has none of this. No views were lost or stale, and the PR's tests pass. The full victory-gpu suite on RTX fails only the two tests that main also fails here.

Bench: sync_contention_bench (#[ignore]d; commit f34bcfb8, cherry-picks onto any tree). A placed, write-watched view heap of 2^20 slots (the host heap caps it at 934,464 here). Each frame, one thread rewrites 200 random 64 KiB pages (50 changed records each) and runs one sync_heaps, while 5 title threads write a placed-buffer SRV every 20 µs into pages of their own. "Wait" is the title threads' time in view writes beyond the uncontended 2–3 µs, summed per frame. Release build, RTX 4060 Laptop, runs interleaved with the base, medians of 30 frames per run. The bench also checks that every view written before a sync is the slot's view address after it, and that every slot is right after a final quiet sync.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218339007 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356#issuecomment-7218339007). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T12:31:15Z. --- Contention numbers for the `SHADER_HEAPS` wait in #3425, this PR (`b1349a7`) against its base `63bcca4`: | | base | #3356 | |---|---|---| | `sync_heaps`, RTX, 12 runs | 9.6 ms | **13.4 ms** (+40 %) | | title-thread wait per frame | 49.5 ms | 69.1 ms | | game-shaped heap (1,245,184 slots, pages past the cap too), 5 runs | 7.9 ms | 14.2 ms | | Intel UHD (a78b), 5 runs | 10.1 ms | 15.8 ms | It was slower in every setup. My guess at the cause: the bench heap is a `MEM_WRITE_WATCH` allocation like the title's, and our guards split it into many small regions with different protections. `VirtualQuery` is slow on such pools (`watch::runtime_pages` notes "asking `VirtualQuery` costs milliseconds in the runtime's big pools"). `a_region_walk_classifies_pages_like_per_page_reads` times a plain committed allocation, which has none of this. No views were lost or stale, and the PR's tests pass. The full `victory-gpu` suite on RTX fails only the two tests that `main` also fails here. Bench: [`sync_contention_bench`](https://github.com/KainanP/VIctory/blob/bench/sync-heaps-contention/crates/victory-gpu/src/descriptor/sync_bench.rs) (`#[ignore]`d; commit `f34bcfb8`, cherry-picks onto any tree). A placed, write-watched view heap of 2^20 slots (the host heap caps it at 934,464 here). Each frame, one thread rewrites 200 random 64 KiB pages (50 changed records each) and runs one `sync_heaps`, while 5 title threads write a placed-buffer SRV every 20 µs into pages of their own. "Wait" is the title threads' time in view writes beyond the uncontended 2–3 µs, summed per frame. Release build, RTX 4060 Laptop, runs interleaved with the base, medians of 30 frames per run. The bench also checks that every view written before a sync is the slot's view address after it, and that every slot is right after a final quiet sync. _AI use: Claude Code (Claude Opus 5.5)._
borosf commented 2026-11-27 13:12:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T13:12:00Z.


Closing this on @KainanP's contention numbers, which I accept over my own.

Their bench (sync_contention_bench, a placed write-watched view heap of 2^20 slots with title threads writing views during each sync_heaps) measured the change as a regression in every configuration: sync_heaps 9.6 → 13.4 ms on RTX, 7.9 → 14.2 ms on the game-shaped heap, 10.1 → 15.8 ms on Intel UHD, and title-thread wait 49.5 → 69.1 ms. That is not a disagreement about a noisy number; it is the same direction on four setups.

The cause is one the code already documents and my measurement missed: VirtualQuery costs milliseconds in the title's big pools, which are MEM_WRITE_WATCH allocations split into many small regions with differing protections. My timing test (a_region_walk_classifies_pages_like_per_page_reads) used a plain committed allocation, which has none of that structure — so it measured the one case where the region walk wins, and generalised from it. The 4.56 ms → 538 µs I reported was real for that allocation and irrelevant to the title.

For the record, since this PR also carried a genuine fix that should not be lost: the round-down-to-64-KiB start made end - start underflow when a placed heap began past a boundary, which panicked in debug and walked a whole heap from an unrelated region in release. #3429's report of it stands, and if a future PR wants the region walk it should keep (a) starting the walk at from rather than below it, and (b) using it only where the pool is not write-watched, with the per-page kernel read kept for the title's pools.

Thanks for the bench and for pushing back with numbers rather than impressions.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7219180752 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3356#issuecomment-7219180752). Originally posted by [borosf](https://github.com/borosf) on 2026-11-27T13:12:00Z. --- Closing this on @KainanP's contention numbers, which I accept over my own. Their bench (`sync_contention_bench`, a placed write-watched view heap of 2^20 slots with title threads writing views during each `sync_heaps`) measured the change as a **regression in every configuration**: `sync_heaps` 9.6 → 13.4 ms on RTX, 7.9 → 14.2 ms on the game-shaped heap, 10.1 → 15.8 ms on Intel UHD, and title-thread wait 49.5 → 69.1 ms. That is not a disagreement about a noisy number; it is the same direction on four setups. The cause is one the code already documents and my measurement missed: `VirtualQuery` costs milliseconds in the title's big pools, which are `MEM_WRITE_WATCH` allocations split into many small regions with differing protections. My timing test (`a_region_walk_classifies_pages_like_per_page_reads`) used a plain committed allocation, which has none of that structure — so it measured the one case where the region walk wins, and generalised from it. The 4.56 ms → 538 µs I reported was real for that allocation and irrelevant to the title. For the record, since this PR also carried a genuine fix that should not be lost: the round-down-to-64-KiB start made `end - start` underflow when a placed heap began past a boundary, which panicked in debug and walked a whole heap from an unrelated region in release. #3429's report of it stands, and if a future PR wants the region walk it should keep (a) starting the walk at `from` rather than below it, and (b) using it only where the pool is not write-watched, with the per-page kernel read kept for the title's pools. Thanks for the bench and for pushing back with numbers rather than impressions.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3356
No description provided.