DirectStorage: Close completes what was submitted #430

Open
marquezinii wants to merge 1 commit from upstream-pr/430 into main
marquezinii commented 2026-11-24 03:15:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T03:15:56Z.


IDStorageQueueX::Close "blocks until all enqueued requests either complete or fail. After the method returns, the queue will no longer complete any more requests, even if some are submitted." close_lane instead cleared the lane's submitted reads that had not started and all of its pending status entries, then waited only for the reads already running. A status entry behind a dropped read stayed E_PENDING for good, so a title polling IsComplete after Close would spin forever. Grand Theft Auto VI calls Close on its queues (the comment on close says so).

close_lane now drops only what was enqueued but never submitted (so a_closed_queue_completes_nothing still holds) and waits until the lane has no reads left, none running and no status entry unwritten. The workers already take reads from a closed lane and finish flushes its statuses, so nothing else changes.

Tested with a new test that submits 32 reads of 256 KiB and a status entry, then closes the queue at once: before the change the status was still E_PENDING after Close (3 of 3 runs); now it is S_OK and the destination holds the whole file (3 of 3). cargo test -p victory-hle passes and clippy reports nothing new.

#234 also touches close_lane (its counters), so one of the two may need a small rebase.

https://learn.microsoft.com/gaming/gdk/docs/reference/system/dstorage/interfaces/idstoragequeuex/methods/idstoragequeuex_close

<!-- greyfinch-sync:Marvisak/VIctory:issue:6573813390 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/430). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T03:15:56Z. --- `IDStorageQueueX::Close` "blocks until all enqueued requests either complete or fail. After the method returns, the queue will no longer complete any more requests, even if some are submitted." `close_lane` instead cleared the lane's submitted reads that had not started and all of its pending status entries, then waited only for the reads already running. A status entry behind a dropped read stayed `E_PENDING` for good, so a title polling `IsComplete` after `Close` would spin forever. Grand Theft Auto VI calls `Close` on its queues (the comment on `close` says so). `close_lane` now drops only what was enqueued but never submitted (so `a_closed_queue_completes_nothing` still holds) and waits until the lane has no reads left, none running and no status entry unwritten. The workers already take reads from a closed lane and `finish` flushes its statuses, so nothing else changes. Tested with a new test that submits 32 reads of 256 KiB and a status entry, then closes the queue at once: before the change the status was still `E_PENDING` after `Close` (3 of 3 runs); now it is `S_OK` and the destination holds the whole file (3 of 3). `cargo test -p victory-hle` passes and clippy reports nothing new. #234 also touches `close_lane` (its counters), so one of the two may need a small rebase. https://learn.microsoft.com/gaming/gdk/docs/reference/system/dstorage/interfaces/idstoragequeuex/methods/idstoragequeuex_close
mercuryVM commented 2026-11-24 06:52:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T05:11:45Z.

Review: APPROVED


Tested 129d289 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed). I ran the new closing_a_queue_completes_what_was_submitted 8 more times on its own and it passed each time (about 0.1 s each), with no hang.

I traced the new wait to check that it always ends:

  • Lanes::start takes reads from any lane with reads, closed or not, so submitted reads still run after Close.
  • finish removes the job from running and calls flush, which writes every status entry with no earlier read outstanding. Once reads and running are empty, statuses empties too, and each worker's finished.notify_all() wakes the waiter.
  • Statuses with no reads ahead of them are flushed in submit, so they cannot be left in a lane that has nothing running.
  • unsubmitted.clear() keeps a_closed_queue_completes_nothing valid.

One edge case, not blocking: scheduler() returns Some even when no worker thread started. Before this change Close returned at once in that case. Now it waits forever if reads were submitted. Every read on such a lane already stalls forever, so this only moves where the hang shows up, but a workers == 0 guard in close_lane (or scheduler() returning None, as its doc says) would rule it out.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6034041601 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/430#pullrequestreview-6034041601). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T05:11:45Z. **Review:** APPROVED --- Tested 129d289 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed). I ran the new `closing_a_queue_completes_what_was_submitted` 8 more times on its own and it passed each time (about 0.1 s each), with no hang. I traced the new wait to check that it always ends: - `Lanes::start` takes reads from any lane with reads, closed or not, so submitted reads still run after `Close`. - `finish` removes the job from `running` and calls `flush`, which writes every status entry with no earlier read outstanding. Once `reads` and `running` are empty, `statuses` empties too, and each worker's `finished.notify_all()` wakes the waiter. - Statuses with no reads ahead of them are flushed in `submit`, so they cannot be left in a lane that has nothing running. - `unsubmitted.clear()` keeps `a_closed_queue_completes_nothing` valid. One edge case, not blocking: `scheduler()` returns `Some` even when no worker thread started. Before this change `Close` returned at once in that case. Now it waits forever if reads were submitted. Every read on such a lane already stalls forever, so this only moves where the hang shows up, but a `workers == 0` guard in `close_lane` (or `scheduler()` returning `None`, as its doc says) would rule it out. AI-assisted (Claude Code).
DaviTostes commented 2026-11-24 06:55:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T03:33:51Z.


Verified 129d289 on Arch Linux x86_64 with the Windows build under Wine 11.22 (cargo xwin, x86_64-pc-windows-msvc, release, rustc 1.98.1):

  • victory-hle: 86 passed, 1 failed. The only failure is modules::net::tests::only_loopback_is_reachable — the known Wine WSAConnectByList environment gap (#217), unrelated.
  • The new closing_a_queue_completes_what_was_submitted passes (with the Wine GetTempPath2W fixme in its output).

Not covered: a real title queue at close, and throughput/latency effects (no game data here).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121214573 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/430#issuecomment-7121214573). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T03:33:51Z. --- Verified `129d289` on **Arch Linux x86_64** with the Windows build under **Wine 11.22** (`cargo xwin`, `x86_64-pc-windows-msvc`, release, rustc 1.98.1): - `victory-hle`: **86 passed, 1 failed**. The only failure is `modules::net::tests::only_loopback_is_reachable` — the known Wine `WSAConnectByList` environment gap (#217), unrelated. - The new `closing_a_queue_completes_what_was_submitted` passes (with the Wine `GetTempPath2W` fixme in its output). Not covered: a real title queue at close, and throughput/latency effects (no game data here).
Marvisak commented 2026-11-25 01:07:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:29:41Z.


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-hle/src/modules/dstorage.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge-candidate) was for an older state of main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148567189 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/430#issuecomment-7148567189). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:29:41Z. --- <!-- victory-triage v1 head=129d2897c43fed991ffb1160b49e85a6b1a1aba0 verdict=needs-rebase at=2026-11-25T15:56:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-hle/src/modules/dstorage.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge-candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/430:upstream-pr/430'
git switch 'upstream-pr/430'

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