GPU: stage HostHeap descriptor updates until submission flush #2048

Closed
github-bot wants to merge 1 commit from gh-pr/2048/head into gh-pr/2048/base
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:06 UTC · original
fuzeofficlal:fix/gpu-multilist-submission-sync-1348 → main · +1396 −111 · 5 files · 1 commits · closed without merging

Refs #1348.

Summary

  • Stage HostHeap descriptor writes (mirror, make_at, make_null, raw_view_at, raw_pair_at) into CPU-only staging chunks and publish each slot atomically alongside its strides, marks, and addresses side-table entries in HostHeap::flush, called under Host::execute's submission lock right before ExecuteCommandLists and again after the submission finishes waiting, before release_retired.
  • Keep HostHeap::view_addresses synchronized with HostHeap::flush via Staged::published_addresses (under the staged mutex) rather than reading self.made directly, so unflushed made updates never leak into the view-address buffer ahead of their staged descriptors.
  • Log a one-time warning and fall back to writing descriptors and side tables directly when alloc_staged (CreateDescriptorHeap) fails instead of dropping slot updates.

Verification

  • descriptor::host::tests::concurrent_slot_rewrites_do_not_corrupt_in_flight_32_list_submission
  • descriptor::host::tests::staged_slots_publish_descriptors_and_side_tables_atomically
  • descriptor::host::tests::view_addresses_stays_synchronized_with_staged_flushes
  • descriptor::host::tests::alloc_staged_failure_falls_back_to_direct_writes
  • cargo clippy -p victory-gpu --tests --locked -- -D warnings and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048) `fuzeofficlal:fix/gpu-multilist-submission-sync-1348` → `main` · +1396 −111 · 5 files · 1 commits · closed without merging Refs #1348. ### Summary - Stage `HostHeap` descriptor writes (`mirror`, `make_at`, `make_null`, `raw_view_at`, `raw_pair_at`) into CPU-only staging chunks and publish each slot atomically alongside its `strides`, `marks`, and `addresses` side-table entries in `HostHeap::flush`, called under `Host::execute`'s submission lock right before `ExecuteCommandLists` and again after the submission finishes waiting, before `release_retired`. - Keep `HostHeap::view_addresses` synchronized with `HostHeap::flush` via `Staged::published_addresses` (under the `staged` mutex) rather than reading `self.made` directly, so unflushed `made` updates never leak into the view-address buffer ahead of their staged descriptors. - Log a one-time warning and fall back to writing descriptors and side tables directly when `alloc_staged` (`CreateDescriptorHeap`) fails instead of dropping slot updates. ### Verification - `descriptor::host::tests::concurrent_slot_rewrites_do_not_corrupt_in_flight_32_list_submission` - `descriptor::host::tests::staged_slots_publish_descriptors_and_side_tables_atomically` - `descriptor::host::tests::view_addresses_stays_synchronized_with_staged_flushes` - `descriptor::host::tests::alloc_staged_failure_falls_back_to_direct_writes` - `cargo clippy -p victory-gpu --tests --locked -- -D warnings` and `cargo xtask policy`: passed.
Title threads mirror views, rewrite dynamic slots, and null stale entries while multi-list submissions are executing on the GPU. Writing directly into the bound shader-visible ID3D12DescriptorHeap and its mapped stride, mark, and view-address tables mid-submission mutates descriptors that later command lists in the same ExecuteCommandLists batch have not yet read.

Populate updated descriptors in CPU-only staging chunks and commit each slot's descriptor, stride, mark, and view-address metadata together as a single staged record. HostHeap::flush publishes queued updates under Host::execute's submission lock right before ExecuteCommandLists and again after waiting for submission completion before release_retired. view_addresses initializes from the already-published address state rather than unflushed made entries, and if staging chunk allocation fails HostHeap warns once, drops any older queued updates for those slots so a subsequent flush cannot overwrite direct writes, and falls back to writing directly to the host heap and side tables.

Refs #1348
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:52 +00:00
github-bot closed this pull request 2026-11-26 04:52:52 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:14 UTC · original

Triage verdict — Keep the staging approach, publish each slot atomically (da8574b)

Evidence

  • @⁠fuzeofficlal defers writes to the GPU-visible heap, but slot creation enqueues descriptor, stride, and mark changes separately. The mirror path can enqueue side-table changes before the descriptor. A flush between queue operations can publish a descriptor with stale metadata or metadata for a descriptor that has yet to be copied. Slot staging · Mirror staging

