Find the destination heap once per descriptor copy, not per descriptor #62

Open
github-bot wants to merge 1 commit from github-bot/gh-62 into a-publier AGit
Owner

@⁠romainhedouin on GitHub · 2026-11-25 13:14 UTC · original
romainhedouin:perf/descriptor-copy-one-lock → a-publier · +63 −39 · 1 files · 1 commits · open

When the title copies N descriptors (CopyDescriptorsSimple), each copied slot was mirrored to the host on its own: it took the SHADER_HEAPS lock, scanned the list for the heap holding the slot, and locked that heap's pending list. The heap is now found once for each run of slots in the same heap (a run stops where another heap starts, so overlapping heaps give the same answer as before), and CopyDescriptors no longer builds two Vecs of ranges per call.

Per copy of N descriptors into one heap Before After
SHADER_HEAPS read-lock acquisitions N 1
Heap-list scans N 1
pending locks N 1
Vec allocations per CopyDescriptors 2 0

Tested: counts from the code; a standalone model of the per-slot lookup against the run lookup agreed on 3,000,000 random cases (overlapping and adjacent heaps, mismatched steps); type-checked for Windows (cargo clippy --target x86_64-pc-windows-msvc, with and without --all-features, no new warnings), not run.

🤖 Generated with Claude Code

**@⁠romainhedouin** on GitHub · 2026-11-25 13:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/62) `romainhedouin:perf/descriptor-copy-one-lock` → `a-publier` · +63 −39 · 1 files · 1 commits · open When the title copies N descriptors (`CopyDescriptorsSimple`), each copied slot was mirrored to the host on its own: it took the `SHADER_HEAPS` lock, scanned the list for the heap holding the slot, and locked that heap's `pending` list. The heap is now found once for each run of slots in the same heap (a run stops where another heap starts, so overlapping heaps give the same answer as before), and `CopyDescriptors` no longer builds two `Vec`s of ranges per call. | Per copy of N descriptors into one heap | Before | After | |---|---|---| | `SHADER_HEAPS` read-lock acquisitions | N | 1 | | Heap-list scans | N | 1 | | `pending` locks | N | 1 | | `Vec` allocations per `CopyDescriptors` | 2 | 0 | Tested: counts from the code; a standalone model of the per-slot lookup against the run lookup agreed on 3,000,000 random cases (overlapping and adjacent heaps, mismatched steps); type-checked for Windows (`cargo clippy --target x86_64-pc-windows-msvc`, with and without `--all-features`, no new warnings), not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:34:47 +00:00
@ -163,0 +159,4 @@
let mut next = u64::MAX;
for &(start, end, heap) in heaps.iter() {
if (start..end).contains(&at) {
found.get_or_insert((end, heap));
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 15:09 UTC · original

The standalone model covers overlapping heaps, but could we keep one overlapping-heap case as a Windows unit test for mirror_range? The found.get_or_insert choice and run cutoff intentionally preserve the old first-containing-heap behavior, which is subtle and otherwise has no repository regression test. AI-assisted review; I checked the production path and the test coverage described in the PR.

**@⁠gut0to** on GitHub · 2026-11-25 15:09 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/62#discussion_r4696900111) The standalone model covers overlapping heaps, but could we keep one overlapping-heap case as a Windows unit test for mirror_range? The found.get_or_insert choice and run cutoff intentionally preserve the old first-containing-heap behavior, which is subtle and otherwise has no repository regression test. AI-assisted review; I checked the production path and the test coverage described in the PR.
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 15:09 UTC · original · reviewed

AI-assisted review: I checked the changed behavior and the associated test coverage.

**@⁠gut0to** on GitHub · 2026-11-25 15:09 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/62#pullrequestreview-6060187663) · **reviewed** AI-assisted review: I checked the changed behavior and the associated test coverage.
github-bot changed target branch from main to a-publier 2026-11-27 00:59:57 +00:00
github-bot force-pushed github-bot/gh-62 from 744c52c653 to 00c88383cb 2026-11-27 00:59:58 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/62/head:github-bot/gh-62'
git switch 'github-bot/gh-62'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-62'
git switch 'github-bot/gh-62'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-62'
git switch 'github-bot/gh-62'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-62'
git switch 'a-publier'
git merge --squash 'github-bot/gh-62'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-62'
git switch 'a-publier'
git merge 'github-bot/gh-62'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.