Repository navigation
perf(mobile): keep four bundle chunk reads in flight across the whole manifest (OTA phase C follow-up) - #22376
Conversation
… manifest The fetch ran one worker per asset and paged inside an asset sequentially, so the largest script's 71 chunks were 71 serial round trips while the other readers idled. One window of four chunk reads now covers every (asset, offset) on the host's chunk grid, largest asset first. A read_limited refusal narrows the window and retries the read; eof is still read from the reply. Synthetic manifest (one 71-chunk asset, five small): 72 round trips -> 19. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Baseline moves to a1ee317, the pipelined fetch. 781 goldens change only their `baseline` header line. Six bodies move: mobile-web-bundle-fetch-paged, mobile-web-bundle-build-changed, and the four matrix-mobileweb.bundle-fetch-* goldens. The two bundle-fetch scenarios now bind requests in pipelined order, largest asset first, with every chunk sent before any reply: index.html@0 (#1), index.html@16 (#2), assets/app.js@0 (#3). - fetch-paged: the request set is identical, only reordered. The chunk sender names/ordinals and the scenarioSha256 moved; the replies and the fetched bytes did not. - build-changed: the same reorder, plus one request that is new because pipelining puts it in flight before the refusal lands (index.html@16). The refusal and the checkpoint are unchanged. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Baseline moves from a1ee317 to e94bde3, the comment-only commit on a fenced path. All 787 goldens and the scenarios file change only their `baseline` line. No golden body moved. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
ℹ️ No critical issues — one rough edge around caller abort.
Reviewed changes
- Pipelined chunk window:
fetchMobileWebBundledrops the four per-asset workers for a single pre-planned queue of(asset, offset)reads with up to four in flight across the whole manifest, largest asset first (planChunkReads,runChunkWindowinmobile/src/transport/mobile-web-bundle-fetch.ts). - Read-limited backpressure: a
mobile_web_bundle_read_limitedrefusal at width > 1 narrows the window by one and retries the read; a refusal of a read sent alone fails the fetch. - Slot-filled chunk contract: a non-final chunk shorter than the advertised size, or one that reaches the declared length without
eof, is now refused (asset-short/asset-overlong), which the host's fixed-grid read already guarantees. - Tests and goldens: new
mobile-web-bundle-fetch-pipeline.test.ts(a wave-released fake host) plus adjustedmobile-web-bundle-fetch.test.ts; six bundle goldens andpilot-scenarios.jsonre-recorded, the other 781 goldens repinned toa1ee317.
The invariants hold under inspection: inFlight <= width <= 4 always, width is monotone non-increasing so retries terminate, the window only resolves when every planned read has settled, and a retry re-queues the same read object after a refusal that transferred no bytes. Host and client agree on the fixed 48 KiB grid, so the planned offsets match what the old chained reader asked for.
ℹ️ Nitpicks
MAX_CONCURRENT_ASSET_READSnow bounds chunk reads across the whole manifest rather than one read per asset; the docstring explains the shift, but the identifier still reads as the old meaning.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in this increment — the prior caller-abort note still stands (thread open).
Reviewed changes (incremental, since e94bde3)
- Recording-corpus repin:
6f5a5adffcmoves thebaselineheader of all 788 goldens froma1ee317toe94bde3— the docs/comment commit that touchedmobile-web-bundle-operations.ts. No source or test hunks; the recorded bodies are byte-identical. Provenance-only, consistent with the rpc-recording workflow.
The pipelined chunk-window rewrite itself was reviewed at e94bde3; this increment adds no behavioral surface. The one non-blocking note from that review — a caller abort that lands after the last read is dispatched resolves instead of rejecting — is unchanged and is the open thread.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
@coderabbitai review |
|
…t progress per chunk Design-review fix round, sketch C: four workers take reads from one planned chunk queue, largest asset first. They replace the central pump and the read_limited narrowing. A host frees its read slot before it replies, so a lone fetch capped at four cannot trip the limit. A refusal now fails the fetch, as it did on base, and stops the other reads. - Each asset's buffer is allocated when the plan is built. That removes the nullable buffer and its guard. The per-asset byte count is gone, and the hash is the oracle (S1, S2). - The caller's signal is checked before each read and once after the pool drains, so an abort during the final window rejects with fetch-stopped (S3). The stopped check now covers only the caller's abort. The internal stop only makes late replies skip checks, hashing and progress (S4). - Progress is reported per accepted chunk. completedAssets still counts on completion (S6). - Renames: MAX_CONCURRENT_CHUNK_READS, and `reply` for the RPC reply (N1). - The slot check states exact-slot acceptance once, then classifies the refusal (N3). - Stale test titles and comments are renamed (N4). The synthetic manifest still takes 19 round trips. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Baseline moves to 34fda6f. 782 goldens and the scenarios file change only their `baseline` line. Five bodies move: mobile-web-bundle-fetch-paged and the four matrix-mobileweb.bundle-fetch-* goldens. The only change is bundle-progress effects. One report now lands after the first accepted chunk of index.html (0 assets, 16 bytes), and the later progress ordinals shift by one. Requests, replies and fetched bytes are identical. mobile-web-bundle-build-changed keeps its body, because its one accepted chunk is the whole of assets/app.js. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ing-stop bounds can fail The wave host stopped releasing replies once the fetch settled. Reads that should have been stopped were never answered, so the read_limited bound (7) and the chunk-failure bound (5) held even with no sibling stop at all. It now drains until nothing waits. With the worker's stopped.abort() removed, both bounds fail at 76 requests. assertChunkDescribesAsset's parameter is renamed to `reply`. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… fix Baseline moves from 34fda6f to 97b13ec. All 787 goldens and the scenarios file change only their `baseline` line. No golden body moved. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Worker pool over the planned grid:
fetchMobileWebBundledrops the read-limit-narrowing dispatcher for four workers draining one manifest-wide queue of planned(asset, offset)reads (largest asset first); amobile_web_bundle_read_limitedrefusal now fails the fetch instead of narrowing. - Per-chunk progress and eager reassembly:
planChunkReadsallocates each asset'swholebuffer up front and drops the per-asset byte count;onProgressreports per accepted chunk, andverifyReassembledAssetkeeps only the hash check because each slot is filled exactly once. - Exact-slot acceptance:
assertChunkFillsItsSlotfast-accepts a reply that fills its planned slot (byteLength === min(chunkBytes, declared - offset)and matchingeof), then classifies off-grid replies aschunk-oversize/asset-overlong/asset-no-progress/asset-short. - Caller abort in the final window:
throwIfCallerAborted(args.signal)afterPromise.allmakes an abort that lands once every read is dispatched reject withfetch-stopped, with a new pipeline test. - Tests and recording corpus: the wave-released fake host now keeps draining after the fetch settles so the sibling-stop bounds can fail; the bundle goldens are re-recorded under per-chunk progress and the rest of the corpus is repinned.
The invariants hold: at most four reads in flight (peaks asserted exactly), every planned offset shifted once, a failed read rejects promptly through Promise.all while siblings stop, and the new tests fail when the stop or the final-window check is removed (verified by in-place mutation). The previous review thread on the final-window caller abort is addressed and resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…22394) #22376 pinned its own branch commit, which the squash left off main; the corpus now pins main at 0c2514e, the tree its fenced paths match. Every golden changes only its baseline line. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