Checks and limits

  • The submitted 32-list synthetic test passed on WARP. A disposable deterministic test forced a flush between the existing staging calls. The descriptor op was drained while the stride and mark still held the old values. A second flush was needed to publish the matching stride and mark. This reproduced the split without changing production code.
  • The existing 32-list shader checks a single result dword and does not consume the side tables. Local debug messages were unavailable, so this run does not independently establish a clean debug-layer result or resolution of #1348. Existing test

Next step

  • Enqueue the descriptor, stride, mark, address, and associated resource ownership as one publication unit. Include both descriptors in that unit for paired slots. Retain the deterministic interleaving test and give the GPU fixture distinct output for each list so it can check every read.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7152668172) **Triage verdict — Keep the staging approach, publish each slot atomically** (`da8574b`) **Evidence** - @⁠fuzeofficlal defers writes to the GPU-visible heap, but slot creation enqueues descriptor, stride, and mark changes separately. The mirror path can enqueue side-table changes before the descriptor. A flush between queue operations can publish a descriptor with stale metadata or metadata for a descriptor that has yet to be copied. [Slot staging](https://github.com/Marvisak/VIctory/blob/da8574ba542debc39f456a19fce3f5626cdef593/crates/victory-gpu/src/descriptor/host.rs#L449-L542) · [Mirror staging](https://github.com/Marvisak/VIctory/blob/da8574ba542debc39f456a19fce3f5626cdef593/crates/victory-gpu/src/descriptor/host.rs#L828-L858) **Checks and limits** - The submitted 32-list synthetic test passed on WARP. A disposable deterministic test forced a flush between the existing staging calls. The descriptor op was drained while the stride and mark still held the old values. A second flush was needed to publish the matching stride and mark. This reproduced the split without changing production code. - The existing 32-list shader checks a single result dword and does not consume the side tables. Local debug messages were unavailable, so this run does not independently establish a clean debug-layer result or resolution of #1348. [Existing test](https://github.com/Marvisak/VIctory/blob/da8574ba542debc39f456a19fce3f5626cdef593/crates/victory-gpu/src/descriptor/host.rs#L1951-L2019) **Next step** - Enqueue the descriptor, stride, mark, address, and associated resource ownership as one publication unit. Include both descriptors in that unit for paired slots. Retain the deterministic interleaving test and give the GPU fixture distinct output for each list so it can check every read. This verification was AI-assisted.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:50 UTC · original

Updated in cdc6fbd0 — thanks @⁠jeremygold02 for catching the split staging window:

  • Replaced separate StagedOp queue pushes with composite StagedSlot { index, descriptor, stride, mark, address } records committed in a single commit_staged lock scope across mirror, make_at, make_null, raw_pair_at (both pair slots together), and raw_view_at(..., mark) (eliminating the separate set_mark call in State::root_view).
  • Added staged_slots_publish_descriptors_and_side_tables_atomically testing deterministic pre/post-flush isolation, 4,000 interleaved flushes against concurrent slot rewrites, and 16 GPU compute dispatches reading HostHeap and all three side tables simultaneously across RTX 5090, AMD RDNA2, and WARP.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7153209984) Updated in `cdc6fbd0` — thanks @⁠jeremygold02 for catching the split staging window: - Replaced separate `StagedOp` queue pushes with composite `StagedSlot { index, descriptor, stride, mark, address }` records committed in a single `commit_staged` lock scope across `mirror`, `make_at`, `make_null`, `raw_pair_at` (both pair slots together), and `raw_view_at(..., mark)` (eliminating the separate `set_mark` call in `State::root_view`). - Added `staged_slots_publish_descriptors_and_side_tables_atomically` testing deterministic pre/post-flush isolation, 4,000 interleaved flushes against concurrent slot rewrites, and 16 GPU compute dispatches reading `HostHeap` and all three side tables simultaneously across RTX 5090, AMD RDNA2, and WARP.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:20 UTC · original · edited 2026-11-25 15:55 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/descriptor.rs, crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 09:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7158194826) · edited 2026-11-25 15:55 UTC <!-- victory-triage v1 head=dfb8093370e5a5e396f1f584a14c4efb96f6241b verdict=needs-rebase at=2026-11-25T15:56:00Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/descriptor.rs`, `crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-gpu/src/host.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 10:34 UTC · original

