Repository navigation
perf(onlion): stop paying for SQLite in requests that never touch it - #137
Merged
Merged
Conversation
Measured before this change: twelve sequential /health calls on the live endpoint took 3.6-6.5 s each. Every one of them is a cold start - this platform starts a fresh isolate per request - and every one paid for SQLite it does not use: - /health called sqliteReady() before answering, purely to report a version string; - the EdgeOne build inlined the wasm as base64 and built the WebAssembly.Module **at module scope**, so the decode and the compile happened before any handler ran (the plugin's comment claimed lazy; the emitted code was eager). Now: - the build emits a factory (`compiledWasm()`) that decodes and compiles on first use; worker.mjs accepts either that factory or workerd's precompiled module, so the wrangler path is unchanged; - /health no longer loads SQLite, and says so instead of reporting a version it did not load; - the always-on request line carries `sqlite_loaded`, so "the deferred load works" is a measurement rather than a claim - false means the request finished without decoding or compiling wasm at all. 37 PASS locally, including `sqlite_loaded: false` on metadata routes.
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.
Doc owner:
docs/decisions/implemented/2026-10-30-defer-wasm-load.{md,zh-CN.md,terms.yaml}(added in this PR).Measured baseline on live: twelve sequential
/healthcalls at 3.6-6.5 s each — every one a cold start (fresh isolate per request), every one paying for SQLite it does not use:/healthcalledsqliteReady()just to report a version string;new WebAssembly.Module(...)at module scope, so decode + compile happened before the handler ran (the plugin comment said "lazily"; the emitted code was eager).Now: a
compiledWasm()factory compiles on first use;/healthnever loads SQLite; the request line reportssqlite_loadedso the claim is falsifiable.Not verified
Not deployed; the 3.6-6.5 s figure is the before-state, and the after-state is unmeasured until this ships. The wrangler/Miniflare path (workerd precompiled module) is covered by the existing suite but not re-measured for speed.