GPU: drain fence wait counts and durations together #3167

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3169 into main
andrewpozdnakov7-jpg commented 2026-11-26 10:51:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T10:51:58Z.


Fence completion records a count and a duration. When the report drains those values separately, it can put the count in one window and its time in the next. The totals across both windows still add up, but the individual rows are wrong.

Accumulate the two values under one lock and drain them as a pair. A signal that completes several queued events records its batch after releasing the fence's waiter lock.

The same synthetic fixture ran a producer with 32,768 waits of 1,250 microseconds while the consumer drained the counters. Each run contained 32,768 events and 40,960,000 microseconds in total.

Build Runs with mismatched report windows Mismatched windows per run
main 63bcca4 20 of 20 86 to 20,688
Patched 0 of 20 0

The app-local WARP diagnostics suite passed 247 tests with one ignored. The native event test passed. Strict GPU Clippy with default and all features and the asset policy passed.

cargo test -p victory-gpu --features diagnostics --locked report_windows_keep_their_fence_counts_and_durations_together -- --nocapture

This collector change is independent of #3157, which logs frames with fence waits even when no command-list segments were held.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5508653720 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3169). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T10:51:58Z. --- Fence completion records a count and a duration. When the report drains those values separately, it can put the count in one window and its time in the next. The totals across both windows still add up, but the individual rows are wrong. Accumulate the two values under one lock and drain them as a pair. A signal that completes several queued events records its batch after releasing the fence's waiter lock. The same synthetic fixture ran a producer with 32,768 waits of 1,250 microseconds while the consumer drained the counters. Each run contained 32,768 events and 40,960,000 microseconds in total. | Build | Runs with mismatched report windows | Mismatched windows per run | | --- | --- | --- | | main 63bcca4 | 20 of 20 | 86 to 20,688 | | Patched | 0 of 20 | 0 | The app-local WARP diagnostics suite passed 247 tests with one ignored. The native event test passed. Strict GPU Clippy with default and all features and the asset policy passed. cargo test -p victory-gpu --features diagnostics --locked report_windows_keep_their_fence_counts_and_durations_together -- --nocapture This collector change is independent of #3157, which logs frames with fence waits even when no command-list segments were held.
Dukestar69 commented 2026-11-26 11:08:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T11:08:01Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib fence:: -- --test-threads=1: passed.
  • cargo test -p victory-gpu --lib queue:: -- --test-threads=1: 5/5 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings & --features diagnostics: clean.
  • cargo xtask policy: 191 files ok.

Cleanly drains fence wait counts and durations atomically together.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6073061203 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3169#pullrequestreview-6073061203). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T11:08:01Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib fence:: -- --test-threads=1`: passed. - `cargo test -p victory-gpu --lib queue:: -- --test-threads=1`: 5/5 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` & `--features diagnostics`: clean. - `cargo xtask policy`: 191 files ok. Cleanly drains fence wait counts and durations atomically together. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 22:20:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T22:20:29Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head 5700e03 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: report_windows_keep_their_fence_counts_and_durations_together.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7204587410 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3169#issuecomment-7204587410). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T22:20:29Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head `5700e03` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `report_windows_keep_their_fence_counts_and_durations_together`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/3169:upstream-pr/3169'
git switch 'upstream-pr/3169'

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/3169'
git switch 'upstream-pr/3169'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3169'
git switch 'upstream-pr/3169'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3169'
git switch 'main'
git merge --squash 'upstream-pr/3169'
git switch 'main'
git merge --ff-only 'upstream-pr/3169'
git switch 'main'
git merge 'upstream-pr/3169'
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
Marvisak/VIctory!3167
No description provided.