]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Experimental: If SQLite is compiled with SQLITE_WAL_BIGHASH defined, use hash
authordan <Dan Kennedy>
Mon, 23 Dec 2024 11:23:07 +0000 (11:23 +0000)
committerdan <Dan Kennedy>
Mon, 23 Dec 2024 11:23:07 +0000 (11:23 +0000)
tables large enough to fit 128K, instead of 4K, entries in the *-shm file.

FossilOrigin-Name: 6e800b7035f55a211917d28cacf829b1681f37cbd2e6989c4cc20d4027a4192d

manifest
manifest.uuid
src/wal.c

index 893f0e4095ba46d52da8036bc22b3a09980b44c1..63e9671cbfa9883a7ecdefd34b765b9a3e631378 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C When\sloading\sstat4\sdata,\smake\sa\ssingle\slarge\sallocation\sfor\sall\sIndex.aSample[]\sarrays,\sinstead\sof\sa\sseparate\sallocation\sfor\seach.
-D 2024-12-20T19:37:41.637
+C Experimental:\sIf\sSQLite\sis\scompiled\swith\sSQLITE_WAL_BIGHASH\sdefined,\suse\shash\ntables\slarge\senough\sto\sfit\s128K,\sinstead\sof\s4K,\sentries\sin\sthe\s*-shm\sfile.
+D 2024-12-23T11:23:07.782
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -857,7 +857,7 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8
 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3
 F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c 9dc2b38da29d4aa24f0ce5610f36b6b911f152bc1af7ae09495d8bd57517d046
+F src/wal.c dcc414ebe459a3f1f4a843d504047cbae631886802a33287783fa1de19ab7e77
 F src/wal.h 8c59ee7a835574396d7cbd04626d11fd849613e361a46e7e9519091ab03bdb29
 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014
 F src/where.c c046dd58c3410f7b7528e1e6317cb876398557bad346d568ed8562321a7d002d
@@ -2250,8 +2250,9 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P fa87355f6286be1e92f22a71cbfbfb13d1a478d5fb5b38abedbd78bf903171fa
-R 9097e0f64b77340a961f20f33cb504fb
+P b40cd7395c44b1f2d019d8e809e03de0e083c93693322a72ddb250a85640528f
+Q +0cb853ea1dece578ae8f336c7d003e618d94ba003e25e5f5f307d7424f31b53f
+R 0db94f9b5016d4409837d31c4cf69ba3
 U dan
-Z f620b0a1456c2c860e9486abd7f7bdfb
+Z 036d387cdbb87985088d735f94a3d8ac
 # Remove this line to create a well-formed Fossil manifest.
index 5f9bc9a5c6fe3e689f452ef166619976d3626f88..1ac53afc427283e399b16f2ad7c146e77b0805fa 100644 (file)
@@ -1 +1 @@
-b40cd7395c44b1f2d019d8e809e03de0e083c93693322a72ddb250a85640528f
+6e800b7035f55a211917d28cacf829b1681f37cbd2e6989c4cc20d4027a4192d
index 904ffcdfaa1a2cbf401b9f9f86621bb9dfd4bcd8..02f04fdcc069e89627daa6b969bac3104a847f42 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -458,8 +458,13 @@ int sqlite3WalTrace = 0;
 ** version-2 ("journal_mode=wal2"). Legacy clients may support version-1
 ** only.
 */
-#define WAL_VERSION1 3007000      /* For "journal_mode=wal" */
-#define WAL_VERSION2 3021000      /* For "journal_mode=wal2" */
+#ifdef SQLITE_WAL_BIGHASH
+# define WAL_VERSION1 3007001      /* For "journal_mode=wal" */
+# define WAL_VERSION2 3021001      /* For "journal_mode=wal2" */
+#else
+# define WAL_VERSION1 3007000      /* For "journal_mode=wal" */
+# define WAL_VERSION2 3021000      /* For "journal_mode=wal2" */
+#endif
 
 #define SQLITE_ENABLE_WAL2NOCKSUM 1
 
@@ -844,7 +849,11 @@ struct Wal {
 ** Each page of the wal-index mapping contains a hash-table made up of
 ** an array of HASHTABLE_NSLOT elements of the following type.
 */
-typedef u16 ht_slot;
+#ifdef SQLITE_WAL_BIGHASH
+ typedef u32 ht_slot;
+#else
+ typedef u16 ht_slot;
+#endif
 
 /*
 ** This structure is used to implement an iterator that loops through
@@ -881,9 +890,14 @@ struct WalIterator {
 ** Changing any of these constants will alter the wal-index format and
 ** create incompatibilities.
 */
-#define HASHTABLE_NPAGE      4096                 /* Must be power of 2 */
-#define HASHTABLE_HASH_1     383                  /* Should be prime */
-#define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */
+#ifdef SQLITE_WAL_BIGHASH
+# define HASHTABLE_BITS       17                   /* 128K frames per hash */
+#else
+# define HASHTABLE_BITS       12                   /* 4K frames per hash */
+#endif
+# define HASHTABLE_NPAGE      (1<<HASHTABLE_BITS)  /* Must be power of 2 */
+# define HASHTABLE_HASH_1     383                  /* Should be prime */
+# define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */
 
 /*
 ** The block of page numbers associated with the first hash-table in a
@@ -2224,11 +2238,13 @@ int sqlite3WalOpen(
   assert(    40 ==  sizeof(WalCkptInfo)  );
   assert(   120 ==  WALINDEX_LOCK_OFFSET );
   assert(   136 ==  WALINDEX_HDR_SIZE    );
+#ifndef SQLITE_WAL_BIGHASH
   assert(  4096 ==  HASHTABLE_NPAGE      );
   assert(  4062 ==  HASHTABLE_NPAGE_ONE  );
   assert(  8192 ==  HASHTABLE_NSLOT      );
   assert(   383 ==  HASHTABLE_HASH_1     );
   assert( 32768 ==  WALINDEX_PGSZ        );
+#endif
   assert(     8 ==  SQLITE_SHM_NLOCK     );
   assert(     5 ==  WAL_NREADER          );
   assert(    24 ==  WAL_FRAME_HDRSIZE    );
@@ -2443,7 +2459,7 @@ static void walMergesort(
   ht_slot *aMerge = 0;            /* List to be merged */
   int iList;                      /* Index into input list */
   u32 iSub = 0;                   /* Index into aSub array */
-  struct Sublist aSub[13];        /* Array of sub-lists */
+  struct Sublist aSub[HASHTABLE_BITS+1];    /* Array of sub-lists */
 
   memset(aSub, 0, sizeof(aSub));
   assert( nList<=HASHTABLE_NPAGE && nList>0 );