startup: support interleaved chunked streams in DirectStorage #1422

Merged
Holastor merged 1 commit from upstream-pr/1429 into main 2026-11-25 22:11:29 +00:00
Holastor commented 2026-11-24 11:21:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T11:21:29Z.


DirectStorage submissions with interleaved multi-file requests previously broke chunked stream continuation enrollment:

  1. Continuation Chain Interleaving: In following_chunk_ids, queued entries for different files within the same submission now use continue rather than break, allowing interleaved multi-file submissions to preserve their respective continuation chains.
  2. Retained Existing Stride & Consecutive Offset Checks: For requests on the same file, following_chunk_ids retains the existing stride logic (step = destination_size ? destination_size : 0x10000) and consecutive offset checking (expected = offset + step). Any non-matching size or non-contiguous offset immediately stops continuation enrollment (break).
  3. Overflow Protection: Guarded offset + step and expected + step against uint64_t wraparound, and guarded delta against UINT32_MAX overflow.
  4. Clean Cache Lookup Extraction: Extracted try_serve_cached_continuation to handle lookup and extraction of continuation slices from work.cached_streams, returning destination capacity exceeded if destination_size exceeds available data.
  5. Preserved Failed Read Status: Failed disk reads retain their normal read failure status and do not fall back to the stream cache by geometry alone.

Verification

  • tests/startup_stub_consumer.cpp:
    • Interleaved requests across multiple files in a single queue submission (file 1 piece 0, file 2 standalone, file 1 piece 1 continuation) with full two-file readback verification.
    • Negative control: an independent same-size request at an accepted stride whose read fails on disk (past physical file EOF) fails cleanly with error status and leaves its destination buffer completely untouched (0xA5).
    • Same-file break controls for non-matching compressed size, non-consecutive offset, non-compressed requests, and submission boundaries.
  • All existing DirectStorage and storage-heartbeat controls pass.
ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_stubs|startup_storage)"

Result: 16/16 tests passed (100%):

  • startup_storage_file_range, startup_storage_alloc_failure, startup_storage_refusal_order: PASS
  • startup_storage_failure_counts, startup_storage_failure_counts_one_bucket_control: PASS
  • startup_storage_page_end_counts, startup_storage_page_end_counts_one_bucket_control: PASS
  • startup_storage_consumer_pair, startup_storage_consumer_pair_accept_refused_control: PASS
  • startup_storage_refused_reuse, startup_storage_refused_reuse_accept_refused_control: PASS
  • startup_storage_worker_start, startup_storage_root, startup_storage_root_separator_control: PASS
  • startup_stubs, startup_storage_directory_batch: PASS

Pure-Python & diff checks:

python tests/docs_links_check.py
python tests/bidi_controls_check.py
git diff --check upstream/main..HEAD

All passed without errors.

Refs #1198

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6580635962 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T11:21:29Z. --- DirectStorage submissions with interleaved multi-file requests previously broke chunked stream continuation enrollment: 1. **Continuation Chain Interleaving**: In `following_chunk_ids`, queued entries for different files within the same submission now use `continue` rather than `break`, allowing interleaved multi-file submissions to preserve their respective continuation chains. 2. **Retained Existing Stride & Consecutive Offset Checks**: For requests on the same file, `following_chunk_ids` retains the existing stride logic (`step = destination_size ? destination_size : 0x10000`) and consecutive offset checking (`expected = offset + step`). Any non-matching size or non-contiguous offset immediately stops continuation enrollment (`break`). 3. **Overflow Protection**: Guarded `offset + step` and `expected + step` against `uint64_t` wraparound, and guarded `delta` against `UINT32_MAX` overflow. 4. **Clean Cache Lookup Extraction**: Extracted `try_serve_cached_continuation` to handle lookup and extraction of continuation slices from `work.cached_streams`, returning `destination capacity exceeded` if `destination_size` exceeds available data. 5. **Preserved Failed Read Status**: Failed disk reads retain their normal read failure status and do not fall back to the stream cache by geometry alone. ### Verification - `tests/startup_stub_consumer.cpp`: - Interleaved requests across multiple files in a single queue submission (file 1 piece 0, file 2 standalone, file 1 piece 1 continuation) with full two-file readback verification. - Negative control: an independent same-size request at an accepted stride whose read fails on disk (past physical file EOF) fails cleanly with error status and leaves its destination buffer completely untouched (`0xA5`). - Same-file break controls for non-matching compressed size, non-consecutive offset, non-compressed requests, and submission boundaries. - All existing DirectStorage and storage-heartbeat controls pass. ```powershell ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_stubs|startup_storage)" ``` Result: **16/16 tests passed (100%)**: - `startup_storage_file_range`, `startup_storage_alloc_failure`, `startup_storage_refusal_order`: PASS - `startup_storage_failure_counts`, `startup_storage_failure_counts_one_bucket_control`: PASS - `startup_storage_page_end_counts`, `startup_storage_page_end_counts_one_bucket_control`: PASS - `startup_storage_consumer_pair`, `startup_storage_consumer_pair_accept_refused_control`: PASS - `startup_storage_refused_reuse`, `startup_storage_refused_reuse_accept_refused_control`: PASS - `startup_storage_worker_start`, `startup_storage_root`, `startup_storage_root_separator_control`: PASS - `startup_stubs`, `startup_storage_directory_batch`: PASS Pure-Python & diff checks: ```powershell python tests/docs_links_check.py python tests/bidi_controls_check.py git diff --check upstream/main..HEAD ``` All passed without errors. Refs #1198
tedin7 commented 2026-11-24 12:02:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:29:09Z.

