1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

Add support for (make base64.wasm=1), which embeds sqlite3.wasm into its corresponding JS file as base64. A very expensive calculator which was fed the resulting file sizes assures me that the two-file approach is, in the aggregate, more efficient both in terms of overall network bandwidth (+~20% bigger for base64) and client-side memory usage (streaming vs non-streaming wasm compilation), so we'll shelve this as an interesting experiment or maybe for use by custom builds.

FossilOrigin-Name: a167aee75198ff08b20b448fecd3267ed4a70af2472c02605318a5613f446fc6
This commit is contained in:
stephan
2026-07-21 16:04:10 +00:00
parent bee0db8c60
commit 1f2bc0ea64
6 changed files with 35 additions and 36 deletions

View File

@@ -217,9 +217,6 @@ b.cp = $(call b.mkdir@); \
# error before we get to handle that filename juggling. Most JS files
# defensively set a file-local @policy.
D.common =
ifeq (1,$(base64.wasm))
D.common += -Dbase64.wasm
endif
#
# $(call b.c-pp.shcmd,LOGTAG,src,dest,-Dx=y...)

View File

@@ -105,7 +105,7 @@
//#/if target:es6-module
}.bind(sIMS);
//#if Module.instantiateWasm and not wasmfs and not target:node
//#if Module.instantiateWasm and not wasmfs
/**
Override Module.instantiateWasm().
@@ -128,8 +128,9 @@
{/*
The following block uses //% as a directive delimiter and is
replaced in a second pass after compilation of sqlite3.js.
*/}
//%if defined sqlite3.wasm.base64
*/}
//%define ? base64.wasm 0
//%if base64.wasm and defined sqlite3.wasm.base64
let b64Wasm = `
//%base64
//%include -raw [arg sqlite3.wasm.base64]

View File

@@ -15,13 +15,13 @@
./c-pp -I. -I./src -Dsrcdir=./src -Dsed=/usr/bin/sed -o libcmpp.h ./tool/libcmpp.c-pp.h -o libcmpp.c ./tool/libcmpp.c-pp.c
with libcmpp 2.0.x a53a63923506aba565e91571c0f6bdb678e7dcc05dc9f7e281a17e68bf95aa46 @ 2026-07-21 10:38:56.344 UTC
with libcmpp 2.0.x ed6b3b14709bba639fa506517cfe9f7415d4a807912cb28df06cfcf19a526176 @ 2026-07-21 11:54:45.237 UTC
*/
#define CMPP_PACKAGE_NAME "libcmpp"
#define CMPP_LIB_VERSION "2.0.x"
#define CMPP_LIB_VERSION_HASH "a53a63923506aba565e91571c0f6bdb678e7dcc05dc9f7e281a17e68bf95aa46"
#define CMPP_LIB_VERSION_TIMESTAMP "2026-07-21 10:38:56.344 UTC"
#define CMPP_LIB_CONFIG_TIMESTAMP "2026-07-21 11:23 GMT"
#define CMPP_LIB_VERSION_HASH "ed6b3b14709bba639fa506517cfe9f7415d4a807912cb28df06cfcf19a526176"
#define CMPP_LIB_VERSION_TIMESTAMP "2026-07-21 11:54:45.237 UTC"
#define CMPP_LIB_CONFIG_TIMESTAMP "2026-07-21 14:56 GMT"
#define CMPP_VERSION CMPP_LIB_VERSION " " CMPP_LIB_VERSION_HASH " @ " CMPP_LIB_VERSION_TIMESTAMP
#define CMPP_PLATFORM_EXT_DLL ".so"
#define CMPP_MODULE_PATH ".:/usr/local/lib/cmpp"
@@ -14513,15 +14513,13 @@ int cmpp_args_parse(cmpp_dx * const dx,
if( 0==dxppCode ){
pArgs->argc = pArgs->pimpl->argli.n;
assert( !pArgs->arg0 );
for( unsigned int i = 0; i < pArgs->argc; ++i ){
for( unsigned int i = 1; i < pArgs->argc; ++i ){
/* We have to link arg->next after the loop because
CmppArgList_append() can realloc, invalidating
the links. */
if( i ){
cmpp_arg * const a = &pArgs->pimpl->argli.list[i];
assert( ! a->next );
pArgs->pimpl->argli.list[i-1].next = a;
}
cmpp_arg * const a = &pArgs->pimpl->argli.list[i];
assert( ! a->next );
pArgs->pimpl->argli.list[i-1].next = a;
}
if( pArgs->argc ) pArgs->arg0 = pArgs->pimpl->argli.list;
if( zOut<zInEnd ) *zOut = 0;

View File

@@ -883,16 +883,19 @@ static void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
pf("\t@$(call b.do.wasm-opt,%s)\n", zBuildName);
pf("\t@$(call b.strip-js-emcc-bindings,$(logtag.%s))\n", zBuildName);
if( 1 ){
pf("\techo 'Embedding $(out.%s.wasm) into $@ ...'\n"
"\t@mv $@ $@.in\n"
"\t$(call b.c-pp.shcmd,%s,$@.in,$@,"
"\"--delimiter=//%%\" "
"\"-Dsqlite3.wasm.base64=$(out.%s.wasm)\""
")\n",
zBuildName, zBuildName, zBuildName);
pf("\t@rm -f $@.in\n");
}
pf("\t@if [ x1 = 'x$(base64.wasm)' ]; then \\\n"
"\techo '[$(emo.magic) Embedding $(out.%s.wasm) into $@ ...]'; \\\n"
"\telse \\\n"
"\techo '[$(emo.megaphone) Not embedding WASM in JS. Pass base64.wasm=1 to do that.]'; \\\n"
"\tfi\n",
zBuildName);
pf("\t@mv $@ $@.in; \\\n"
"\t$(call b.c-pp.shcmd,%s,$@.in,$@,"
" \"--delimiter=//%%\" -Dbase64.wasm=$(base64.wasm)"
" \"-Dsqlite3.wasm.base64=$(out.%s.wasm)\""
"); \\\n"
"\trm -f $@.in\n",
zBuildName, zBuildName);
if( CP_JS & pB->flags ){
/*

View File

@@ -1,5 +1,5 @@
C This\sembeds\ssqlite3.wasm\sinto\ssqlite3.js/mjs\sas\sbase64\sbut\sis\sapplied\sglobally\s-\sit\sstill\sneeds\sto\sbe\smade\sconfigurable.
D 2026-07-21T13:28:52.549
C Add\ssupport\sfor\s(make\sbase64.wasm=1),\swhich\sembeds\ssqlite3.wasm\sinto\sits\scorresponding\sJS\sfile\sas\sbase64.\sA\svery\sexpensive\scalculator\swhich\swas\sfed\sthe\sresulting\sfile\ssizes\sassures\sme\sthat\sthe\stwo-file\sapproach\sis,\sin\sthe\saggregate,\smore\sefficient\sboth\sin\sterms\sof\soverall\snetwork\sbandwidth\s(+~20%\sbigger\sfor\sbase64)\sand\sclient-side\smemory\susage\s(streaming\svs\snon-streaming\swasm\scompilation),\sso\swe'll\sshelve\sthis\sas\san\sinteresting\sexperiment\sor\smaybe\sfor\suse\sby\scustom\sbuilds.
D 2026-07-21T16:04:10.298
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -582,7 +582,7 @@ F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009e
F ext/session/sqlite3session.c 673a2c71a3e1fc909301ed15daa30485d774419d015eb7688c79396e6cba6378
F ext/session/sqlite3session.h ca7c4422c1514a95056cc8d333217df6b1829d39058126b1de85d10cd62d7a9c
F ext/session/test_session.c f465f13c661919f8ba4485a9d0690c4df5bff1cc79e962cfdafa9ff376d5119f
F ext/wasm/GNUmakefile 6c8c97611d44410eefd8a2c7e578c9ac13ad2b230e88ba3039fe9cdd464bc411
F ext/wasm/GNUmakefile 92936a75dc15057dae3a87d96fe8282b22e663edb139852551da9179b437f1b3
F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
F ext/wasm/README.md 2e87804e12c98f1d194b7a06162a88441d33bb443efcfe00dc6565a780d2f259
F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -598,7 +598,7 @@ F ext/wasm/api/opfs-common-inline.c-pp.js 496ca858af09b7fef2efaece467960611d35f5
F ext/wasm/api/opfs-common-shared.c-pp.js 9a9019bcc070d7c90829af5f5eb81d25135bf9543944a691631c0184f0c62416
F ext/wasm/api/post-js-footer.js a50c1a2c4d008aede7b2aa1f18891a7ee71437c2f415b8aeb3db237ddce2935b
F ext/wasm/api/post-js-header.js f35d2dcf1ab7f22a93d565f8e0b622a2934fc4e743edf3b708e4dd8140eeff55
F ext/wasm/api/pre-js.c-pp.js 35b2ae330c8098f585fe2bf2bb3404cfa0b12ff46671d825687b1c79c1ec4ac4
F ext/wasm/api/pre-js.c-pp.js e7b41b3f1dd40da5476cc2beec9008af3843732541e9ce554536cb66b9a544ae
F ext/wasm/api/sqlite3-api-glue.c-pp.js 31a721ada7225838a61310a9f3f797fa5275353f8e9b0ae769d85b437be061f5
F ext/wasm/api/sqlite3-api-oo1.c-pp.js 35e4727010f15fd72ead0dd1eb4e3c2c9bb1cc60e51544cbdff1f7c14f209de2
F ext/wasm/api/sqlite3-api-prologue.js 0084e15d66fbcd75cacbaa58e3b473d5e57082c30f3122be7fdadff5589cf6b6
@@ -636,9 +636,9 @@ F ext/wasm/index-dist.html db23748044e286773f2768eec287669501703b5d5f72755e8db73
F ext/wasm/index.html 5bf6cf1b0a3c8b9f5f54d77f2219d7ae87a15162055ce308109c49b1dcab4239
F ext/wasm/jaccwabyt/jaccwabyt.js 4e2b797dc170851c9c530c3567679f4aa509eec0fab73b466d945b00b356574b
F ext/wasm/jaccwabyt/jaccwabyt.md 6aa90fa1a973d0ad10d077088bea163b241d8470c75eafdef87620a1de1dea41
F ext/wasm/libcmpp.c 5296a720aa95795617335fa0b3b4da5ea48150132251b85ca131bc6f2a21b066
F ext/wasm/libcmpp.c 456b5c39eb9a65a0835c3a9b16f85d9c53330a31c810d7e6c15e5893488f9287
F ext/wasm/mkdist.sh f8883b077a2ca47cf92e6f0ce305fbf72ca648c3501810125056c4b09c2d5554 x
F ext/wasm/mkwasmbuilds.c 412296dad75252cfd3f4c71288aa4947ec2da93287b336bdc0cec958f784b11f
F ext/wasm/mkwasmbuilds.c e689304a63bcb6d09ec4046c706e92ce32cb97896248bb34be2f2f988fb41c03
F ext/wasm/module-symbols.html e54f42112e0aac2a31f850ab33e7f2630a2ea4f63496f484a12469a2501e07e2
F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96
F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63
@@ -2217,8 +2217,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
P 538199cf62f07a2fe7ee5775c9f01aff1644d638bc0916cf631d61376462b5cb
R cfcfa8bc897c97c9b5ebf70867bb8fcf
P 0467a0f826b5b7bb65d9c74df80c7443f01824c1cc8184417849a74791f491b7
R a2f656d7d331f000ff17a5ffcbf6eb95
U stephan
Z 45cbe61cb9c192f82469f625e6cedbe8
Z 4ead1d14385d2197e032e9be0a72938f
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
0467a0f826b5b7bb65d9c74df80c7443f01824c1cc8184417849a74791f491b7
a167aee75198ff08b20b448fecd3267ed4a70af2472c02605318a5613f446fc6