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

Open
github-bot wants to merge 1 commit from github-bot/gh-2074 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 04:23 UTC · original
0xkn0wh3r3:hle/dstorage-auto-submit-past-half → main · +77 −21 · 1 files · 1 commits · open

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".
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 04:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2074) `0xkn0wh3r3:hle/dstorage-auto-submit-past-half` → `main` · +77 −21 · 1 files · 1 commits · open ## 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".
The public DirectStorage documentation for the console queue says an
Enqueue submits the queue once it has filled more than half of its
capacity since the last submission; the queue submitted at exactly half.
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), so
a queue of 2 holds one entry and could never pass half: it submits once
full, or its next Enqueue would wait forever.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:03 +00:00
Author
Owner

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

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.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7152950729) **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.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 06:35 UTC · original

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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 06:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7154950899) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:28 UTC · original · edited 2026-11-26 00:26 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7159736604) · edited 2026-11-26 00:26 UTC <!-- 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)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 00:06 UTC · original

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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 00:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2074#issuecomment-7178401089) 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 can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2074/head:github-bot/gh-2074'
git switch 'github-bot/gh-2074'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2074'
git switch 'github-bot/gh-2074'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2074'
git switch 'github-bot/gh-2074'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2074'
git switch 'main'
git merge --squash 'github-bot/gh-2074'
git switch 'main'
git merge --ff-only 'github-bot/gh-2074'
git switch 'main'
git merge 'github-bot/gh-2074'
git push origin 'main'
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!2074
No description provided.