Review: COMMENTED


Peer review at efe1fe2d56bea09168bba48549c951c0abec1268:

  • Diff & safety audit: git diff --check clean. src/startup_stubs/xcrdapi.cpp cleanly factors try_serve_cached_continuation, supports intermediate_size at +0x34 (falling back to +0x38 for legacy synthetic tests and sizing bcpack && intermediate_size directly), allows following_chunk_ids to skip unrelated/interleaved requests within the same submission while detecting the chunk step, and routes EOF-exceeding continuation reads to the stream cache before failing with read failed.
  • Minor observations (non-blocking):
    • In following_chunk_ids, e_offset - offset > UINT_MAX with (e_offset - offset) % default_step == 0 would truncate static_cast<unsigned>(e_offset - offset) to 32 bits; guarding (e_offset - offset) <= UINT32_MAX (or < total_size) would avoid that.
    • tests/startup_stub_consumer.cpp adds an interleaved-stream + +0x34 intermediate_size test, though bcpack && intermediate_size does not have a dedicated new test case.
  • Linux checks: docs_links_check.py (16 Markdown files, 322 links) and bidi_controls_check.py (1181 tracked files) passed.
  • Win2025:
    • Debug (--preset dev): startup_stubs (0.42s) and startup_storage_directory_batch (0.14s) 2/2 passed (build 4.24s).
    • Release /O2 (--preset release): startup_stubs (0.43s) and startup_storage_directory_batch (0.13s) 2/2 passed (build 2.91s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6038397115 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#pullrequestreview-6038397115). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T11:29:09Z. **Review:** COMMENTED --- Peer review at `efe1fe2d56bea09168bba48549c951c0abec1268`: - **Diff & safety audit**: `git diff --check` clean. `src/startup_stubs/xcrdapi.cpp` cleanly factors `try_serve_cached_continuation`, supports `intermediate_size` at `+0x34` (falling back to `+0x38` for legacy synthetic tests and sizing `bcpack && intermediate_size` directly), allows `following_chunk_ids` to skip unrelated/interleaved requests within the same submission while detecting the chunk step, and routes EOF-exceeding continuation reads to the stream cache before failing with `read failed`. - **Minor observations (non-blocking)**: - In `following_chunk_ids`, `e_offset - offset > UINT_MAX` with `(e_offset - offset) % default_step == 0` would truncate `static_cast<unsigned>(e_offset - offset)` to 32 bits; guarding `(e_offset - offset) <= UINT32_MAX` (or `< total_size`) would avoid that. - `tests/startup_stub_consumer.cpp` adds an interleaved-stream + `+0x34` `intermediate_size` test, though `bcpack && intermediate_size` does not have a dedicated new test case. - **Linux checks**: `docs_links_check.py` (16 Markdown files, 322 links) and `bidi_controls_check.py` (1181 tracked files) passed. - **Win2025**: - Debug (`--preset dev`): `startup_stubs` (`0.42s`) and `startup_storage_directory_batch` (`0.14s`) **2/2 passed** (build `4.24s`). - Release `/O2` (`--preset release`): `startup_stubs` (`0.43s`) and `startup_storage_directory_batch` (`0.13s`) **2/2 passed** (build `2.91s`).
R0Y00 commented 2026-11-24 12:02:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T12:02:42Z.

Review: CHANGES_REQUESTED


The interleaving case is useful, but the inferred stride is too broad for the EOF fallback. A later request on the same file with the same compressed size can currently be enrolled as a continuation from an arbitrary aligned gap. If its own read fails, the old stream can be copied into its destination and reported as success. Please keep interleaving across unrelated files, while requiring positive evidence of continuation identity and a checked stride before serving cached bytes. Add a source-built pair of independent same-size records and an EOF case that leave their destinations untouched. Please separate the intermediate-size field change or show how the +0x38 legacy size is distinguished from the request tag when +0x34 is zero.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6038826146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#pullrequestreview-6038826146). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T12:02:42Z. **Review:** CHANGES_REQUESTED --- The interleaving case is useful, but the inferred stride is too broad for the EOF fallback. A later request on the same file with the same compressed size can currently be enrolled as a continuation from an arbitrary aligned gap. If its own read fails, the old stream can be copied into its destination and reported as success. Please keep interleaving across unrelated files, while requiring positive evidence of continuation identity and a checked stride before serving cached bytes. Add a source-built pair of independent same-size records and an EOF case that leave their destinations untouched. Please separate the intermediate-size field change or show how the +0x38 legacy size is distinguished from the request tag when +0x34 is zero.
JohnConnorNPC commented 2026-11-24 12:03:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T11:43:49Z.


Result from one console executable, one run of each build. Fewer failed requests with this PR, but loading still does not complete, and the run with the PR ended in a fault.

Setup. main at a8946ec0 against the same tree with efe1fe2d merged (clean merge). clang-cl build under Wine 11.0 with vkd3d-proton, RTX 4070 Ti SUPER, i7-10700KF, startup debugger with X2W_HOST_CPU=1, X2W_XMEM_SHARED_VIEWS=1, X2W_FAKE_USER=1, render on. Both builds carry #1403, which this host needs to get past the first seconds. The same scripted input takes first-run setup to its confirm step in both runs; the settings file is written at 164.8 s and 165.2 s, so the two timelines line up to within half a second.

DirectStorage heartbeat counters (done / inflated / failed, cumulative):

Time main main + this PR
160 s (before confirm) 8522 / 10623 / 30 8522 / 10623 / 30
170 s 9751 / 14690 / 89 9673 / 13968 / 89
180 s 10184 / 22950 / 184 10146 / 23029 / 288
190 s 10401 / 32511 / 698 10491 / 33942 / 344
200 s 10404 / 34425 / 8605 10491 / 38098 / 3229
210 s 10404 / 36013 / 19833 10491 / 41623 / 8815
220 s 10461 / 40505 / 25339 run ended at 220.4 s
230 s 10461 / 42390 / 35090
  • Up to the confirm step the two builds are identical, including the 30 failures that happen on the setup pages.
  • From 200 s on, the PR has between a third and a half of main's failures and about 15% more inflated requests at 210 s (41,623 against 36,013).
  • The failures still climb steeply with the PR (344 at 190 s, 8,815 at 210 s), so the bulk failure class of #1198 is reduced, not removed.

How the runs ended.

  • main: ran to the 240 s timeout with a blank frame after confirm.
  • With the PR: second-chance access violation in the executable's own code at 220.35 s, a write to a null address. main did not fault in its 240 s. With one run each I cannot say whether the PR exposes that fault by getting the load further or whether it is run-to-run variation.

The executable's own soft assert on a compressed chunk read that does not begin at the chunk's start (the one from #1136) fired 45,124 times after confirm on main and 16,922 times with the PR, in a shorter run.

Not measured: which outcome strings the remaining failures have. My log keeps only the first lines of each kind, so I cannot split them into destination capacity exceeded and zlib failed. Windows is not covered; this is a translation-layer host. If a per-outcome count or a repeat of both runs would help, say which and I will run it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130472019 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7130472019). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-24T11:43:49Z. --- Result from one console executable, one run of each build. Fewer failed requests with this PR, but loading still does not complete, and the run with the PR ended in a fault. **Setup.** `main` at `a8946ec0` against the same tree with `efe1fe2d` merged (clean merge). clang-cl build under Wine 11.0 with vkd3d-proton, RTX 4070 Ti SUPER, i7-10700KF, startup debugger with `X2W_HOST_CPU=1`, `X2W_XMEM_SHARED_VIEWS=1`, `X2W_FAKE_USER=1`, render on. Both builds carry #1403, which this host needs to get past the first seconds. The same scripted input takes first-run setup to its confirm step in both runs; the settings file is written at 164.8 s and 165.2 s, so the two timelines line up to within half a second. **DirectStorage heartbeat counters** (`done` / `inflated` / `failed`, cumulative): | Time | `main` | `main` + this PR | |---|---|---| | 160 s (before confirm) | 8522 / 10623 / 30 | 8522 / 10623 / 30 | | 170 s | 9751 / 14690 / 89 | 9673 / 13968 / 89 | | 180 s | 10184 / 22950 / 184 | 10146 / 23029 / 288 | | 190 s | 10401 / 32511 / 698 | 10491 / 33942 / 344 | | 200 s | 10404 / 34425 / 8605 | 10491 / 38098 / 3229 | | 210 s | 10404 / 36013 / 19833 | 10491 / 41623 / 8815 | | 220 s | 10461 / 40505 / 25339 | run ended at 220.4 s | | 230 s | 10461 / 42390 / 35090 | | - Up to the confirm step the two builds are identical, including the 30 failures that happen on the setup pages. - From 200 s on, the PR has between a third and a half of `main`'s failures and about 15% more inflated requests at 210 s (41,623 against 36,013). - The failures still climb steeply with the PR (344 at 190 s, 8,815 at 210 s), so the bulk failure class of #1198 is reduced, not removed. **How the runs ended.** - `main`: ran to the 240 s timeout with a blank frame after confirm. - With the PR: second-chance access violation in the executable's own code at 220.35 s, a write to a null address. `main` did not fault in its 240 s. With one run each I cannot say whether the PR exposes that fault by getting the load further or whether it is run-to-run variation. The executable's own soft assert on a compressed chunk read that does not begin at the chunk's start (the one from #1136) fired 45,124 times after confirm on `main` and 16,922 times with the PR, in a shorter run. **Not measured:** which outcome strings the remaining failures have. My log keeps only the first lines of each kind, so I cannot split them into `destination capacity exceeded` and `zlib failed`. Windows is not covered; this is a translation-layer host. If a per-outcome count or a repeat of both runs would help, say which and I will run it.
Holastor commented 2026-11-24 13:00:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T12:32:43Z.


Addressed review feedback:

  • Strict continuation identity & checked stride: In following_chunk_ids, removed the inferred arbitrary stride ((e_offset - offset) % default_step == 0). Continuation slices on the same file now require positive evidence of sequential continuity: step is strictly destination_size or 0x10000, and each piece must strictly match expected = offset + (ids.size() + 1) * step. Any non-matching offset or size for the same file immediately terminates continuation enrollment (break).
  • Interleaving across unrelated files preserved: Queued requests for different files (e_source != source) continue to be skipped (continue), allowing multi-file submissions with interleaved streams to resolve their respective continuation chains.
  • Cache fallback boundaries: Only requests strictly enrolled in work.cached_streams with validated sequential strides can be served from the stream cache on EOF reads. Independent same-size records or arbitrary reads beyond EOF do not fall back to the cache, fail cleanly, and leave their destination buffers untouched.
  • Intermediate size separated: Reverted the +0x34 field change; uncompressed_size remains at +0x38 matching main.
  • Overflow guard: Added delta <= UINT32_MAX check as noted by @tedin7.
  • Source-built negative control tests (tests/startup_stub_consumer.cpp):
    • Interleaved requests across different files within a single submission (file 1 piece 0, file 2 standalone, file 1 piece 1 continuation).
    • Pair of independent same-size records on the same file separated by a 256 KiB gap: record 2 fails without cache fallback and leaves destination bytes untouched (0xA5 sentinels preserved).
    • Request beyond EOF fails cleanly and leaves destination bytes untouched (0x5A sentinels preserved).

Verification:

ctest --preset dev --no-tests=error -R '^(startup_stubs|startup_storage|bcpack)' -V

Result: 6/6 tests passed (100%):

  • startup_storage_file_range: PASS
  • startup_stubs: PASS (0.85s)
  • startup_storage_directory_batch: PASS
  • bcpack_prefix_and_mip_tail: PASS
  • bcpack_rans_symbols: PASS
  • bcpack_tables: PASS

Pure-Python checks:

python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

All passed without errors.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7131586779 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7131586779). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T12:32:43Z. --- Addressed review feedback: - **Strict continuation identity & checked stride**: In `following_chunk_ids`, removed the inferred arbitrary stride (`(e_offset - offset) % default_step == 0`). Continuation slices on the same file now require positive evidence of sequential continuity: `step` is strictly `destination_size` or `0x10000`, and each piece must strictly match `expected = offset + (ids.size() + 1) * step`. Any non-matching offset or size for the same file immediately terminates continuation enrollment (`break`). - **Interleaving across unrelated files preserved**: Queued requests for different files (`e_source != source`) continue to be skipped (`continue`), allowing multi-file submissions with interleaved streams to resolve their respective continuation chains. - **Cache fallback boundaries**: Only requests strictly enrolled in `work.cached_streams` with validated sequential strides can be served from the stream cache on EOF reads. Independent same-size records or arbitrary reads beyond EOF do not fall back to the cache, fail cleanly, and leave their destination buffers untouched. - **Intermediate size separated**: Reverted the `+0x34` field change; `uncompressed_size` remains at `+0x38` matching `main`. - **Overflow guard**: Added `delta <= UINT32_MAX` check as noted by @tedin7. - **Source-built negative control tests** (`tests/startup_stub_consumer.cpp`): - Interleaved requests across different files within a single submission (file 1 piece 0, file 2 standalone, file 1 piece 1 continuation). - Pair of independent same-size records on the same file separated by a 256 KiB gap: record 2 fails without cache fallback and leaves destination bytes untouched (`0xA5` sentinels preserved). - Request beyond EOF fails cleanly and leaves destination bytes untouched (`0x5A` sentinels preserved). Verification: ```powershell ctest --preset dev --no-tests=error -R '^(startup_stubs|startup_storage|bcpack)' -V ``` Result: 6/6 tests passed (100%): - `startup_storage_file_range`: PASS - `startup_stubs`: PASS (0.85s) - `startup_storage_directory_batch`: PASS - `bcpack_prefix_and_mip_tail`: PASS - `bcpack_rans_symbols`: PASS - `bcpack_tables`: PASS Pure-Python checks: ```powershell python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` All passed without errors.
tedin7 commented 2026-11-24 17:01:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:39:48Z.

Review: COMMENTED


Re-review of head 3ddddd25 (history rewritten since the last review).

Blocking

  • The PR is CONFLICTING with main (GitHub reports mergeStateStatus DIRTY). The rewritten history is one commit on an old base, and it conflicts in src/startup_stubs/xcrdapi.cpp. It also carries the gamesave async test files and runtime_proxy.cpp/save_*.h changes that main already has, so against current main the diff is larger than the topic and partly reverts newer code (runtime_proxy.cpp is 6 additions and 112 deletions against main). Please rebase on current main and keep only the DirectStorage changes.
  • The title still says "support intermediate size", but the +0x34 intermediate-size handling from the earlier revision is no longer in the diff. Either restore it with a test or drop it from the title and the body.

What looks right

  • following_chunk_ids skips requests for other files and stops the chain on a same-file gap, a different source size, or a submission boundary. That matches the interleaved case the PR describes.
  • The new delta > UINT32_MAX guard stops the chain before the 32-bit offset can wrap.
  • The two new consumer controls (two files interleaved in one submission; independent gap and EOF) assert on distinct outcomes.

Gap in the tests

  • The 0x10000 step branch (e_offset == offset + 0x10000) has no test. No control reaches it, so a regression there passes.
  • The overflow guard has no test either. See the mutation result below.

Checks run (Linux only; the gamesave consumer needs Windows and was not run)

  • python3 tests/docs_links_check.py: self-test passed, 16 files, 330 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1207 files, no bidirectional controls.
  • python3 -m py_compile tests/startup_gamesave_read_async_check.py: ok. The script only wraps the Windows consumer, so it does not exercise the logic on Linux.
  • I compiled following_chunk_ids unchanged into a native harness with stub queue types: interleaved other file, same-file gap, different source size, and a 1,048,578-entry chain at step 0x1000. All passed on the PR code.
  • Mutation 1, continue changed to break on e_source != source: KILLED (the interleaved case returned the wrong chain).
  • Mutation 2, || delta > UINT32_MAX removed: KILLED only by the long-chain case in my harness (returned 1,048,578 ids instead of 1,048,575). It SURVIVES the repo's own tests, which never build a chain that long. A small test with a source offset near 4 GiB would cover it.
  • Both mutations were reverted; the checkout was clean afterwards.

Verification is Linux-only. The WARP and consumer runs are for the Windows gate.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043431732 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#pullrequestreview-6043431732). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:39:48Z. **Review:** COMMENTED --- Re-review of head 3ddddd25 (history rewritten since the last review). **Blocking** - The PR is CONFLICTING with main (GitHub reports mergeStateStatus DIRTY). The rewritten history is one commit on an old base, and it conflicts in `src/startup_stubs/xcrdapi.cpp`. It also carries the gamesave async test files and `runtime_proxy.cpp`/`save_*.h` changes that main already has, so against current main the diff is larger than the topic and partly reverts newer code (`runtime_proxy.cpp` is 6 additions and 112 deletions against main). Please rebase on current main and keep only the DirectStorage changes. - The title still says "support intermediate size", but the `+0x34` intermediate-size handling from the earlier revision is no longer in the diff. Either restore it with a test or drop it from the title and the body. **What looks right** - `following_chunk_ids` skips requests for other files and stops the chain on a same-file gap, a different source size, or a submission boundary. That matches the interleaved case the PR describes. - The new `delta > UINT32_MAX` guard stops the chain before the 32-bit offset can wrap. - The two new consumer controls (two files interleaved in one submission; independent gap and EOF) assert on distinct outcomes. **Gap in the tests** - The `0x10000` step branch (`e_offset == offset + 0x10000`) has no test. No control reaches it, so a regression there passes. - The overflow guard has no test either. See the mutation result below. **Checks run (Linux only; the gamesave consumer needs Windows and was not run)** - `python3 tests/docs_links_check.py`: self-test passed, 16 files, 330 links. - `python3 tests/bidi_controls_check.py`: self-test passed, 1207 files, no bidirectional controls. - `python3 -m py_compile tests/startup_gamesave_read_async_check.py`: ok. The script only wraps the Windows consumer, so it does not exercise the logic on Linux. - I compiled `following_chunk_ids` unchanged into a native harness with stub queue types: interleaved other file, same-file gap, different source size, and a 1,048,578-entry chain at step 0x1000. All passed on the PR code. - Mutation 1, `continue` changed to `break` on `e_source != source`: KILLED (the interleaved case returned the wrong chain). - Mutation 2, `|| delta > UINT32_MAX` removed: KILLED only by the long-chain case in my harness (returned 1,048,578 ids instead of 1,048,575). It SURVIVES the repo's own tests, which never build a chain that long. A small test with a source offset near 4 GiB would cover it. - Both mutations were reverted; the checkout was clean afterwards. Verification is Linux-only. The WARP and consumer runs are for the Windows gate. AI-assisted; commands listed were executed locally.
upstream-sync changed title from [PR #1429] startup: support intermediate size and interleaved chunked streams in DirectStorage to [PR #1429] startup: support interleaved chunked streams and EOF fallback in DirectStorage 2026-11-25 06:00:58 +00:00
tedin7 commented 2026-11-25 06:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:20:55Z.

Review: COMMENTED


Re-review of head 918045b6c5.

Previous blockers

  • Rebased: the diff against main is now 2 files (src/startup_stubs/xcrdapi.cpp, tests/startup_stub_consumer.cpp), +425/-48. git merge-tree --write-tree origin/main HEAD (main a4ee28a8) merges cleanly. GitHub's merge state reads BLOCKED only because the Windows check was still pending.
  • Title no longer claims the intermediate-size handling.

What looks right

  • following_chunk_ids (xcrdapi.cpp ~L180-240) skips requests for other files and breaks on a same-file source-size mismatch, a non-consecutive offset or a submission boundary. The step is detected from the first follower (destination_size, then 0x10000), with offset <= UINT64_MAX - step guards before the add.
  • try_serve_cached_continuation is a clean extraction. It now also covers the read-failed path (compressed EOF), and it reports destination capacity exceeded instead of silently falling through.
  • The data == nullptr case after a capacity failure is handled by the later if (data) blocks. The outcome and failure cause survive.

Findings

  • P1=0.
  • P2=0.
  • Nit, test gap: the delta > UINT32_MAX guards (in following_chunk_ids and in the cached slice path) have no test. A chain past 4 GiB is impractical in the consumer, so a note in the PR body that this is guard-only would be enough.
  • Nit: unsigned detected_step = destination_size; is overwritten through out_step. Initialising it from the same destination_size ? ... : 0x10000 expression would match the function's own default.
  • Covered: the new consumer controls hit interleaved files in one submission, the 0x10000 step with a 32 KiB destination, and the independent gap plus EOF case (destination untouched, 0x5A fill checked).

Checks run locally (Linux)

  • python3 tests/docs_links_check.py: self-test passed, 18 files, 407 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1487 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • gh pr checks: Linux Python checks and gfx1013 fixtures pass. Windows build and test was pending when I looked.
  • The touched code is Windows-only (startup_stub_consumer.cpp). I did not run a mutation or a Win2025 run in this pass. The consumer controls need the Windows build, so please wait for the Windows CI result and the Stage-2 WARP run before Ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052239438 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#pullrequestreview-6052239438). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:20:55Z. **Review:** COMMENTED --- Re-review of head 918045b6c54b2be70db2551441cc7f723bf715ff. **Previous blockers** - Rebased: the diff against main is now 2 files (`src/startup_stubs/xcrdapi.cpp`, `tests/startup_stub_consumer.cpp`), +425/-48. `git merge-tree --write-tree origin/main HEAD` (main a4ee28a8) merges cleanly. GitHub's merge state reads BLOCKED only because the Windows check was still pending. - Title no longer claims the intermediate-size handling. **What looks right** - `following_chunk_ids` (xcrdapi.cpp ~L180-240) skips requests for other files and breaks on a same-file source-size mismatch, a non-consecutive offset or a submission boundary. The step is detected from the first follower (`destination_size`, then `0x10000`), with `offset <= UINT64_MAX - step` guards before the add. - `try_serve_cached_continuation` is a clean extraction. It now also covers the read-failed path (compressed EOF), and it reports `destination capacity exceeded` instead of silently falling through. - The `data == nullptr` case after a capacity failure is handled by the later `if (data)` blocks. The outcome and failure cause survive. **Findings** - P1=0. - P2=0. - Nit, test gap: the `delta > UINT32_MAX` guards (in `following_chunk_ids` and in the cached slice path) have no test. A chain past 4 GiB is impractical in the consumer, so a note in the PR body that this is guard-only would be enough. - Nit: `unsigned detected_step = destination_size;` is overwritten through `out_step`. Initialising it from the same `destination_size ? ... : 0x10000` expression would match the function's own default. - Covered: the new consumer controls hit interleaved files in one submission, the `0x10000` step with a 32 KiB destination, and the independent gap plus EOF case (destination untouched, 0x5A fill checked). **Checks run locally (Linux)** - `python3 tests/docs_links_check.py`: self-test passed, 18 files, 407 links. - `python3 tests/bidi_controls_check.py`: self-test passed, 1487 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean. - `gh pr checks`: Linux Python checks and gfx1013 fixtures pass. Windows build and test was pending when I looked. - The touched code is Windows-only (`startup_stub_consumer.cpp`). I did not run a mutation or a Win2025 run in this pass. The consumer controls need the Windows build, so please wait for the Windows CI result and the Stage-2 WARP run before Ready. AI-assisted; commands listed were executed locally.
Holastor commented 2026-11-25 06:01:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T05:18:27Z.


Addressed the review feedback from @tedin7:

  1. Rebased onto current upstream/main (67758cba) with DirectStorage-only changes:

    • Dropped the unrelated CMakeLists.txt, docs/startup-runtime.md, runtime_proxy.cpp, save_*.h, and startup_gamesave_read_async.* changes that were already in main.
    • The PR diff now touches only src/startup_stubs/xcrdapi.cpp and tests/startup_stub_consumer.cpp, and integrates cleanly with main's StorageFailure / failure_result / read_failure_cause / destination_writable and IntermediateSize (+0x34) handling.
    • try_serve_cached_continuation also propagates StorageFailure::destination_capacity when destination_size > available and only runs for zlib non-BCPack requests (zlib && !bcpack).
  2. Title & body aligned with diff:

    • Updated the PR title to startup: support interleaved chunked streams and EOF fallback in DirectStorage (dropping intermediate size) and updated the PR body and inline test comments to match.
  3. Test & guard additions:

    • Added a control in tests/startup_stub_consumer.cpp (Step64KStatus) exercising the 0x10000 step branch (e_offset == offset + 0x10000 with destination_size = 32 KiB, serving piece 1 from the stream cache past compressed EOF).
    • Added destination_size > 0 and UINT64_MAX - step wrap guards in following_chunk_ids around offset + destination_size and offset + 0x10000. (Note: in execute_request, inflated streams are capped at 0x80000 / 512 KiB, so delta >= total_size bounds runtime chains well below UINT32_MAX; delta > UINT32_MAX stays as a defensive guard.)

Verification

ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_stubs|startup_storage)"
  • 16/16 passed (startup_stubs, startup_storage_directory_batch, startup_storage_file_range, startup_storage_alloc_failure, startup_storage_refusal_order, startup_storage_failure_counts*, startup_storage_page_end_counts*, startup_storage_consumer_pair*, startup_storage_refused_reuse*, startup_storage_worker_start, startup_storage_root*).
  • Pure-Python & diff checks (docs_links_check.py, bidi_controls_check.py, git diff --check upstream/main..HEAD): PASS.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153644684 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7153644684). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-25T05:18:27Z. --- Addressed the review feedback from @tedin7: 1. **Rebased onto current `upstream/main` (`67758cba`) with DirectStorage-only changes**: - Dropped the unrelated `CMakeLists.txt`, `docs/startup-runtime.md`, `runtime_proxy.cpp`, `save_*.h`, and `startup_gamesave_read_async.*` changes that were already in `main`. - The PR diff now touches only `src/startup_stubs/xcrdapi.cpp` and `tests/startup_stub_consumer.cpp`, and integrates cleanly with `main`'s `StorageFailure` / `failure_result` / `read_failure_cause` / `destination_writable` and `IntermediateSize` (`+0x34`) handling. - `try_serve_cached_continuation` also propagates `StorageFailure::destination_capacity` when `destination_size > available` and only runs for zlib non-BCPack requests (`zlib && !bcpack`). 2. **Title & body aligned with diff**: - Updated the PR title to `startup: support interleaved chunked streams and EOF fallback in DirectStorage` (dropping `intermediate size`) and updated the PR body and inline test comments to match. 3. **Test & guard additions**: - Added a control in `tests/startup_stub_consumer.cpp` (`Step64KStatus`) exercising the `0x10000` step branch (`e_offset == offset + 0x10000` with `destination_size = 32 KiB`, serving piece 1 from the stream cache past compressed EOF). - Added `destination_size > 0` and `UINT64_MAX - step` wrap guards in `following_chunk_ids` around `offset + destination_size` and `offset + 0x10000`. (Note: in `execute_request`, inflated streams are capped at `0x80000` / 512 KiB, so `delta >= total_size` bounds runtime chains well below `UINT32_MAX`; `delta > UINT32_MAX` stays as a defensive guard.) ### Verification ```powershell ctest --preset dev --no-tests=error --output-on-failure -R "^(startup_stubs|startup_storage)" ``` - **16/16 passed** (`startup_stubs`, `startup_storage_directory_batch`, `startup_storage_file_range`, `startup_storage_alloc_failure`, `startup_storage_refusal_order`, `startup_storage_failure_counts*`, `startup_storage_page_end_counts*`, `startup_storage_consumer_pair*`, `startup_storage_refused_reuse*`, `startup_storage_worker_start`, `startup_storage_root*`). - Pure-Python & diff checks (`docs_links_check.py`, `bidi_controls_check.py`, `git diff --check upstream/main..HEAD`): **PASS**.
Holastor commented 2026-11-25 10:05:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T09:35:58Z.


@R0Y00

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7158547889 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7158547889). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-25T09:35:58Z. --- @R0Y00
R0Y00 commented 2026-11-25 15:02:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T14:40:12Z.


I rechecked 918045b6. The update narrows the candidate offsets and checks overflow. A same-file request of the same compressed size at an accepted stride still enters the continuation list by geometry alone. Its request ID then confirms only that it was enrolled, even on the failed-read path.

Please keep the interleaving change independently reviewable. The fallback needs evidence that the second request belongs to the first stream. Extend the negative case to an independent same-size request at an accepted stride whose own read fails, with destination bytes and failure status checked. If the request fields carry no such identity, keep the failed-read path for that case.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7165631811 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7165631811). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T14:40:12Z. --- I rechecked `918045b6`. The update narrows the candidate offsets and checks overflow. A same-file request of the same compressed size at an accepted stride still enters the continuation list by geometry alone. Its request ID then confirms only that it was enrolled, even on the failed-read path. Please keep the interleaving change independently reviewable. The fallback needs evidence that the second request belongs to the first stream. Extend the negative case to an independent same-size request at an accepted stride whose own read fails, with destination bytes and failure status checked. If the request fields carry no such identity, keep the failed-read path for that case.
upstream-sync changed title from [PR #1429] startup: support interleaved chunked streams and EOF fallback in DirectStorage to [PR #1429] startup: support interleaved chunked streams in DirectStorage 2026-11-25 16:04:59 +00:00
Holastor commented 2026-11-25 16:05:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T15:25:57Z.


@R0Y00 Re-checked and updated at c94b29e3 (rebased on current upstream/main):

  1. Scoped strictly to interleaving: Kept this PR focused on the multi-file interleaving fix in following_chunk_ids (e_source != source continuing rather than breaking the sequence for independent files), keeping it independently reviewable.
  2. Removed failed-read fallback: Removed the fallback from failed disk reads to the stream cache. As noted, geometry alone cannot prove stream identity, so failed disk reads strictly retain their normal read failed status and do not write to destination buffers.
  3. Negative control at accepted stride: Updated the negative control in tests/startup_stub_consumer.cpp to an independent same-size request at an accepted stride (64 KiB) whose disk read fails (past physical file EOF), verifying that it reports failure and leaves its destination buffer untouched (0xA5).
  4. Verification: 16/16 startup_stubs and startup_storage tests passed locally (ctest --preset dev -R "^(startup_stubs|startup_storage)"), python tests/docs_links_check.py and python tests/bidi_controls_check.py passed, and git diff --check is clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7166832585 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7166832585). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-25T15:25:57Z. --- @R0Y00 Re-checked and updated at `c94b29e3` (rebased on current `upstream/main`): 1. **Scoped strictly to interleaving**: Kept this PR focused on the multi-file interleaving fix in `following_chunk_ids` (`e_source != source` continuing rather than breaking the sequence for independent files), keeping it independently reviewable. 2. **Removed failed-read fallback**: Removed the fallback from failed disk reads to the stream cache. As noted, geometry alone cannot prove stream identity, so failed disk reads strictly retain their normal `read failed` status and do not write to destination buffers. 3. **Negative control at accepted stride**: Updated the negative control in `tests/startup_stub_consumer.cpp` to an independent same-size request at an accepted stride (`64 KiB`) whose disk read fails (past physical file EOF), verifying that it reports failure and leaves its destination buffer untouched (`0xA5`). 4. **Verification**: 16/16 `startup_stubs` and `startup_storage` tests passed locally (`ctest --preset dev -R "^(startup_stubs|startup_storage)"`), `python tests/docs_links_check.py` and `python tests/bidi_controls_check.py` passed, and `git diff --check` is clean.
