DirectStorage: a queue submits itself past half its capacity, not at half #2072

Open
0xkn0wh3r3 wants to merge 1 commit from upstream-pr/2074 into main
0xkn0wh3r3 commented 2026-11-25 04:23:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T04:23:02Z.


The problem

A DirectStorage queue submitted itself one entry too early.

The public DirectStorage overview for the console queue says an Enqueue submits the queue once it has filled more than half of its capacity since the last submission. Our queue (queue in modules/dstorage.rs) submitted at exactly half. For example, a queue of 8 holding 4 entries since its last submission submitted itself, where the overview says they stay pending.

The reference pages for EnqueueStatus and Query say the submit happens at half, so the public pages disagree (see the thread). This PR follows the overview. Flipping it is one line in Lane::submits_at plus the two boundary tests.

The fix

  • A queue now submits itself once the entries enqueued since the last submission are more than half its capacity (Lane::submits_at). A queue of 8 holding 4 entries since its last submission now leaves them pending until Submit or a fifth entry.
  • A queue holds one entry fewer than its capacity: one slot stays free (Lane::most, the check the blocking loop already made). So a queue of 2 holds one entry and could never pass half. It submits once full, or its next Enqueue would wait forever.
capacity entries held entries that submit
0, 1, 2 1 1
3 2 2
4 3 3
8 7 5

Testing

  • half_a_queue_submits_itself is now more_than_half_a_queue_submits_itself, which uses status entries only and does not sleep. On a capacity-8 queue, after a Submit, four status entries stay E_PENDING and the fifth submits all of them. A status with no read before it is written by the submit itself, so the check does not depend on worker timing. With the old threshold the test fails at the fourth entry.
  • New unit test a_full_queue_has_submitted_itself: checks the table above, and that for every capacity up to 1024 a queue submits before it is full, so an Enqueue never waits forever.
  • Upstream's a_page_list_the_title_changes_before_its_submit (from eddde73) enqueues a third read. Two of four no longer submit the queue, and the test needs a self-submit.
  • cargo test -p victory-hle: all pass. cargo test -p victory-hle --lib dstorage:: passed 55 runs in a row. On the first run after the build, a_page_list_filled_after_its_request_starts failed once. It submits explicitly on a capacity-128 queue, so the threshold does not affect it. It races a 2 ms filler thread against the 8 x 1 ms late-list retries. cargo clippy -p victory-hle --all-targets: clean. cargo xtask policy: ok.
  • With this and the other conformance fixes merged onto #2057's branch, its suite passes 151 of 152 checks (the remaining one, the console id, is #1717).
  • Not run with a title (no game data here). No console Query measurement to settle which public page is right.
  • Found by the conformance title in #2057, which lists this check as a known divergence. Whichever of the two merges second takes the entry off the test's KNOWN list (a listed check that passes fails that test).

Rebased onto 63bcca4

  • The threshold change sits on top of upstream eddde73. When a queue submits itself (now past half instead of at half), its reads into physical pages and the status entries behind them still wait for the title's Submit. A full queue still submits everything.
  • Lane::most replaces the inline one-free-slot check in queue. eddde73's self-submit log line and comments now say "more than half full".
