startup: support interleaved chunked streams in DirectStorage #1422
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1429"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
following_chunk_ids, queued entries for different files within the same submission now usecontinuerather thanbreak, allowing interleaved multi-file submissions to preserve their respective continuation chains.following_chunk_idsretains 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).offset + stepandexpected + stepagainstuint64_twraparound, and guardeddeltaagainstUINT32_MAXoverflow.try_serve_cached_continuationto handle lookup and extraction of continuation slices fromwork.cached_streams, returningdestination capacity exceededifdestination_sizeexceeds available data.Verification
tests/startup_stub_consumer.cpp:0xA5).Result: 16/16 tests passed (100%):
startup_storage_file_range,startup_storage_alloc_failure,startup_storage_refusal_order: PASSstartup_storage_failure_counts,startup_storage_failure_counts_one_bucket_control: PASSstartup_storage_page_end_counts,startup_storage_page_end_counts_one_bucket_control: PASSstartup_storage_consumer_pair,startup_storage_consumer_pair_accept_refused_control: PASSstartup_storage_refused_reuse,startup_storage_refused_reuse_accept_refused_control: PASSstartup_storage_worker_start,startup_storage_root,startup_storage_root_separator_control: PASSstartup_stubs,startup_storage_directory_batch: PASSPure-Python & diff checks:
All passed without errors.
Refs #1198
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:29:09Z.
Review: COMMENTED
Peer review at
efe1fe2d56bea09168bba48549c951c0abec1268:git diff --checkclean.src/startup_stubs/xcrdapi.cppcleanly factorstry_serve_cached_continuation, supportsintermediate_sizeat+0x34(falling back to+0x38for legacy synthetic tests and sizingbcpack && intermediate_sizedirectly), allowsfollowing_chunk_idsto 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 withread failed.following_chunk_ids,e_offset - offset > UINT_MAXwith(e_offset - offset) % default_step == 0would truncatestatic_cast<unsigned>(e_offset - offset)to 32 bits; guarding(e_offset - offset) <= UINT32_MAX(or< total_size) would avoid that.tests/startup_stub_consumer.cppadds an interleaved-stream ++0x34intermediate_sizetest, thoughbcpack && intermediate_sizedoes not have a dedicated new test case.docs_links_check.py(16 Markdown files, 322 links) andbidi_controls_check.py(1181 tracked files) passed.--preset dev):startup_stubs(0.42s) andstartup_storage_directory_batch(0.14s) 2/2 passed (build4.24s)./O2(--preset release):startup_stubs(0.43s) andstartup_storage_directory_batch(0.13s) 2/2 passed (build2.91s).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.
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.
mainata8946ec0against the same tree withefe1fe2dmerged (clean merge). clang-cl build under Wine 11.0 with vkd3d-proton, RTX 4070 Ti SUPER, i7-10700KF, startup debugger withX2W_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):mainmain+ this PRmain's failures and about 15% more inflated requests at 210 s (41,623 against 36,013).How the runs ended.
main: ran to the 240 s timeout with a blank frame after confirm.maindid 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
mainand 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 exceededandzlib 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.Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T12:32:43Z.
Addressed review feedback:
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:stepis strictlydestination_sizeor0x10000, and each piece must strictly matchexpected = offset + (ids.size() + 1) * step. Any non-matching offset or size for the same file immediately terminates continuation enrollment (break).e_source != source) continue to be skipped (continue), allowing multi-file submissions with interleaved streams to resolve their respective continuation chains.work.cached_streamswith 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.+0x34field change;uncompressed_sizeremains at+0x38matchingmain.delta <= UINT32_MAXcheck as noted by @tedin7.tests/startup_stub_consumer.cpp):0xA5sentinels preserved).0x5Asentinels preserved).Verification:
Result: 6/6 tests passed (100%):
startup_storage_file_range: PASSstartup_stubs: PASS (0.85s)startup_storage_directory_batch: PASSbcpack_prefix_and_mip_tail: PASSbcpack_rans_symbols: PASSbcpack_tables: PASSPure-Python checks:
All passed without errors.
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
src/startup_stubs/xcrdapi.cpp. It also carries the gamesave async test files andruntime_proxy.cpp/save_*.hchanges that main already has, so against current main the diff is larger than the topic and partly reverts newer code (runtime_proxy.cppis 6 additions and 112 deletions against main). Please rebase on current main and keep only the DirectStorage changes.+0x34intermediate-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_idsskips 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.delta > UINT32_MAXguard stops the chain before the 32-bit offset can wrap.Gap in the tests
0x10000step branch (e_offset == offset + 0x10000) has no test. No control reaches it, so a regression there passes.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.following_chunk_idsunchanged 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.continuechanged tobreakone_source != source: KILLED (the interleaved case returned the wrong chain).|| delta > UINT32_MAXremoved: 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.Verification is Linux-only. The WARP and consumer runs are for the Windows gate.
AI-assisted; commands listed were executed locally.
[PR #1429] startup: support intermediate size and interleaved chunked streams in DirectStorageto [PR #1429] startup: support interleaved chunked streams and EOF fallback in DirectStorageImported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:20:55Z.
Review: COMMENTED
Re-review of head
918045b6c5.Previous blockers
src/startup_stubs/xcrdapi.cpp,tests/startup_stub_consumer.cpp), +425/-48.git merge-tree --write-tree origin/main HEAD(maina4ee28a8) merges cleanly. GitHub's merge state reads BLOCKED only because the Windows check was still pending.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, then0x10000), withoffset <= UINT64_MAX - stepguards before the add.try_serve_cached_continuationis a clean extraction. It now also covers the read-failed path (compressed EOF), and it reportsdestination capacity exceededinstead of silently falling through.data == nullptrcase after a capacity failure is handled by the laterif (data)blocks. The outcome and failure cause survive.Findings
delta > UINT32_MAXguards (infollowing_chunk_idsand 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.unsigned detected_step = destination_size;is overwritten throughout_step. Initialising it from the samedestination_size ? ... : 0x10000expression would match the function's own default.0x10000step 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.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.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T05:18:27Z.
Addressed the review feedback from @tedin7:
Rebased onto current
upstream/main(67758cba) with DirectStorage-only changes:CMakeLists.txt,docs/startup-runtime.md,runtime_proxy.cpp,save_*.h, andstartup_gamesave_read_async.*changes that were already inmain.src/startup_stubs/xcrdapi.cppandtests/startup_stub_consumer.cpp, and integrates cleanly withmain'sStorageFailure/failure_result/read_failure_cause/destination_writableandIntermediateSize(+0x34) handling.try_serve_cached_continuationalso propagatesStorageFailure::destination_capacitywhendestination_size > availableand only runs for zlib non-BCPack requests (zlib && !bcpack).Title & body aligned with diff:
startup: support interleaved chunked streams and EOF fallback in DirectStorage(droppingintermediate size) and updated the PR body and inline test comments to match.Test & guard additions:
tests/startup_stub_consumer.cpp(Step64KStatus) exercising the0x10000step branch (e_offset == offset + 0x10000withdestination_size = 32 KiB, serving piece 1 from the stream cache past compressed EOF).destination_size > 0andUINT64_MAX - stepwrap guards infollowing_chunk_idsaroundoffset + destination_sizeandoffset + 0x10000. (Note: inexecute_request, inflated streams are capped at0x80000/ 512 KiB, sodelta >= total_sizebounds runtime chains well belowUINT32_MAX;delta > UINT32_MAXstays as a defensive guard.)Verification
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*).docs_links_check.py,bidi_controls_check.py,git diff --check upstream/main..HEAD): PASS.Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T09:35:58Z.
@R0Y00
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.
[PR #1429] startup: support interleaved chunked streams and EOF fallback in DirectStorageto [PR #1429] startup: support interleaved chunked streams in DirectStorageImported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T15:25:57Z.
@R0Y00 Re-checked and updated at
c94b29e3(rebased on currentupstream/main):following_chunk_ids(e_source != sourcecontinuing rather than breaking the sequence for independent files), keeping it independently reviewable.read failedstatus and do not write to destination buffers.tests/startup_stub_consumer.cppto 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).startup_stubsandstartup_storagetests passed locally (ctest --preset dev -R "^(startup_stubs|startup_storage)"),python tests/docs_links_check.pyandpython tests/bidi_controls_check.pypassed, andgit diff --checkis clean.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.
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,0x10000when 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.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T21:42:40Z.
@R0Y00 Updated at
3fe30776:following_chunk_idsback to the existing stride logic (const unsigned step = destination_size ? destination_size : 0x10000; u64 expected = offset + step;). Removedout_stepanddetected_step.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).tests/startup_stub_consumer.cpp:0xA5) and the gap past EOF control (0x5A).ctest --preset dev -R "^(startup_stubs|startup_storage)": 16/16 passed (100%).python tests/docs_links_check.pyandpython tests/bidi_controls_check.py: passed.git diff --check: clean.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
3fe30776and ranctest --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.