Holastor commented 2026-11-25 21:01:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T20:52:03Z.


@tedin7 @R0Y00 Ready for review and merge into main when you have time.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7174295466 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7174295466). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-25T20:52:03Z. --- @tedin7 @R0Y00 Ready for review and merge into main when you have time.
R0Y00 commented 2026-11-25 22:02:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:21:27Z.


I rechecked c94b29e3. The earlier failed-read fallback is gone. The implementation still adds a second continuation stride, 0x10000 when destination size differs, and the new 32 KiB test expects that broader inference. The past-EOF control verifies the failed read only. A successful read of unrelated same-file bytes at that stride, without a zlib header and with an equal compressed length, can still qualify by geometry alone.

Please keep the interleaving change focused on skipping other files while retaining the existing stride. Keep the two-file readback and same-file break controls. A different stride can be reviewed independently with a proven record identity and a successful-read unrelated-payload control.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7174967606 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7174967606). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T21:21:27Z. --- I rechecked `c94b29e3`. The earlier failed-read fallback is gone. The implementation still adds a second continuation stride, `0x10000` when destination size differs, and the new 32 KiB test expects that broader inference. The past-EOF control verifies the failed read only. A successful read of unrelated same-file bytes at that stride, without a zlib header and with an equal compressed length, can still qualify by geometry alone. Please keep the interleaving change focused on skipping other files while retaining the existing stride. Keep the two-file readback and same-file break controls. A different stride can be reviewed independently with a proven record identity and a successful-read unrelated-payload control.
Holastor commented 2026-11-25 22:02:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T21:42:40Z.


