Repository navigation
perf(host-cloudflare): cheaper new isolates: one-read D1 open and lazy QuickJS - #29
Merged
Merged
Conversation
Fold the compatibility version and the ordered data-migration ids into the schema fingerprint and skip the compatibility check and migration ledger read when the stored fingerprint matches. The marker is still written only after DDL, compatibility and data migrations succeed. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
…f every app build The QuickJS executor now loads the Workers WASM-inlined variant right before its first execute, so building the app, the cron reconcile and MCP sessions that never run code skip the load. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
…t loader Hosts that cannot fetch the default WASM register a loader that runs on the first resolve and is memoized, with a rejected load retried. The Cloudflare worker registers its WASM-inlined variant once at module scope, so the artifact smoke render in the MCP session Durable Object works again without instantiating QuickJS at startup. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
…d simplify tests The fingerprint now hashes the compatibility repair source instead of a hand-bumped version, is computed once per isolate, and is read in parallel with the stored marker. The D1 tests assert through the marker row and recorded statements instead of a module mock. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
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.
Why
A request that lands on a new isolate took about 1.5 to 1.9 s, against 0.1 to 0.3 s on a warm isolate. Two parts of the app build ran on every new isolate even when the request needed neither:
What changes
runtime-quickjsgainssetQuickJSModuleLoader.resolveQuickJSuses the preloaded module first, then the registered loader (awaited once, memoized, reset on rejection so a transient failure retries), thengetQuickJS().makeQuickJsExecutorandexecuteSealedBundleresolve through it.worker.ts, so the fetch handlers and the MCP Durable Objects are all covered, and drops every per-buildpreloadQuickJscall.executeSealedBundlein the MCP session DO) loads QuickJS the same way. The first version of this PR missed that path.ensureCloudflareD1SchemaCompatibilityand the ordered data-migration ids.prepareCloudflareD1Data.Tests
module-loader.test.ts: the loader runs only on the first resolve, and once across many resolves; a preloaded module wins; a rejected load retries; the sealed-bundle and executor paths share one load.cloudflare/artifact-smoke-render.test.ts:create-artifactover MCP with a component that throws on first render is refused with the thrown message, which proves QuickJS ran in workerd. It fails when the loader registration is removed.https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S