Skip to content

Commit 8c7e756

Browse files
committed
sqlite3-wasm: update SQLite to 3.54.1
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 #277.
1 parent f8e1f5a commit 8c7e756

6 files changed

Lines changed: 7282 additions & 3408 deletions

File tree

‎workloads/sqlite3-wasm/benchmark.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class Benchmark {
6969
"--nomemstat",
7070
"--big-transactions" /*important for tests 410 and 510!*/,
7171
"--size", "2", // To speedup, default is 100 (and takes about 4s).
72+
// Since SQLite 3.50, the default testset is the "mix1" list, which
73+
// speedtest1 splits in place in a static buffer. Calling main() again in
74+
// the same instance then runs only "main", so only the first iteration
75+
// would run the other testsets. Run just "main" in every iteration.
76+
"--testset", "main",
7277
"--vfs", vfs, // See VFS comment above.
7378
];
7479

‎workloads/sqlite3-wasm/build.log‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Built on 2026-10-28T21:51:11Z
1+
Built on 2026-10-28T22:49:56Z
22

33
Toolchain versions
44
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 6.0.13 (e13ee988ce3d87a738dd8f3661d02223308c412a)
55
wasm-strip 1.0.36
66

7-
Getting sources from https://sqlite.org/2025/sqlite-src-3480000.zip
7+
Getting sources from https://sqlite.org/2026/sqlite-src-3540100.zip
88

99
Building...
1010
Copying files from sqlite-src-*/ext/wasm/ into build/

‎workloads/sqlite3-wasm/build.sh‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ emcc --version | head -n1 | tee -a "$BUILD_LOG"
1616
echo -e "wasm-strip $(wasm-strip --version)\n" | tee -a "$BUILD_LOG"
1717

1818
# Check https://sqlite.org/download.html and update the source link, if needed.
19-
SQLITE_SRC_URL="https://sqlite.org/2025/sqlite-src-3480000.zip"
19+
SQLITE_SRC_URL="https://sqlite.org/2026/sqlite-src-3540100.zip"
2020
echo -e "Getting sources from $SQLITE_SRC_URL\n" | tee -a "$BUILD_LOG"
2121
SQLITE_SRC_FILE="$(basename $SQLITE_SRC_URL)"
2222
curl -o "$SQLITE_SRC_FILE" $SQLITE_SRC_URL
@@ -25,15 +25,25 @@ unzip "$SQLITE_SRC_FILE"
2525
# Paths and information in make output could be sensitive, so don't save in log.
2626
echo "Building..." | tee -a "$BUILD_LOG"
2727
pushd sqlite-src-*/
28-
# SQLite 3.48.0's JS glue predates Emscripten 4.0's async MODULARIZE factory,
29-
# see the patch description. Drop the patch when updating to SQLite >= 3.49.0.
30-
patch -p1 -i ../emscripten-4-post-load-init.patch
3128
./configure
29+
# ext/wasm/GNUmakefile expects the amalgamation to exist already.
30+
make sqlite3.c
3231
cd ext/wasm
3332
# Emscripten 6.0.2 removed `wasmBinary` from the default INCOMING_MODULE_JS_API
3433
# list, and setting the list replaces the default, so name every Module property
3534
# that benchmark.js and the speedtest1 glue code pass in.
36-
EMCC_CFLAGS="-sINCOMING_MODULE_JS_API=wasmBinary,print,printErr,preRun,postRun,noInitialRun" make dist
35+
# `make dist` no longer builds speedtest1, so build that target directly:
36+
# - CC="cc -DSQLITE_DISABLE_INTRINSIC" builds the host c-pp preprocessor
37+
# without GCC's __builtin_ceil/__builtin_floor, which at -O0 emit calls to
38+
# libm's ceil()/floor() whereas GNUmakefile links c-pp without -lm.
39+
# (speedtest1.wasm itself is compiled by emcc, not $(CC).)
40+
# - WASM_CUSTOM_INSTANTIATE=0 uses Emscripten's loader instead of SQLite's
41+
# fetch()-based one, which JS shells don't have.
42+
# - emcc_opt=-Oz matches the optimization level that `make dist` used.
43+
# - bin.wasm-opt= skips SQLite's extra `wasm-opt --all-features` pass, which
44+
# makes current Binaryen emit compact imports (0x7f) that engines reject.
45+
EMCC_CFLAGS="-sINCOMING_MODULE_JS_API=wasmBinary,print,printErr,preRun,postRun,noInitialRun" \
46+
make speedtest1 CC="cc -DSQLITE_DISABLE_INTRINSIC" WASM_CUSTOM_INSTANTIATE=0 emcc_opt=-Oz bin.wasm-opt=
3747
popd
3848

3949
echo "Copying files from sqlite-src-*/ext/wasm/ into build/" | tee -a "$BUILD_LOG"

0 commit comments

Comments
 (0)