@R0Y00 Updated at 3fe30776:

  1. Retained existing stride: Reverted the dynamic second stride inference in following_chunk_ids back to the existing stride logic (const unsigned step = destination_size ? destination_size : 0x10000; u64 expected = offset + step;). Removed out_step and detected_step.
  2. Focused strictly on multi-file interleaving: Kept the change scoped to skipping requests for other files (if (e_source != source) continue;) so that interleaved multi-file submissions preserve their respective continuation chains, while any non-matching size, non-consecutive offset, non-compressed request, or submission boundary for the same file strictly ends enrollment (break).
  3. Fixture controls in tests/startup_stub_consumer.cpp:
    • Removed the 32 KiB destination / 64 KiB step test.
    • Retained the interleaved two-file readback test (verifying full payload readback for both files across interleaved queue entries).
    • Retained the at-stride failed read negative control past physical EOF (verifying error status and untouched destination buffer 0xA5) and the gap past EOF control (0x5A).
    • Retained all same-file break controls (non-matching compressed size, non-consecutive offset, non-compressed request, submission boundary).
  4. Verification:
    • ctest --preset dev -R "^(startup_stubs|startup_storage)": 16/16 passed (100%).
    • python tests/docs_links_check.py and python tests/bidi_controls_check.py: passed.
    • git diff --check: clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175439326 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#issuecomment-7175439326). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-25T21:42:40Z. --- @R0Y00 Updated at `3fe30776`: 1. **Retained existing stride**: Reverted the dynamic second stride inference in `following_chunk_ids` back to the existing stride logic (`const unsigned step = destination_size ? destination_size : 0x10000; u64 expected = offset + step;`). Removed `out_step` and `detected_step`. 2. **Focused strictly on multi-file interleaving**: Kept the change scoped to skipping requests for other files (`if (e_source != source) continue;`) so that interleaved multi-file submissions preserve their respective continuation chains, while any non-matching size, non-consecutive offset, non-compressed request, or submission boundary for the same file strictly ends enrollment (`break`). 3. **Fixture controls in `tests/startup_stub_consumer.cpp`**: - Removed the 32 KiB destination / 64 KiB step test. - Retained the interleaved two-file readback test (verifying full payload readback for both files across interleaved queue entries). - Retained the at-stride failed read negative control past physical EOF (verifying error status and untouched destination buffer `0xA5`) and the gap past EOF control (`0x5A`). - Retained all same-file break controls (non-matching compressed size, non-consecutive offset, non-compressed request, submission boundary). 4. **Verification**: - `ctest --preset dev -R "^(startup_stubs|startup_storage)"`: 16/16 passed (100%). - `python tests/docs_links_check.py` and `python tests/bidi_controls_check.py`: passed. - `git diff --check`: clean.
upstream-sync closed this pull request 2026-11-25 23:01:36 +00:00
R0Y00 commented 2026-11-25 23:01:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:10:39Z.

Review: APPROVED


The interleaving revision addresses my previous request. It retains the existing stride and same-file stop conditions, and a failed physical read cannot enter the continuation-cache lookup. I rebuilt Windows Release at 3fe30776 and ran ctest --preset release --no-tests=error -R '^(startup_stubs|startup_storage_directory_batch)$' -V (2 passed, 0 skipped). The two-archive fixture checks all ten readbacks, including the at-stride and off-stride EOF sentinels and correct reads after both failures.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065685807 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1429#pullrequestreview-6065685807). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T22:10:39Z. **Review:** APPROVED --- The interleaving revision addresses my previous request. It retains the existing stride and same-file stop conditions, and a failed physical read cannot enter the continuation-cache lookup. I rebuilt Windows Release at `3fe30776` and ran `ctest --preset release --no-tests=error -R '^(startup_stubs|startup_storage_directory_batch)$' -V` (2 passed, 0 skipped). The two-archive fixture checks all ten readbacks, including the at-stride and off-stride EOF sentinels and correct reads after both failures.
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
R0Y00/Xbox2Windows!1422
No description provided.