Repository navigation
Encode hosted SQLite text directly into snapshot index replies - #2045
Merged
Merged
Conversation
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.
Refs #2017
The hosted snapshot builder reads each resource path twice and its Markdown body once. The SQLite adapter previously allocated a UTF-8 byte array for each of those text cells, then copied it into the binary reply. It now encodes into the reply buffer and allocates a temporary array only when a multibyte suffix needs more room. Request strings share a UTF-8 decoder across independent, synchronous decodes.
Local Durable Object SQLite benchmark
Each inventory reads resource paths, byte lengths and multilingual bodies in 256-row pages. The harness checks byte-for-byte equality of all baseline and candidate replies, warms each arm for four rounds, then collects 32 paired samples with alternating order. Times are milliseconds per complete inventory. CPU is Linux process time for workerd. Temporary arrays count calls to
TextEncoder.encodein a separate, untimed inventory.The 4,096-resource fixture used 21% less median workerd CPU. On one resource, CPU and median wall time fell, while wall p95 rose by 0.010 ms. These measurements cover the adapter on local workerd. Production snapshot latency and billing were outside the experiment.
Independent repeat on the rebased head
After local CI finished, the same harness on Linux x86-64 with Node 24.22.2 and workerd 1.20261014.1 returned the following per-inventory results. The baseline ran faster in this session as well. Comparing arms within each run, median CPU fell 18% in the repeat and 21% in the original large fixture. Both small controls improved on all timing metrics in the repeat.
Reproduction
Run from the PR checkout on Linux with Node 24. The baseline adapter below is byte-identical to the version used for the first measurement.
Verification
pnpm ci:localwith two Vitest workers and CI retry settings. An earlier run hit the 5 s shared-window UI test timeout. All 506 UI tests passed on the final run. The patch changes hosted-worker TypeScript, its test and benchmark, and a changelog fragment.