<!-- greyfinch-sync:Marvisak/VIctory:issue:6597158348 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T04:23:02Z. --- ## The problem A DirectStorage queue submitted itself one entry too early. The public DirectStorage overview for the console queue says an Enqueue submits the queue once it has filled more than half of its capacity since the last submission. Our queue (`queue` in `modules/dstorage.rs`) submitted at exactly half. For example, a queue of 8 holding 4 entries since its last submission submitted itself, where the overview says they stay pending. The reference pages for `EnqueueStatus` and `Query` say the submit happens at half, so the public pages disagree (see the thread). This PR follows the overview. Flipping it is one line in `Lane::submits_at` plus the two boundary tests. ## The fix - A queue now submits itself once the entries enqueued since the last submission are more than half its capacity (`Lane::submits_at`). A queue of 8 holding 4 entries since its last submission now leaves them pending until Submit or a fifth entry. - A queue holds one entry fewer than its capacity: one slot stays free (`Lane::most`, the check the blocking loop already made). So a queue of 2 holds one entry and could never pass half. It submits once full, or its next Enqueue would wait forever. | capacity | entries held | entries that submit | |---|---|---| | 0, 1, 2 | 1 | 1 | | 3 | 2 | 2 | | 4 | 3 | 3 | | 8 | 7 | 5 | ## Testing - `half_a_queue_submits_itself` is now `more_than_half_a_queue_submits_itself`, which uses status entries only and does not sleep. On a capacity-8 queue, after a Submit, four status entries stay `E_PENDING` and the fifth submits all of them. A status with no read before it is written by the submit itself, so the check does not depend on worker timing. With the old threshold the test fails at the fourth entry. - New unit test `a_full_queue_has_submitted_itself`: checks the table above, and that for every capacity up to 1024 a queue submits before it is full, so an Enqueue never waits forever. - Upstream's `a_page_list_the_title_changes_before_its_submit` (from eddde73) enqueues a third read. Two of four no longer submit the queue, and the test needs a self-submit. - `cargo test -p victory-hle`: all pass. `cargo test -p victory-hle --lib dstorage::` passed 55 runs in a row. On the first run after the build, `a_page_list_filled_after_its_request_starts` failed once. It submits explicitly on a capacity-128 queue, so the threshold does not affect it. It races a 2 ms filler thread against the 8 x 1 ms late-list retries. `cargo clippy -p victory-hle --all-targets`: clean. `cargo xtask policy`: ok. - With this and the other conformance fixes merged onto #2057's branch, its suite passes 151 of 152 checks (the remaining one, the console id, is #1717). ## Not covered / Related - Not run with a title (no game data here). No console `Query` measurement to settle which public page is right. - Found by the conformance title in #2057, which lists this check as a known divergence. Whichever of the two merges second takes the entry off the test's `KNOWN` list (a listed check that passes fails that test). ### Rebased onto 63bcca4 - The threshold change sits on top of upstream eddde73. When a queue submits itself (now past half instead of at half), its reads into physical pages and the status entries behind them still wait for the title's Submit. A full queue still submits everything. - `Lane::most` replaces the inline one-free-slot check in `queue`. eddde73's self-submit log line and comments now say "more than half full".
catminou4 commented 2026-11-25 05:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:31Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

DirectStorage queue self-submits past half capacity — queue-depth policy change; check the threshold against real DirectStorage behavior (half-full submit is the documented pattern).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051851199 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074#pullrequestreview-6051851199). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:26:31Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. DirectStorage queue self-submits past half capacity — queue-depth policy change; check the threshold against real DirectStorage behavior (half-full submit is the documented pattern).
DenRakEiw commented 2026-11-25 05:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:41:43Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle --lib dstorage:: — 15 passed, 0 failed (including more_than_half_a_queue_submits_itself and a_full_queue_has_submitted_itself)
  • cargo clippy -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix submitting DirectStorage queues strictly past half capacity rather than at half, with targeted unit tests. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051958998 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074#pullrequestreview-6051958998). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:41:43Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-hle --lib dstorage::` — 15 passed, 0 failed (including `more_than_half_a_queue_submits_itself` and `a_full_queue_has_submitted_itself`) - `cargo clippy -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean fix submitting DirectStorage queues strictly past half capacity rather than at half, with targeted unit tests. Looks good. AI-assisted (Gemini 4 Neon).
jeremygold02 commented 2026-11-25 05:06:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:33:23Z.


Triage verdict — Implementation verified, reference threshold unresolved (2ced771)

Evidence

  • @0xkn0wh3r3’s threshold matches the GDK overview, which says automatic submission occurs after more than half the queue is filled since the last submit. The EnqueueStatus and Query references for the same GDK release say it triggers at half. Both descriptions are relevant to the #2057 conformance expectation. GDK overview · EnqueueStatus · Query

Checks and limits

  • Both submitted tests passed independently on the exact head. A status-only control on a capacity-8 queue showed that four new entries after a manual submit stayed pending and the fifth completed them. A capacity-2 queue submitted its sole usable slot. Restoring only the original threshold made the capacity-8 control fail at four entries. The status-only control needs no sleep or worker progress. Threshold and fixture · Submitted tests
  • These results establish the implementation’s behavior. They do not resolve the conflicting Xbox documentation.

