Skip to content

DirectStorage: Close completes what was submitted - #430

Open
marquezinii wants to merge 1 commit into
Marvisak:mainfrom
marquezinii:fix/dstorage-close-completes-submitted
Open

marquezinii wants to merge 1 commit into
Marvisak:mainfrom
marquezinii:fix/dstorage-close-completes-submitted

Conversation

@marquezinii

Copy link
Copy Markdown
Contributor

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

IDStorageQueueX::Close blocks until all enqueued requests complete or
fail. close_lane dropped submitted reads that had not started and every
pending status entry, and waited only for the reads already running, so
a title polling a status entry after Close waited forever. Requests
enqueued but never submitted are still dropped.
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DaviTostes

Copy link
Copy Markdown

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 (Wine: fall back where ws2_32 lacks exports; hook and cfg fixes #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).

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. close_lane in crates/victory-hle/src/modules/dstorage.rs discarded submitted reads and status entries that had not started, so a status entry behind a dropped read stayed E_PENDING forever. It now drops only commands enqueued but never submitted and waits until the lane has no reads, nothing running and no unwritten status entries, which matches the public Close documentation. Lanes::start does not skip closed lanes and finish calls Lane::flush, so the wait loop ends; a_closed_queue_completes_nothing still holds. May need a small rebase against #234, as the body says.

CI: no check runs on the head commit.


Generated by Claude Code

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants