mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Set default page cache size to 16mb in wasm builds. Fix an off-by-one counter in sqlite3_wasm_enum_json(). Minor coding style conformance tweaks.
FossilOrigin-Name: 72a9e589cc318ec50941739e2edf2c0636284b316c3bf87b71fd363b37619da3
This commit is contained in:
@ -58,6 +58,26 @@
|
|||||||
#ifndef SQLITE_OMIT_WAL
|
#ifndef SQLITE_OMIT_WAL
|
||||||
# define SQLITE_OMIT_WAL
|
# define SQLITE_OMIT_WAL
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef SQLITE_DEFAULT_CACHE_SIZE
|
||||||
|
/*
|
||||||
|
** The OPFS impls benefit tremendously from an increased cache size
|
||||||
|
** when working on large workloads, e.g. speedtest1 --size 50 or
|
||||||
|
** higher. On smaller workloads, e.g. speedtest1 --size 25, they
|
||||||
|
** clearly benefit from having 4mb of cache, but not as much as a
|
||||||
|
** larger cache benefits the larger workloads. Speed differences
|
||||||
|
** between 2x and nearly 3x have been measured with ample page cache.
|
||||||
|
*/
|
||||||
|
# define SQLITE_DEFAULT_CACHE_SIZE -16777216
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
** TODO: experiment with this when back on the opfs-capable machine.
|
||||||
|
*/
|
||||||
|
#ifndef SQLITE_DEFAULT_PAGE_SIZE
|
||||||
|
# define SQLITE_DEFAULT_PAGE_SIZE 8192 /*4096*/
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "sqlite3.c" /* yes, .c instead of .h. */
|
#include "sqlite3.c" /* yes, .c instead of .h. */
|
||||||
@ -140,6 +160,11 @@ WASM_KEEP void * sqlite3_wasm_stack_alloc(int n){
|
|||||||
** memory to use for that purpose. This memory ends up in the
|
** memory to use for that purpose. This memory ends up in the
|
||||||
** WASM-managed memory, such that routines which manipulate the wasm
|
** WASM-managed memory, such that routines which manipulate the wasm
|
||||||
** heap can also be used to manipulate this memory.
|
** heap can also be used to manipulate this memory.
|
||||||
|
**
|
||||||
|
** This particular allocator is intended for small allocations such as
|
||||||
|
** storage for output pointers. We cannot reasonably size it large
|
||||||
|
** enough for general-purpose string conversions because some of our
|
||||||
|
** tests use input files (strings) of 16MB+.
|
||||||
*/
|
*/
|
||||||
static unsigned char PStack_mem[512 * 8] = {0};
|
static unsigned char PStack_mem[512 * 8] = {0};
|
||||||
static struct {
|
static struct {
|
||||||
@ -239,35 +264,35 @@ int sqlite3_wasm_db_error(sqlite3*db, int err_code, const char *zMsg){
|
|||||||
*/
|
*/
|
||||||
WASM_KEEP
|
WASM_KEEP
|
||||||
const char * sqlite3_wasm_enum_json(void){
|
const char * sqlite3_wasm_enum_json(void){
|
||||||
static char strBuf[1024 * 12] = {0} /* where the JSON goes */;
|
static char azBuffer[1024 * 12] = {0} /* where the JSON goes */;
|
||||||
int n = 0, childCount = 0, structCount = 0
|
int n = 0, nChildren = 0, nStruct = 0
|
||||||
/* output counters for figuring out where commas go */;
|
/* output counters for figuring out where commas go */;
|
||||||
char * pos = &strBuf[1] /* skip first byte for now to help protect
|
char * zPos = &azBuffer[1] /* skip first byte for now to help protect
|
||||||
** against a small race condition */;
|
** against a small race condition */;
|
||||||
char const * const zEnd = pos + sizeof(strBuf) /* one-past-the-end */;
|
char const * const zEnd = &azBuffer[0] + sizeof(azBuffer) /* one-past-the-end */;
|
||||||
if(strBuf[0]) return strBuf;
|
if(azBuffer[0]) return azBuffer;
|
||||||
/* Leave strBuf[0] at 0 until the end to help guard against a tiny
|
/* Leave azBuffer[0] at 0 until the end to help guard against a tiny
|
||||||
** race condition. If this is called twice concurrently, they might
|
** race condition. If this is called twice concurrently, they might
|
||||||
** end up both writing to strBuf, but they'll both write the same
|
** end up both writing to azBuffer, but they'll both write the same
|
||||||
** thing, so that's okay. If we set byte 0 up front then the 2nd
|
** thing, so that's okay. If we set byte 0 up front then the 2nd
|
||||||
** instance might return and use the string before the 1st instance
|
** instance might return and use the string before the 1st instance
|
||||||
** is done filling it. */
|
** is done filling it. */
|
||||||
|
|
||||||
/* Core output macros... */
|
/* Core output macros... */
|
||||||
#define lenCheck assert(pos < zEnd - 128 \
|
#define lenCheck assert(zPos < zEnd - 128 \
|
||||||
&& "sqlite3_wasm_enum_json() buffer is too small."); \
|
&& "sqlite3_wasm_enum_json() buffer is too small."); \
|
||||||
if(pos >= zEnd - 128) return 0
|
if( zPos >= zEnd - 128 ) return 0
|
||||||
#define outf(format,...) \
|
#define outf(format,...) \
|
||||||
pos += snprintf(pos, ((size_t)(zEnd - pos)), format, __VA_ARGS__); \
|
zPos += snprintf(zPos, ((size_t)(zEnd - zPos)), format, __VA_ARGS__); \
|
||||||
lenCheck
|
lenCheck
|
||||||
#define out(TXT) outf("%s",TXT)
|
#define out(TXT) outf("%s",TXT)
|
||||||
#define CloseBrace(LEVEL) \
|
#define CloseBrace(LEVEL) \
|
||||||
assert(LEVEL<5); memset(pos, '}', LEVEL); pos+=LEVEL; lenCheck
|
assert(LEVEL<5); memset(zPos, '}', LEVEL); zPos+=LEVEL; lenCheck
|
||||||
|
|
||||||
/* Macros for emitting maps of integer- and string-type macros to
|
/* Macros for emitting maps of integer- and string-type macros to
|
||||||
** their values. */
|
** their values. */
|
||||||
#define DefGroup(KEY) n = 0; \
|
#define DefGroup(KEY) n = 0; \
|
||||||
outf("%s\"" #KEY "\": {",(childCount++ ? "," : ""));
|
outf("%s\"" #KEY "\": {",(nChildren++ ? "," : ""));
|
||||||
#define DefInt(KEY) \
|
#define DefInt(KEY) \
|
||||||
outf("%s\"%s\": %d", (n++ ? ", " : ""), #KEY, (int)KEY)
|
outf("%s\"%s\": %d", (n++ ? ", " : ""), #KEY, (int)KEY)
|
||||||
#define DefStr(KEY) \
|
#define DefStr(KEY) \
|
||||||
@ -575,7 +600,7 @@ const char * sqlite3_wasm_enum_json(void){
|
|||||||
/** Macros for emitting StructBinder description. */
|
/** Macros for emitting StructBinder description. */
|
||||||
#define StructBinder__(TYPE) \
|
#define StructBinder__(TYPE) \
|
||||||
n = 0; \
|
n = 0; \
|
||||||
outf("%s{", (structCount++ ? ", " : "")); \
|
outf("%s{", (nStruct++ ? ", " : "")); \
|
||||||
out("\"name\": \"" # TYPE "\","); \
|
out("\"name\": \"" # TYPE "\","); \
|
||||||
outf("\"sizeof\": %d", (int)sizeof(TYPE)); \
|
outf("\"sizeof\": %d", (int)sizeof(TYPE)); \
|
||||||
out(",\"members\": {");
|
out(",\"members\": {");
|
||||||
@ -591,7 +616,7 @@ const char * sqlite3_wasm_enum_json(void){
|
|||||||
(int)sizeof(((CurrentStruct*)0)->MEMBER), \
|
(int)sizeof(((CurrentStruct*)0)->MEMBER), \
|
||||||
SIG)
|
SIG)
|
||||||
|
|
||||||
structCount = 0;
|
nStruct = 0;
|
||||||
out(", \"structs\": ["); {
|
out(", \"structs\": ["); {
|
||||||
|
|
||||||
#define CurrentStruct sqlite3_vfs
|
#define CurrentStruct sqlite3_vfs
|
||||||
@ -654,9 +679,9 @@ const char * sqlite3_wasm_enum_json(void){
|
|||||||
} out( "]"/*structs*/);
|
} out( "]"/*structs*/);
|
||||||
|
|
||||||
out("}"/*top-level object*/);
|
out("}"/*top-level object*/);
|
||||||
*pos = 0;
|
*zPos = 0;
|
||||||
strBuf[0] = '{'/*end of the race-condition workaround*/;
|
azBuffer[0] = '{'/*end of the race-condition workaround*/;
|
||||||
return strBuf;
|
return azBuffer;
|
||||||
#undef StructBinder
|
#undef StructBinder
|
||||||
#undef StructBinder_
|
#undef StructBinder_
|
||||||
#undef StructBinder__
|
#undef StructBinder__
|
||||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\sa\s--cachesize\sflag\sto\sthe\sspeedtest1-worker-opfs\slink\sin\sindex.html\sbecause\sopfs\sis\smuch\sfaster\swith\sthat.
|
C Set\sdefault\spage\scache\ssize\sto\s16mb\sin\swasm\sbuilds.\sFix\san\soff-by-one\scounter\sin\ssqlite3_wasm_enum_json().\sMinor\scoding\sstyle\sconformance\stweaks.
|
||||||
D 2022-10-03T22:51:24.381
|
D 2022-10-03T23:13:05.622
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -491,7 +491,7 @@ F ext/wasm/api/sqlite3-api-opfs.js 3d17da752181d67847bd2e3d1f4662df31c5023a1bed5
|
|||||||
F ext/wasm/api/sqlite3-api-prologue.js 61f28bf7a51479c7b401e2da636b2a0710de77d86f68961445d572a3761dd170
|
F ext/wasm/api/sqlite3-api-prologue.js 61f28bf7a51479c7b401e2da636b2a0710de77d86f68961445d572a3761dd170
|
||||||
F ext/wasm/api/sqlite3-api-worker1.js 7f4f46cb6b512a48572d7567233896e6a9c46570c44bdc3d13419730c7c221c8
|
F ext/wasm/api/sqlite3-api-worker1.js 7f4f46cb6b512a48572d7567233896e6a9c46570c44bdc3d13419730c7c221c8
|
||||||
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
|
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
|
||||||
F ext/wasm/api/sqlite3-wasm.c 3838ad650c9f92803e810f09a1253b25252a6533b09620b3450194d72084094f
|
F ext/wasm/api/sqlite3-wasm.c 1ed1356752c02a991b2d16c32e3e5c138a03526bb60182f2a751ec5372ecba12
|
||||||
F ext/wasm/batch-runner.html cf1a410c92bad50fcec2ddc71390b4e9df63a6ea1bef12a5163a66a0af4d78d9
|
F ext/wasm/batch-runner.html cf1a410c92bad50fcec2ddc71390b4e9df63a6ea1bef12a5163a66a0af4d78d9
|
||||||
F ext/wasm/batch-runner.js 5bae81684728b6be157d1f92b39824153f0fd019345b39f2ab8930f7ee2a57d8
|
F ext/wasm/batch-runner.js 5bae81684728b6be157d1f92b39824153f0fd019345b39f2ab8930f7ee2a57d8
|
||||||
F ext/wasm/common/SqliteTestUtil.js 647bf014bd30bdd870a7e9001e251d12fc1c9ec9ce176a1004b838a4b33c5c05
|
F ext/wasm/common/SqliteTestUtil.js 647bf014bd30bdd870a7e9001e251d12fc1c9ec9ce176a1004b838a4b33c5c05
|
||||||
@ -2029,8 +2029,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 3cfcc14dfd220536141aeffb902fdc8db1cea055b2a0609b88e092fc3df94688
|
P 5b8f8e33afc47c9f0c64dbe34643d7d1c37a0a82afb4656e714a86ef54a9ce6f
|
||||||
R c3ddc7f08af0e1dfea53de525fac120d
|
R 9e18661e1500a3e4cdfa05bc23635f3f
|
||||||
U stephan
|
U stephan
|
||||||
Z c791e943ea41f9bead968e082bef6c31
|
Z e3d9878d6daf198d0150d0ecad381b11
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
5b8f8e33afc47c9f0c64dbe34643d7d1c37a0a82afb4656e714a86ef54a9ce6f
|
72a9e589cc318ec50941739e2edf2c0636284b316c3bf87b71fd363b37619da3
|
Reference in New Issue
Block a user