Identify residency and mapping waits by allocation kind #432

Open
feanorsun wants to merge 1 commit from upstream-pr/432 into main
feanorsun commented 2026-11-27 04:52:54 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by feanorsun on 2026-11-27T04:52:54Z.


Refs #371

Jesper-Andersson reported a longest residency wait of 592 ms in run H with the own-bytes pool enabled. The longest mapping wait in that run was 35 ms. The existing counters gave totals across threads, so the log alone could not place either wait on the path to a Present. Run H and the request for instrumentation

A diagnostics build with VICTORY_TIMELINE enabled now shows new memory: resident around the synchronous MakeResident call and new memory: mapped around the mapping barrier. The latter includes waiting for the shared queue lock, submitting the copy, and waiting for its fence if needed. Both spans end before the counters are reported. With VICTORY_WAIT_RESIDENT=0, both functions return before creating a span or counting a sample.

Each existing summary now includes an allocation_kinds field with a count, total microseconds, and maximum microseconds for each kind. The resident summary still reports every 1,000 calls. The mapped summary reports on the first call and every 200 calls. The counters distinguish textures (including depth twins), new texture-pool heaps, upload buffers, shared buffers, CPU-mapped card buffers, and device-local UAV buffers. Each label identifies the allocation that requested the wait. For example, staging blocks and other users of the upload-buffer helper share its label. That helper calls MakeResident and then maps the resource for the CPU. It contributes only to the resident summary.

Windows CPU verification

Listed the two tests first in each configuration, then ran each by its full name with one test thread. Default features passed 2/2 and diagnostics passed 2/2. Synthetic resident samples of 10 and 30 µs for textures and 7 µs for a shared buffer produced 3 calls, 47 µs total, and a 30 µs maximum. An independent 7 µs mapped sample counted only in the mapping summary. The tests also check the formatted allocation labels and the two reporting intervals.

cargo test --offline --locked -j 1 -p victory-gpu --lib residency_waits -- --list
cargo test --offline --locked -j 1 -p victory-gpu --lib --features diagnostics residency_waits -- --list
$tests = @(
    'host::residency_waits::tests::separates_waits_and_allocation_kinds'
    'host::residency_waits::tests::keeps_the_existing_report_intervals'
)
foreach ($name in $tests) {
    cargo test --offline --locked -j 1 -p victory-gpu --lib $name -- --exact --test-threads=1
    cargo test --offline --locked -j 1 -p victory-gpu --lib --features diagnostics $name -- --exact --test-threads=1
}

Local tests cover diagnostic accounting. No D3D12 device, WARP, or game was run, and no frame times were measured.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5521399871 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/432). Originally posted by [feanorsun](https://github.com/feanorsun) on 2026-11-27T04:52:54Z. --- Refs #371 Jesper-Andersson reported a longest residency wait of 592 ms in run H with the own-bytes pool enabled. The longest mapping wait in that run was 35 ms. The existing counters gave totals across threads, so the log alone could not place either wait on the path to a Present. [Run H and the request for instrumentation](https://github.com/avatarmanz/VIctory-7900XTX/issues/371#issuecomment-7203690682) A diagnostics build with `VICTORY_TIMELINE` enabled now shows `new memory: resident` around the synchronous `MakeResident` call and `new memory: mapped` around the mapping barrier. The latter includes waiting for the shared queue lock, submitting the copy, and waiting for its fence if needed. Both spans end before the counters are reported. With `VICTORY_WAIT_RESIDENT=0`, both functions return before creating a span or counting a sample. Each existing summary now includes an `allocation_kinds` field with a count, total microseconds, and maximum microseconds for each kind. The resident summary still reports every 1,000 calls. The mapped summary reports on the first call and every 200 calls. The counters distinguish textures (including depth twins), new texture-pool heaps, upload buffers, shared buffers, CPU-mapped card buffers, and device-local UAV buffers. Each label identifies the allocation that requested the wait. For example, staging blocks and other users of the upload-buffer helper share its label. That helper calls `MakeResident` and then maps the resource for the CPU. It contributes only to the resident summary. ### Windows CPU verification Listed the two tests first in each configuration, then ran each by its full name with one test thread. Default features passed 2/2 and `diagnostics` passed 2/2. Synthetic resident samples of 10 and 30 µs for textures and 7 µs for a shared buffer produced 3 calls, 47 µs total, and a 30 µs maximum. An independent 7 µs mapped sample counted only in the mapping summary. The tests also check the formatted allocation labels and the two reporting intervals. ```powershell cargo test --offline --locked -j 1 -p victory-gpu --lib residency_waits -- --list cargo test --offline --locked -j 1 -p victory-gpu --lib --features diagnostics residency_waits -- --list $tests = @( 'host::residency_waits::tests::separates_waits_and_allocation_kinds' 'host::residency_waits::tests::keeps_the_existing_report_intervals' ) foreach ($name in $tests) { cargo test --offline --locked -j 1 -p victory-gpu --lib $name -- --exact --test-threads=1 cargo test --offline --locked -j 1 -p victory-gpu --lib --features diagnostics $name -- --exact --test-threads=1 } ``` Local tests cover diagnostic accounting. No D3D12 device, WARP, or game was run, and no frame times were measured.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/432:upstream-pr/432'
git switch 'upstream-pr/432'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/432'
git switch 'upstream-pr/432'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/432'
git switch 'upstream-pr/432'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/432'
git switch 'main'
git merge --squash 'upstream-pr/432'
git switch 'main'
git merge --ff-only 'upstream-pr/432'
git switch 'main'
git merge 'upstream-pr/432'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!432
No description provided.