perf(gpu): avoid repeated placeholder queries within uncommitted regions #580
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/lobomfz--VIctory-xmem!580
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-580"
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?
@tommiehansen on GitHub · 2026-12-05 11:19 UTC · original
tommiehansen:perf/guard-placeholder-region-cache→main· +105 −2 · 1 files · 2 commits · openWhy
Placeholder classification repeats native queries for each block of an already bounded uncommitted run.
What changes
Cache classification only within intersection of VirtualQuery run and returned allocation region; failed/inconsistent answers do not extend beyond one block.
Benchmark results
512 blocks: 512→1 native queries, 159.45→1.05 µs, paired −99.34% (8 blocks). Independent fragmented 48-window test: 222→108 calls, exact classifications/absent/held sets.
Why this should be merged / current decision
Avoids redundant syscalls without changing protection decisions; ready for review.
Validation
Native CI passed split and private-boundary tests in debug/release. Independent verification: same five inherited suite failures as main, no new failures.
Compatibility
No new switch. Distinct from #513/#334/#381; no frame-time inference.
Archived detailed evidence and review history.
github-bot referenced this pull request2026-12-05 11:23:58 +00:00
@Kal0s-design on GitHub · 2026-12-05 11:58 UTC · original
Native Windows check of
e35ac10(MSVC build, Windows 11, no Wine), compared against main at8bf4878.The watch tests pass (39 passed, the benchmark ignored). The full victory-gpu lib suite, skipping descriptor::tests::views_die_with_their_resource, gives the same five failures as main on this machine and nothing new. Those are the two indirect host_list tests, the two pipeline::host library loads and the_rest_of_the_one_asking_has_a_number_of_its_own. The last one is the known flaky watch test and passes when rerun on its own.
The ignored benchmark passes natively. Query count goes from 512 to 1 with identical classification, and in a release build the median walk over the 512 block placeholder is about 200x faster (three runs, very stable). That is a microbenchmark of the classification loop only, not a frame time number.
I also wanted to see the real protect_mapped path on a messier layout, so I wrote a throwaway local test (not pushed). It carves one 24 block placeholder into split placeholder pieces of 4, 3, 1, 3 and 3 blocks, a released block that leaves a MEM_FREE hole, a committed MEM_REPLACE_PLACEHOLDER private block, a 3 block section view mapped with MEM_REPLACE_PLACEHOLDER, a reserve-only MEM_REPLACE_PLACEHOLDER allocation with one block committed in the middle, and a reserve-only block with only its first 4 KiB committed. It then calls protect_mapped from every start offset, plus short windows, and compares held against a fresh per-block NtQueryVirtualMemory answer for every absent block. All 48 runs matched, and the absent and held sets of the full-range walk came out identical to the same test on main.
Some native details that might help. A VirtualQuery reserved run never crossed an allocation here, so the allocation-region bound mostly coincides with the uncommitted run. The one place they differ is the reserve-only allocation with a committed block inside, where region_size runs to the end of the allocation and the VirtualQuery bound is the one that stops the reuse, as intended. The free hole in my layout was a single block, so it got its own query as on main. From reading the code a longer free run should also stay at one query per block, and flooring end / BLOCK means a partial trailing block always gets its own query, which seems right. Since the cached value lives only inside one protect_mapped call, there is nothing to invalidate on free, unmap or remap. In this fragmented layout the saving was 222 queries down to 108 across all start offsets, so the big win depends on long unsplit placeholders like the benchmark's.
I see no correctness problem. git merge-tree reports no textual conflict with #581, #513, #312 or #559.
AI-assisted: yes
@tommiehansen on GitHub · 2026-12-05 12:28 UTC · original
Thanks for the additional fragmented-layout verification. The 48-window parity and 222→108 query result are now documented separately from the contiguous microbenchmark. No code change was indicated by the review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.