Repository navigation
perf(gpu): read a heap sync batch's stale slots once a page, not once a slot - #640
Merged
pragyaangaur merged 1 commit intoNov 27, 2026
Merged
Conversation
… a slot mirror_synced_batch re-read every stale slot's record under self.made with its own ReadProcessMemory call, to catch a title thread that rewrote the slot. Under Wine each call is a kernel call of ~0.5 us: 39,100 of them took 18-21 ms alone on an M5 Pro, ~70 % of the batch, and made the default fast heap sync slower than the legacy path in bench_sync_slots_1_5m_fast_vs_legacy (0.83-0.90x). The span of a batch's stale slots (a page's at most) is now read once under the same lock and each slot compared in that copy; a span that cannot be read whole falls back to a read per slot, as before. The race check is unchanged: the read is still under self.made, after prepare, and a later write is caught by the next sync as before. Benchmark (M5 Pro, CrossOver Wine + D3DMetal, release, 3 runs): fast path 27-29 ms -> 10-13 ms for 1.5M slots scanned and ~39,100 made again, 2.5-2.7x the legacy path. Not measured in the game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This is the same change as #633 (opened about two hours earlier), so the maintainer only needs one of them. Both read the batch's stale records together under Differences, for picking one:
The bench numbers agree: about 0.46 µs per kernel copy under Wine, and the fast path about 2.5x faster with the reads together. I'm fine with whichever the maintainer prefers. |
Nick233x
pushed a commit
to Nick233x/VIctory-macOS
that referenced
this pull request
Nov 28, 2026
main's pragyaangaur#640 reads a heap sync batch's stale records once a page, always, as VICTORY_HEAP_READ_ONCE did here (on by default since dd434a4): that one is kept, and the switch, its test and its docs row go. bench_made_again times the merged path and prints the split of making slots again. In flight.rs, main's SUBMISSIONS_BEGUN store goes after the fence check here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gdemontalivet
added a commit
to gdemontalivet/VIctory-macOS
that referenced
this pull request
Nov 28, 2026
…ion (VICTORY_QUICK_SYNC) Add opt-in VICTORY_QUICK_SYNC (default off; supports 1, maps, views) layered onto batched heap sync and VICTORY_CENSUS_FAST=1: - Part A (census_maps.rs + bindless.rs): multiply-and-fold FoldHasher (Hashing) and hash-backed RangesMap replacing BTreeMap in bindless::Viewed when enabled, preserving UnorderedIndex / SnapshotCache (VICTORY_CENSUS_FAST=1), pragyaangaur#613 hull_generation invariance across interior view edits, deterministic BTreeMap-equivalent ordering in widened_writes_into when RangesMap is hash-backed, and sorting range copy keys before dedup in diagnostics. - Part B (descriptor/host/quick.rs + descriptor/host.rs): resolve each unique buffer SRV, placed buffer SRV, or aligned CBV record once per synced 64 KiB page outside HostHeap::made (including 3-channel widening, raw_structured lowering, held source, stride, view address, and bindless::Seen), then stamp matching slots via StagingHeap templates, keep_batch, and Viewed::set_batch_resolved while preserving pragyaangaur#640 page-span live reads, pragyaangaur#618 deferred show-after, and SyncStat / VICTORY_VIEW_PROBE telemetry. Textures, UAVs, samplers, placed textures, and refused/edge-case views stay on the standard path. - Add unit and live GPU equivalence tests comparing quick sync against standard sync across all view kinds, VICTORY_CENSUS_FAST=1, deterministic widened_writes_into ordering, and both Wine and native D3D12 (WARP) alignment/format rules.
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.
What
HostHeap::mirror_synced_batch(the default fast heap sync from #439) re-read every stale slot's record underself.madewith its ownReadProcessMemorycall, to catch a title thread that rewrote the slot since the page snapshot. It now reads the span of the batch's stale slots once, under the same lock: a page at most, sincesync_heapspasses a page's slots per call. Each slot is then compared within that copy. If the span can't be read whole (or is wider than 1 MiB), it falls back to reading slot by slot, as before.Why
bench_sync_slots_1_5m_fast_vs_legacyshowed the fast path slower than the legacy one on an M5 Pro (speedup=0.83–0.90x, where #439 reported 2.38x on an M5 Max). Running the fast path first gave the same result, so the order of the runs is not the cause. Under Wine eachReadProcessMemoryis a kernel call of about 0.5 µs: 39,100 of them took 18–21 ms on their own, about 70 % of the batch.The race check is unchanged: the read still happens under
self.made, afterprepare, and a write after it is caught by the next sync, as before.Measured
Apple M5 Pro, CrossOver Wine + D3DMetal, release build,
bench_sync_slots_1_5m_fast_vs_legacy(1.5M slots scanned, ~39,100 made again), 3 runs each:main¹ The legacy path is unchanged; the Mac was busier during these runs.
Not measured in the game. At the ~39,000 slots a world frame makes again (#409), this should save about 15–19 ms of heap sync per frame on Macs where the call costs what it does here.
Tests
WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=b" tools/macos/test-wine.sh -p victory-gpu --no-fail-fast: 591 passed, 0 failed, 19 ignored. That includesfast_heap_sync_handles_placed_null_duplicates_forget_and_concurrent_rewrite, which covers the rewrite check.cargo clippy -p victory-gpu --all-targetsforx86_64-pc-windows-gnullvm, with and without--all-features,-D warnings: clean.No game data, offsets or file names here.
🤖 Generated with Claude Code