dstorage: reads into physical pages wait for the title's Submit (DSTORAGE-HOLD-PAGE-READS) #2124

Manually merged
github merged 1 commit from github-bot/gh-2124 into main 2026-11-26 14:53:20 +00:00 AGit
Owner

@⁠QemmHD on GitHub · 2026-11-25 21:35 UTC · original
ubiquitarianism:claude/dstorage-hold-page-reads → main · +456 −12 · 4 files · 1 commits · merged 2026-11-26 14:41 UTC

A queue with auto-submit on submits itself once the entries enqueued since the last submit reach half its capacity (enqueue() → submit_locked()). A request into physical pages names its pages through DestinationPageArray, which the worker reads only when the request runs (publish() → page_transfer()). The title fills that page table just before it calls Submit. So a read started by the self-submit finds page 0 (the entry fails with E_INVALIDARG) or the page number the slot held before (the data lands in a page that now belongs to something else, with no error).

  • A self-submit stops at the first read into physical pages. That read and every entry behind it wait for the title's Submit, in order, so a status entry, fence or event behind a held read still comes after it.
  • A full queue submits the held entries, since the title cannot call Submit while it waits in an enqueue. Close submits everything, as before.
  • LEONIDA_DSTORAGE_HOLD_MS bounds a hold (2000 ms by default, 0 for no limit), so a path that never calls Submit cannot stall for good. LEONIDA_DSTORAGE_HOLD_PAGES=0 restores the old behaviour.
  • [rt] ds-hold counts self-submits, held reads, full-queue and timed releases, and page lists that were still empty when read.