Next step

  • Keep the status-only boundary control and explicit small-queue coverage. Before treating this as console parity in #2057, record which reference governs the expectation or obtain a console Query result for the trigger count.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152950729 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7152950729). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:33:23Z. --- **Triage verdict — Implementation verified, reference threshold unresolved** (`2ced771`) **Evidence** - @0xkn0wh3r3’s threshold matches the GDK overview, which says automatic submission occurs after more than half the queue is filled since the last submit. The `EnqueueStatus` and `Query` references for the same GDK release say it triggers at half. Both descriptions are relevant to the #2057 conformance expectation. [GDK overview](https://learn.microsoft.com/en-us/xbox/gdk/docs/features/console/storage/directstorage/directstorage-overview?view=gdk-2604#idstoragequeuex) · [EnqueueStatus](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/dstorage/interfaces/idstoragequeuex/methods/idstoragequeuex_enqueuestatus?view=gdk-2604) · [Query](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/dstorage/interfaces/idstoragequeuex/methods/idstoragequeuex_query?view=gdk-2604) **Checks and limits** - Both submitted tests passed independently on the exact head. A status-only control on a capacity-8 queue showed that four new entries after a manual submit stayed pending and the fifth completed them. A capacity-2 queue submitted its sole usable slot. Restoring only the original threshold made the capacity-8 control fail at four entries. The status-only control needs no sleep or worker progress. [Threshold and fixture](https://github.com/Marvisak/VIctory/blob/2ced77158f4c7ae7000fd7bad678cb9e0c7b303f/crates/victory-hle/src/modules/dstorage.rs#L599-L617) · [Submitted tests](https://github.com/Marvisak/VIctory/blob/2ced77158f4c7ae7000fd7bad678cb9e0c7b303f/crates/victory-hle/src/modules/dstorage.rs#L1290-L1341) - These results establish the implementation’s behavior. They do not resolve the conflicting Xbox documentation. **Next step** - Keep the status-only boundary control and explicit small-queue coverage. Before treating this as console parity in #2057, record which reference governs the expectation or obtain a console `Query` result for the trigger count. This verification was AI-assisted.
0xkn0wh3r3 commented 2026-11-25 07:03:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:35:29Z.


Thanks @jeremygold02, and you're right that the references disagree. This PR follows the DirectStorage overview: an enqueue that leaves more than half the capacity filled since the last submit triggers one. I took the overview as the description of the behaviour, and the EnqueueStatus and Query pages as describing what those calls report.

I have no console measurement to settle it. #2057's known-divergence entry quotes the overview, so its expectation follows the same reading. If someone with a console finds that Query shows a submit at exactly half, the change is one line in the threshold plus flipping the two boundary tests. Your status-only boundary control and the small-queue cases would catch it either way, so I've kept both.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154950899 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7154950899). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T06:35:29Z. --- Thanks @jeremygold02, and you're right that the references disagree. This PR follows the DirectStorage overview: an enqueue that leaves *more than half* the capacity filled since the last submit triggers one. I took the overview as the description of the behaviour, and the `EnqueueStatus` and `Query` pages as describing what those calls report. I have no console measurement to settle it. #2057's known-divergence entry quotes the overview, so its expectation follows the same reading. If someone with a console finds that `Query` shows a submit at exactly half, the change is one line in the threshold plus flipping the two boundary tests. Your status-only boundary control and the small-queue cases would catch it either way, so I've kept both.
Marvisak commented 2026-11-25 11:05:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:28:08Z.


Automated triage for the maintainers.

Needs work: needs the maintainer's decision. It merges cleanly into current main.

Two of the earlier points are fixed on d3b373f:

  • The commit message, title and description no longer name the SDK, and the diff has no such mention.
  • more_than_half_a_queue_submits_itself (crates/victory-hle/src/modules/dstorage.rs) now uses status entries only and does not sleep. On a capacity-8 queue, entries 1 to 4 after a Submit stay E_PENDING and the fifth submits them all. a_full_queue_has_submitted_itself checks that submits_at <= most for every capacity up to 1024, so an Enqueue cannot wait forever.

Still open: the change to Lane::submits_at changes emulated runtime behaviour, and the public sources disagree. The overview says "more than half", while the EnqueueStatus/Query reference pages say "at half". into_destination's late page-list retry depends on when a queue submits itself. The maintainer should decide which reading to follow. A console Query result, or how the title itself sizes and fills its queues, would settle it. The code is otherwise ready.

On your reply: thanks, both fixes are confirmed. The remaining point is the one you also leave to the maintainer.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159736604 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7159736604). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:28:08Z. --- <!-- victory-triage v1 head=d3b373f76aa3614e9a730c5ac20aa787694c12a9 verdict=needs-work at=2026-11-26T00:26:18Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** It merges cleanly into current `main`. Two of the earlier points are fixed on d3b373f: - The commit message, title and description no longer name the SDK, and the diff has no such mention. - `more_than_half_a_queue_submits_itself` (`crates/victory-hle/src/modules/dstorage.rs`) now uses status entries only and does not sleep. On a capacity-8 queue, entries 1 to 4 after a Submit stay `E_PENDING` and the fifth submits them all. `a_full_queue_has_submitted_itself` checks that `submits_at <= most` for every capacity up to 1024, so an Enqueue cannot wait forever. Still open: the change to `Lane::submits_at` changes emulated runtime behaviour, and the public sources disagree. The overview says "more than half", while the `EnqueueStatus`/`Query` reference pages say "at half". `into_destination`'s late page-list retry depends on when a queue submits itself. The maintainer should decide which reading to follow. A console `Query` result, or how the title itself sizes and fills its queues, would settle it. The code is otherwise ready. On your reply: thanks, both fixes are confirmed. The remaining point is the one you also leave to the maintainer. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 01:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T00:06:23Z.


Thanks. The branch is rebased onto main (63bcca4) and the new head is d3b373f.

  • Commit message: reworded in d3b373f. It now cites "the public DirectStorage documentation for the console queue". The SDK name is gone from the branch's commit, the PR title and the description. The code is unchanged apart from the test below.

  • Conflicting evidence: agreed, this is your call. These are the two public sources the thread cites (links in the verification comment above):

    • the DirectStorage overview, IDStorageQueueX section: the queue submits automatically once more than half of it has filled since the last submit;
    • the IDStorageQueueX::EnqueueStatus and IDStorageQueueX::Query reference pages: the submit happens at half.

    The PR follows the overview's wording. I have no console Query result to settle it. If you prefer the reference pages, I'll flip it: one line in Lane::submits_at plus the two boundary tests.

  • Timing-dependent E_PENDING: fixed in d3b373f. more_than_half_a_queue_submits_itself is now the status-only boundary control from the thread, with no sleep. On a capacity-8 queue, after a Submit, four status entries stay E_PENDING and the fifth submits all of them. A status with no read before it is written inside the submit (Lanes::submit_as -> Lane::flush), so no worker timing is involved. With the old threshold, the test fails at the fourth entry.

Tests: cargo test -p victory-hle passes, and --lib dstorage:: passed 55 runs in a row. On the first run after the build, a_page_list_filled_after_its_request_starts failed once. That test submits explicitly on a capacity-128 queue, so the threshold does not affect it. It races a filler thread's 2 ms sleep against the 8 x 1 ms late-list retries. I did not reproduce the failure on main in 40 runs. cargo clippy -p victory-hle --all-targets is clean, and cargo xtask policy is ok.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178401089 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7178401089). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T00:06:23Z. --- Thanks. The branch is rebased onto `main` (63bcca4) and the new head is d3b373f. - **Commit message:** reworded in d3b373f. It now cites "the public DirectStorage documentation for the console queue". The SDK name is gone from the branch's commit, the PR title and the description. The code is unchanged apart from the test below. - **Conflicting evidence:** agreed, this is your call. These are the two public sources the thread cites (links in the verification comment above): - the DirectStorage overview, `IDStorageQueueX` section: the queue submits automatically once more than half of it has filled since the last submit; - the `IDStorageQueueX::EnqueueStatus` and `IDStorageQueueX::Query` reference pages: the submit happens at half. The PR follows the overview's wording. I have no console `Query` result to settle it. If you prefer the reference pages, I'll flip it: one line in `Lane::submits_at` plus the two boundary tests. - **Timing-dependent `E_PENDING`:** fixed in d3b373f. `more_than_half_a_queue_submits_itself` is now the status-only boundary control from the thread, with no sleep. On a capacity-8 queue, after a Submit, four status entries stay `E_PENDING` and the fifth submits all of them. A status with no read before it is written inside the submit (`Lanes::submit_as` -> `Lane::flush`), so no worker timing is involved. With the old threshold, the test fails at the fourth entry. Tests: `cargo test -p victory-hle` passes, and `--lib dstorage::` passed 55 runs in a row. On the first run after the build, `a_page_list_filled_after_its_request_starts` failed once. That test submits explicitly on a capacity-128 queue, so the threshold does not affect it. It races a filler thread's 2 ms sleep against the 8 x 1 ms late-list retries. I did not reproduce the failure on `main` in 40 runs. `cargo clippy -p victory-hle --all-targets` is clean, and `cargo xtask policy` is ok.
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/2074:upstream-pr/2074'
git switch 'upstream-pr/2074'

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