The mobile web bundle fetch paged each asset one chunk at a time and ran one reader per asset, so the largest script (71 chunks of 48 KiB) was 71 serial round trips while the other three readers sat idle once the small assets were done. On a relay link every round trip costs the link's latency, so the bundle download was bounded by the biggest asset, not by the four read slots the host offers.
Now every (asset, offset) on the host's chunk grid is planned up front, largest asset first, and four workers pull from that one queue, so the four slots stay busy until the last chunk.
eofis still taken from the reply; because offsets are planned, a reply is accepted only if it fills exactly its slot of the grid (a short non-final chunk isasset-short, a reply past the declared length isasset-overlong). One failed chunk stops every other read. A caller abort during the final window rejects withfetch-stoppedas the contract says. Progress now counts bytes per accepted chunk rather than per completed asset, because largest-first would otherwise show "0 files, 0 bytes" for most of the download. Wire, host, and the released chunk method are unchanged.Measured on a synthetic manifest of one 71-chunk asset plus five one-chunk assets, counting released waves through a fake host: 72 round trips before, 19 after. The new suite fails on the base code with
expected 72 to be 19; the abort-in-the-last-window and progress-before-first-completion cases fail on the previous shape; the fake host keeps draining after the fetch settles, so the sibling-stop bounds fail (76 reads) if the stop is removed.Design review. An Opus review pass took the branch from a hand-rolled dispatcher with read-limit narrowing to this worker pool: narrowing was dropped because the host frees its read slot before replying, so a lone fetch capped at four cannot trip the limit (a
mobile_web_bundle_read_limitedrefusal fails the fetch, as before); a lazily allocated buffer with an unreachable null guard, a redundant per-asset byte count, and an unreachable stop branch were removed; one mutable field per asset remains.Recording goldens. The bundle-fetch goldens record the order requests go out and the progress effects, so they are re-recorded here with
baselinepinned to this branch's last fenced commit (the same shape as #22179). Five bundle goldens change bodies (request order, plus one progress effect per chunk); the two bundle-fetch scenarios inpilot-scenarios.jsonhave their bind/complete steps in the new order; every other golden changes itsbaselineline only. The chunk-placement mutant is still killed. A repin to main's tip follows the squash as its own PR, as #22185 did.Inert today: this code runs only in an
EXPO_PUBLIC_MOBILE_SHELL=otabuild's shell download path. Session-route closure pin unchanged at 4,213.