Repository navigation
Keep the blocks an archive's index was read from, so a worker started again reads nothing - #153
Merged
Merged
Conversation
The block cache under small reads over HTTP lives in the Service Worker's memory, and Chromium stops an idle worker after about thirty seconds, so a reload read the archive's tail and head again before the worker answered anything. At the end of each index of a whole reader over HTTP, the worker now writes the blocks that reader's small reads went through into the package's cache, with the validator and size they were read under, and openReader puts them back before zip.js opens the archive. Only with a validator; a copy that does not match or does not read back whole is read around. On the demo's quiz, from a host paced to 1 MB/s with 100 ms on every request, a reload after the worker stopped is the probe alone, ready at 0.21 s, where it took four requests and 0.64 s. Closes #136.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #136.
The blocks an archive's index was read from lived only in the Service Worker's memory. Chromium stops an idle worker after about thirty seconds, so the usual revisit found that cache empty. Before the worker could answer anything, it read the archive's tail and head again, one request after the other.
What changes
indexfor a whole reader over HTTP, the worker writes the blocks that reader's small reads went through into the package's cache. That covers the index,content.json, and whatever the plan and the check read; the player names no file. The blocks are stored with the validator and size they were read under (keepIndexBlocks,ChunkStore.setIndexBlocks,blocksReadBy).openReaderputs the blocks back into the block cache before zip.js opens the archive, when the validator and size still match (seedIndexBlocks,seedBlocks,BlockCache.seed). zip.js then reads the index from memory, as a reader rebuilt afterattach-librariesalready does.ETagorLast-Modifiedthe page can read. Without one, an archive republished at the same URL keeps its package id, and old blocks would send zip.js to the old offsets. Such a host reads the index again, as now.<package>/index-blocks, beside the entries, not among their chunks./counted/test host gives anETagwhen a test asks with&etag=1.design/serving.md(Small reads over HTTP go through a block cache…) and its line inAGENTS.md.docs/setup.mdnow asks a host on another origin to exposeETag(orLast-Modified).Checked
Timings on the demo's quiz, from a host paced to 1 MB/s with 100 ms added to every request, with the worker stopped through CDP between two loads:
mainETagFirst loads are unchanged: five requests, ready in 2.3 to 2.6 s.
tests/browser-emulated/worker-stopped.test.tsstops the worker through CDP and counts the reload's requests at/counted/. With anETag, the probe is the only request; without the change,bytes=0-3378follows it, and the test fails. Without a validator, the index is read again.Unit tests:
BlockCachehands over a key's blocks and puts them back, and leaves out a block of the wrong length or one it already holds.range-http-handle: a worker started again costs nothing with the blocks put back, and the tail and the head without them.Suites: the player's suite passes, 604 tests across the unit, browser and emulated projects.
pnpm testpasses across the workspace (embed 81, skills 73, verify 27, demo 21, and the rest).Not done, as the issue says: the warm's whole entries already have this gap for an archive republished without a validator, and nothing clears a package's cache when its archive changes.
Release: in the player's next minor.