Tests (Windows 11, RTX 4070 SUPER, VS 2022, Ninja)

  • dstorage_test with the new test_page_reads_wait_for_submit: 551 checks pass. With LEONIDA_DSTORAGE_HOLD_PAGES=0, 15 of them fail: the read lands in the page the list named before, and an empty list fails.
  • Full ctest: everything passes except the tests already flaky on this machine (xs_proxy_mock, d3d12_depth_resolve under the driver's MFAA setting). None of them build dstorage.
  • Consistency set: 597 passed; only the existing test_runtime_paths workflow check fails, as on main.

Idea from fxceless/victory-fork 79cfdd9 (after Marvisak/VIctory eddde73), written anew for this queue.

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf

**@⁠QemmHD** on GitHub · 2026-11-25 21:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2124) `ubiquitarianism:claude/dstorage-hold-page-reads` → `main` · +456 −12 · 4 files · 1 commits · merged 2026-11-26 14:41 UTC A queue with auto-submit on submits itself once the entries enqueued since the last submit reach half its capacity (`enqueue()` → `submit_locked()`). A request into physical pages names its pages through `DestinationPageArray`, which the worker reads only when the request runs (`publish()` → `page_transfer()`). The title fills that page table just before it calls Submit. So a read started by the self-submit finds page 0 (the entry fails with E_INVALIDARG) or the page number the slot held before (the data lands in a page that now belongs to something else, with no error). - A self-submit stops at the first read into physical pages. That read and every entry behind it wait for the title's Submit, in order, so a status entry, fence or event behind a held read still comes after it. - A full queue submits the held entries, since the title cannot call Submit while it waits in an enqueue. Close submits everything, as before. - `LEONIDA_DSTORAGE_HOLD_MS` bounds a hold (2000 ms by default, 0 for no limit), so a path that never calls Submit cannot stall for good. `LEONIDA_DSTORAGE_HOLD_PAGES=0` restores the old behaviour. - `[rt] ds-hold` counts self-submits, held reads, full-queue and timed releases, and page lists that were still empty when read. **Tests** (Windows 11, RTX 4070 SUPER, VS 2022, Ninja) - `dstorage_test` with the new `test_page_reads_wait_for_submit`: 551 checks pass. With `LEONIDA_DSTORAGE_HOLD_PAGES=0`, 15 of them fail: the read lands in the page the list named before, and an empty list fails. - Full ctest: everything passes except the tests already flaky on this machine (xs_proxy_mock, d3d12_depth_resolve under the driver's MFAA setting). None of them build dstorage. - Consistency set: 597 passed; only the existing `test_runtime_paths` workflow check fails, as on main. Idea from fxceless/victory-fork 79cfdd9 (after Marvisak/VIctory eddde73), written anew for this queue. AI-assisted (Claude Code, Claude Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
A queue with auto-submit on submits itself once the entries enqueued
since the last submit reach half its capacity. A request whose
destination is a physical page list names its pages through
DestinationPageArray, a pointer into the title's own page-number table,
and the worker reads that table only when the request runs
(page_transfer). The title fills the page table just before Submit. So a
read started by the self-submit found page 0 (the entry failed) or the
number the slot held before (the data landed in a page that now belongs
to something else, with no error).

A self-submit now stops at the first read into physical pages. That read
and every entry behind it wait for the title's Submit, in order, so a
status entry, fence or event behind a held read still comes after it. A
full queue submits the held entries too, since the title cannot call
Submit while it waits in an enqueue. Close submits everything, as
before. A hold also ends after LEONIDA_DSTORAGE_HOLD_MS (2000 ms unless
set; 0 means no limit), so a path that never calls Submit cannot stall
for good. LEONIDA_DSTORAGE_HOLD_PAGES=0 restores the old self-submit of
everything.

"[rt] ds-hold" counts self-submits, held reads, full-queue and timed
releases, and destination lists that named page 0 when written. It is
printed at each power of two of the counter that moved
(runtime/src/dstorage_hold.h).

The idea is from Marvisak/VIctory eddde73; it also appears in
fxceless/victory-fork 79cfdd9. Written anew for this queue.

Test: dstorage_test, test_page_reads_wait_for_submit: a list changed
between the self-submit and Submit, a list still empty at the
self-submit, a full queue, the default and an explicit time limit, no
limit, the switch, and the page-0 counter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:18:48 +00:00
Author
Owner

@⁠qhukz13 on GitHub · 2026-11-26 00:25 UTC · original

Review at 6b09de493 (code reading plus a native Windows run of dstorage_test, see the end). The hold keeps queue order (everything behind a held read waits with it), a full queue releases it because the title cannot call Submit from inside an enqueue, Close submits everything, and the worker only times a hold while it has nothing submitted to run. Reads right to me.

One question before it is on by default: the hold changes behaviour for any title path that enqueues a read into physical pages, then a status/fence/event entry, and waits on that entry without calling Submit, counting on the self-submit at half capacity. Today that path runs; with the hold it waits LEONIDA_DSTORAGE_HOLD_MS (2 s) per occurrence and then goes with the page list as it is. The synthetic test cannot say whether the title does that. Your own [rt] ds-hold line answers it: timed_releases and full_releases from one retail boot past the story load (and page0_entries with the hold off, to see how often the early read actually hit an unfilled list). If timed_releases is 0 there, the 2 s default is safe; if not, those stalls would show up as missed frames at the world start.

Native Windows 10 run (the description has Windows 11): GTX 1050 Ti host, Windows 10 Pro 19045, MSVC RelWithDebInfo, this head merged onto main 61732aca1 (clean). dstorage passes 3/3, plain and with LEONIDA_VK_VALIDATION=1. With LEONIDA_DSTORAGE_HOLD_PAGES=0 it fails 3/3: dstorage: 551 checks, 16 failures here (the description says 15 for that mode, so one more on this machine), with 0x89240007 / 0x8924000f entry failures, so the new test does tell the two modes apart.

AI-assisted (Claude Code).

**@⁠qhukz13** on GitHub · 2026-11-26 00:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2124#issuecomment-7178742565) Review at `6b09de493` (code reading plus a native Windows run of `dstorage_test`, see the end). The hold keeps queue order (everything behind a held read waits with it), a full queue releases it because the title cannot call Submit from inside an enqueue, `Close` submits everything, and the worker only times a hold while it has nothing submitted to run. Reads right to me. One question before it is on by default: the hold changes behaviour for any title path that enqueues a read into physical pages, then a status/fence/event entry, and waits on that entry **without** calling Submit, counting on the self-submit at half capacity. Today that path runs; with the hold it waits `LEONIDA_DSTORAGE_HOLD_MS` (2 s) per occurrence and then goes with the page list as it is. The synthetic test cannot say whether the title does that. Your own `[rt] ds-hold` line answers it: `timed_releases` and `full_releases` from one retail boot past the story load (and `page0_entries` with the hold off, to see how often the early read actually hit an unfilled list). If `timed_releases` is 0 there, the 2 s default is safe; if not, those stalls would show up as missed frames at the world start. Native Windows 10 run (the description has Windows 11): GTX 1050 Ti host, Windows 10 Pro 19045, MSVC RelWithDebInfo, this head merged onto main `61732aca1` (clean). `dstorage` passes 3/3, plain and with `LEONIDA_VK_VALIDATION=1`. With `LEONIDA_DSTORAGE_HOLD_PAGES=0` it fails 3/3: `dstorage: 551 checks, 16 failures` here (the description says 15 for that mode, so one more on this machine), with `0x89240007` / `0x8924000f` entry failures, so the new test does tell the two modes apart. AI-assisted (Claude Code).
Author
Owner

@⁠QemmHD on GitHub · 2026-11-26 00:39 UTC · original

Thanks for the review and the Windows 10 / GTX 1050 Ti run.

On the question: I have data from real boots. Our test build has carried this same hold (same code, LEONIDA_DSTORAGE_HOLD_MS=2000 default) for the last ~10 boots on an RTX 4070 SUPER, and several of them got past the end of the main load to the start of the world. In none of them did a [rt] ds-hold line appear. That line is printed the first time any of its counters moves, and the self-submit counter moves on every half-capacity self-submit, even one that holds nothing. So in those boots no queue ever self-submitted at half capacity: zero holds, so timed_releases and full_releases were 0, and the case you describe (waiting on an entry without Submit, relying on the self-submit) didn't come up. The title we test seems to call Submit itself well before half capacity, or creates its queues with auto-submit off. I'll add a one-time line per queue (capacity, auto-submit on/off) so this is visible directly instead of inferred from a missing line.

Your point stands for other titles, though. If you or the maintainers prefer, I can make the timed release default to 0 ms (no hold time, only the full-queue release), or ship the hold off by default behind LEONIDA_DSTORAGE_HOLD_PAGES=1 until there is data from more titles. Happy to do either.

On 16 vs 15 failures with the hold off: that mode is only there to show the test tells the two modes apart; the count isn't asserted. Which reads the worker reaches before the test rewrites the page list depends on thread timing, so a one-check difference between machines is expected.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-26 00:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2124#issuecomment-7178987374) Thanks for the review and the Windows 10 / GTX 1050 Ti run. On the question: I have data from real boots. Our test build has carried this same hold (same code, `LEONIDA_DSTORAGE_HOLD_MS=2000` default) for the last ~10 boots on an RTX 4070 SUPER, and several of them got past the end of the main load to the start of the world. In none of them did a `[rt] ds-hold` line appear. That line is printed the first time any of its counters moves, and the self-submit counter moves on every half-capacity self-submit, even one that holds nothing. So in those boots no queue ever self-submitted at half capacity: zero holds, so `timed_releases` and `full_releases` were 0, and the case you describe (waiting on an entry without Submit, relying on the self-submit) didn't come up. The title we test seems to call Submit itself well before half capacity, or creates its queues with auto-submit off. I'll add a one-time line per queue (capacity, auto-submit on/off) so this is visible directly instead of inferred from a missing line. Your point stands for other titles, though. If you or the maintainers prefer, I can make the timed release default to 0 ms (no hold time, only the full-queue release), or ship the hold off by default behind `LEONIDA_DSTORAGE_HOLD_PAGES=1` until there is data from more titles. Happy to do either. On 16 vs 15 failures with the hold off: that mode is only there to show the test tells the two modes apart; the count isn't asserted. Which reads the worker reaches before the test rewrites the page list depends on thread timing, so a one-check difference between machines is expected. AI-assisted (Claude Code, Claude Opus 5.5).
github manually merged commit cb825bb786 into main 2026-11-26 14:53:20 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 14:42 UTC · original

Thank you, @⁠QemmHD. This went into main through #2350 (RT-LINUX-AMD-WORLD), merged at your head 6b09de493 with your commits and authorship kept. GitHub shows this PR as merged for that reason, so nothing needs closing.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2124#issuecomment-7195198218) Thank you, @⁠QemmHD. This went into `main` through #2350 (RT-LINUX-AMD-WORLD), merged at your head `6b09de493` with your commits and authorship kept. GitHub shows this PR as merged for that reason, so nothing needs closing. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.