#ifndef SQLITE_OMIT_WAL
# define SQLITE_OMIT_WAL
#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 "sqlite3.c" /* yes, .c instead of .h. */
** memory to use for that purpose. This memory ends up in the
** WASM-managed memory, such that routines which manipulate the wasm
** 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 struct {
*/
WASM_KEEP
const char * sqlite3_wasm_enum_json(void){
- static char strBuf[1024 * 12] = {0} /* where the JSON goes */;
- int n = 0, childCount = 0, structCount = 0
+ static char azBuffer[1024 * 12] = {0} /* where the JSON goes */;
+ int n = 0, nChildren = 0, nStruct = 0
/* 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 */;
- char const * const zEnd = pos + sizeof(strBuf) /* one-past-the-end */;
- if(strBuf[0]) return strBuf;
- /* Leave strBuf[0] at 0 until the end to help guard against a tiny
+ char const * const zEnd = &azBuffer[0] + sizeof(azBuffer) /* one-past-the-end */;
+ if(azBuffer[0]) return azBuffer;
+ /* Leave azBuffer[0] at 0 until the end to help guard against a tiny
** 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
** instance might return and use the string before the 1st instance
** is done filling it. */
/* Core output macros... */
-#define lenCheck assert(pos < zEnd - 128 \
+#define lenCheck assert(zPos < zEnd - 128 \
&& "sqlite3_wasm_enum_json() buffer is too small."); \
- if(pos >= zEnd - 128) return 0
+ if( zPos >= zEnd - 128 ) return 0
#define outf(format,...) \
- pos += snprintf(pos, ((size_t)(zEnd - pos)), format, __VA_ARGS__); \
+ zPos += snprintf(zPos, ((size_t)(zEnd - zPos)), format, __VA_ARGS__); \
lenCheck
#define out(TXT) outf("%s",TXT)
#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
** their values. */
#define DefGroup(KEY) n = 0; \
- outf("%s\"" #KEY "\": {",(childCount++ ? "," : ""));
+ outf("%s\"" #KEY "\": {",(nChildren++ ? "," : ""));
#define DefInt(KEY) \
outf("%s\"%s\": %d", (n++ ? ", " : ""), #KEY, (int)KEY)
#define DefStr(KEY) \
/** Macros for emitting StructBinder description. */
#define StructBinder__(TYPE) \
n = 0; \
- outf("%s{", (structCount++ ? ", " : "")); \
+ outf("%s{", (nStruct++ ? ", " : "")); \
out("\"name\": \"" # TYPE "\","); \
outf("\"sizeof\": %d", (int)sizeof(TYPE)); \
out(",\"members\": {");
(int)sizeof(((CurrentStruct*)0)->MEMBER), \
SIG)
- structCount = 0;
+ nStruct = 0;
out(", \"structs\": ["); {
#define CurrentStruct sqlite3_vfs
} out( "]"/*structs*/);
out("}"/*top-level object*/);
- *pos = 0;
- strBuf[0] = '{'/*end of the race-condition workaround*/;
- return strBuf;
+ *zPos = 0;
+ azBuffer[0] = '{'/*end of the race-condition workaround*/;
+ return azBuffer;
#undef StructBinder
#undef StructBinder_
#undef StructBinder__
-C Add\sa\s--cachesize\sflag\sto\sthe\sspeedtest1-worker-opfs\slink\sin\sindex.html\sbecause\sopfs\sis\smuch\sfaster\swith\sthat.
-D 2022-10-03T22:51:24.381
+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-03T23:13:05.622
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/wasm/api/sqlite3-api-prologue.js 61f28bf7a51479c7b401e2da636b2a0710de77d86f68961445d572a3761dd170
F ext/wasm/api/sqlite3-api-worker1.js 7f4f46cb6b512a48572d7567233896e6a9c46570c44bdc3d13419730c7c221c8
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.js 5bae81684728b6be157d1f92b39824153f0fd019345b39f2ab8930f7ee2a57d8
F ext/wasm/common/SqliteTestUtil.js 647bf014bd30bdd870a7e9001e251d12fc1c9ec9ce176a1004b838a4b33c5c05
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 3cfcc14dfd220536141aeffb902fdc8db1cea055b2a0609b88e092fc3df94688
-R c3ddc7f08af0e1dfea53de525fac120d
+P 5b8f8e33afc47c9f0c64dbe34643d7d1c37a0a82afb4656e714a86ef54a9ce6f
+R 9e18661e1500a3e4cdfa05bc23635f3f
U stephan
-Z c791e943ea41f9bead968e082bef6c31
+Z e3d9878d6daf198d0150d0ecad381b11
# Remove this line to create a well-formed Fossil manifest.