Updated in 40d0bcec per triage feedback:

  • view_addresses synchronization: HostHeap::view_addresses now initializes from Staged::published_addresses under the staged lock (and updates published_addresses + addresses_data atomically inside write_side_tables during flush), rather than reading self.made directly ahead of staged descriptors. Covered by view_addresses_stays_synchronized_with_staged_flushes.
  • alloc_staged fallback & warning: When CreateDescriptorHeap fails in alloc_staged, it now logs a one-time tracing::warn! and falls back (target_handles + finish_slots(..., false)) to writing descriptors and side tables directly instead of dropping the update. Covered by alloc_staged_failure_falls_back_to_direct_writes.
  • Title, doc comments & issue link: Updated the title and doc comments across descriptor.rs, descriptor/host.rs, host.rs, and memory.rs to state accurately that staged updates are published under Host::execute's submission lock before ExecuteCommandLists and again after completion before release_retired, and changed Closes #1348 to Refs #1348.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 10:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7159882504) Updated in `40d0bcec` per triage feedback: - **`view_addresses` synchronization**: `HostHeap::view_addresses` now initializes from `Staged::published_addresses` under the `staged` lock (and updates `published_addresses` + `addresses_data` atomically inside `write_side_tables` during `flush`), rather than reading `self.made` directly ahead of staged descriptors. Covered by `view_addresses_stays_synchronized_with_staged_flushes`. - **`alloc_staged` fallback & warning**: When `CreateDescriptorHeap` fails in `alloc_staged`, it now logs a one-time `tracing::warn!` and falls back (`target_handles` + `finish_slots(..., false)`) to writing descriptors and side tables directly instead of dropping the update. Covered by `alloc_staged_failure_falls_back_to_direct_writes`. - **Title, doc comments & issue link**: Updated the title and doc comments across `descriptor.rs`, `descriptor/host.rs`, `host.rs`, and `memory.rs` to state accurately that staged updates are published under `Host::execute`'s submission lock before `ExecuteCommandLists` and again after completion before `release_retired`, and changed `Closes #1348` to `Refs #1348`.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 13:15 UTC · original

Updated in dfb80933 (rebased onto 940d32f) to fix the fallback-ordering issue noted above:

  • target_handles / finish_slots(.., false): When alloc_staged falls back to direct writes, queued StagedSlot entries for those slot indices are dropped under self.staged before writing directly and before updating side tables, so a subsequent flush cannot overwrite the newer direct descriptor or side-table entries.
  • Test: Added direct_fallback_drops_older_queued_updates_for_the_same_slot covering queued staged writes followed by fail_alloc direct writes and flush.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 13:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7163510653) Updated in `dfb80933` (rebased onto `940d32f`) to fix the fallback-ordering issue noted above: - **`target_handles` / `finish_slots(.., false)`**: When `alloc_staged` falls back to direct writes, queued `StagedSlot` entries for those slot indices are dropped under `self.staged` before writing directly and before updating side tables, so a subsequent `flush` cannot overwrite the newer direct descriptor or side-table entries. - **Test**: Added `direct_fallback_drops_older_queued_updates_for_the_same_slot` covering queued staged writes followed by `fail_alloc` direct writes and `flush`.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 13:20 UTC · original

I verified the updated dfb8093 on Windows app-local WARP. All 10 descriptor::host::tests passed, including direct_fallback_drops_older_queued_updates_for_the_same_slot. The readbacks cover both the direct replacement in slot 0 and the unrelated staged update in slot 1. I also reproduced the stale replay on the previous 40d0bce with an independent two-slot fixture.

AI-assisted with Codex. Synthetic buffers only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 13:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7163634539) I verified the updated `dfb8093` on Windows app-local WARP. All 10 `descriptor::host::tests` passed, including `direct_fallback_drops_older_queued_updates_for_the_same_slot`. The readbacks cover both the direct replacement in slot 0 and the unrelated staged update in slot 1. I also reproduced the stale replay on the previous `40d0bce` with an independent two-slot fixture. AI-assisted with Codex. Synthetic buffers only.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 16:11 UTC · original

Closing for now: da82e444 refactored HostHeap descriptor creation/eviction and 16-byte view-address side tables (42ea09f, f809521, 52d14b1, e790217), and we do not have an in-title A/B run past #1348 to justify rebasing this core-path staging layer.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 16:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2048#issuecomment-7167671757) Closing for now: `da82e444` refactored `HostHeap` descriptor creation/eviction and 16-byte view-address side tables (`42ea09f`, `f809521`, `52d14b1`, `e790217`), and we do not have an in-title A/B run past `#1348` to justify rebasing this core-path staging layer.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2048
No description provided.