Skip to content

sqlite3-wasm: update SQLite to 3.54.1 - #328

Open
danleh wants to merge 2 commits into
WebKit:mainfrom
danleh:wasm-sqlite-3.54
Open

danleh wants to merge 2 commits into
WebKit:mainfrom
danleh:wasm-sqlite-3.54

Conversation

@danleh

@danleh danleh commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of #277. Stacked on #327 so the SQLite library update can be reviewed separately from the Emscripten 6.0.13 compiler rebuild; only the second commit is new.

Update SQLite from 3.48.0 to 3.54.1, built with Emscripten 6.0.13. SQLite 3.49.0 and later work with Emscripten 4 and newer (Module.runSQLite3PostLoadInit), so the backport patch from #327 goes away.

To review (3 files, +20/−46):

  • benchmark.js passes --testset main. Since SQLite 3.50, speedtest1's default testset is the "mix1" list, kept in a static buffer that speedtest1 tokenizes in place. JetStream calls main() repeatedly in one instance, so only the first iteration would run all 8 testsets of mix1, and every later one only "main". With the flag, every iteration runs "main", as with 3.48.
  • build.sh: make dist no longer builds speedtest1, so build.sh builds that target. It runs make sqlite3.c first, passes CC="cc -DSQLITE_DISABLE_INTRINSIC" (so the host c-pp preprocessor links on Linux without -lm), and sets WASM_CUSTOM_INSTANTIATE=0 (Emscripten's loader instead of SQLite's fetch()-based one), emcc_opt=-Oz (the level make dist used) and bin.wasm-opt= (skips SQLite's extra wasm-opt --all-features pass, after which Binaryen v133 emits compact imports that engines reject).

Binaries: speedtest1.wasm grows from 862,092 to 960,233 bytes: 3.54.1 exports 71 more C functions, and speedtest1.c has new testsets (json, star) that "main" does not run.

Scores (each test alone in a fresh shell; 10 rounds against #327, 6 rounds against main):

Comparison d8 jsc SpiderMonkey
Against main (3.48.0 + emcc 3.1.73) +14.7% +18.8% +6.7%
Against #327 (3.48.0 + emcc 6.0.13, 10 rounds) +1.8% +1.1% −2.5%
Comparison d8 First / Average jsc First / Average SpiderMonkey First / Average
Against #327 (3.48.0 + emcc 6.0.13) −3.6% / +7.5% −5.8% / +6.4% −6.9% / −0.9%

Against #327, the first iteration (which compiles and instantiates the 11.4% larger module inside runIteration) is slower on all three shells, while later iterations are faster on d8 (+7.5%) and jsc (+6.4%) and flat on SpiderMonkey (−0.9%).

Rebuild with Emscripten 6.0.13 (was 3.1.73). SQLite stays at 3.48.0 and
benchmark.js is unchanged, so the benchmark runs the same SQL as before.

- Emscripten 4.0 made the MODULARIZE factory async, which runs SQLite
  3.48's --post-js init too late: EmscriptenModule.sqlite3 stays
  undefined, and the shells fail with "Cannot set properties of
  undefined (setting 'scriptInfo')". emscripten-4-post-load-init.patch
  backports Module.runSQLite3PostLoadInit from SQLite 3.49.0. It changes
  only the JS glue. Drop it when updating to SQLite 3.49.0 or later.
- Pass INCOMING_MODULE_JS_API through EMCC_CFLAGS, since Emscripten 6.0.2
  removed wasmBinary from the default list.

speedtest1.wasm now uses bulk memory (271 memory.copy, 217 memory.fill).

Score change, d8 (15.9.60) / jsc (325217) / SpiderMonkey (160.0b3) (each
test alone in a fresh shell, 6 rounds): +15.2% / -0.2% / +11.7%.

Part of WebKit#277.
@danleh
danleh requested review from eqrion and kmiller68 November 3, 2026 17:32
@netlify

netlify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for webkit-jetstream-preview ready!

Name Link
🔨 Latest commit 8c7e756
🔍 Latest deploy log https://app.netlify.com/projects/webkit-jetstream-preview/deploys/6aea5beb9d1e2f6bfe3c1ea6
😎 Deploy Preview https://deploy-preview-328--webkit-jetstream-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Update SQLite from 3.48.0 to 3.54.1, still built with emcc 6.0.13.
SQLite 3.49.0 and later work with Emscripten 4 and newer, so the
backport patch is gone.

benchmark.js now passes "--testset main". Since SQLite 3.50, the default
testset is the "mix1" list, kept in a static buffer that speedtest1
tokenizes in place. JetStream calls main() repeatedly in one instance,
so only the first iteration would run all 8 testsets of mix1, and every
later iteration would run only "main". With the flag, every iteration
runs the "main" testset, as with 3.48.

`make dist` no longer builds speedtest1, so build.sh builds that target:
- Run `make sqlite3.c` first. ext/wasm/GNUmakefile stops if sqlite3.h is
  out of date.
- Pass `CC="cc -DSQLITE_DISABLE_INTRINSIC"` so the host c-pp preprocessor
  links on Linux without `-lm` (speedtest1.wasm is built by emcc, not CC).
- WASM_CUSTOM_INSTANTIATE=0 uses Emscripten's loader instead of SQLite's
  fetch()-based one, which JS shells lack.
- emcc_opt=-Oz is the level `make dist` used. Without it, speedtest1
  builds at -O0.
- bin.wasm-opt= skips SQLite's extra `wasm-opt --all-features` pass,
  which makes Binaryen v133 emit compact imports that engines reject.

speedtest1.wasm grows from 862,092 to 960,233 bytes: 3.54.1 exports 71
more C functions, and speedtest1.c has new testsets (json, star) that
"main" does not run.

Score change against the 3.48.0 build, d8 / jsc / SpiderMonkey (each
test alone in a fresh shell, 10 rounds): +1.8% / +1.1% / -2.5%. The
first iteration is slower on all three (-3.6% / -5.8% / -6.9%); the
average iteration is faster on d8 and jsc (+7.5% / +6.4%) and level on
SpiderMonkey (-0.9%).

Part of WebKit#277.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant