]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Query or change the maximum number of worker threads allowed on each
authordrh <drh@noemail.net>
Mon, 25 Aug 2014 15:13:22 +0000 (15:13 +0000)
committerdrh <drh@noemail.net>
Mon, 25 Aug 2014 15:13:22 +0000 (15:13 +0000)
database connection separately using the "PRAGMA threads" command.

FossilOrigin-Name: 29c5e8a7c9d7ce349a1e1d72082d23450e877b45

manifest
manifest.uuid
src/pragma.c
src/shell.c
src/sqliteInt.h
src/vdbesort.c
tool/mkpragmatab.tcl

index d18353dedb07852ccd0d5304d6010d11bdbb4a7d..22dd6d848a955b70ed761be97c4067d88e4204cd 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\sthe\srecent\sperformance\senhancements\simplemented\son\strunk\sinto\sthe\nthreads\sbranch.
-D 2014-08-25T13:27:02.036
+C Query\sor\schange\sthe\smaximum\snumber\sof\sworker\sthreads\sallowed\son\seach\ndatabase\sconnection\sseparately\susing\sthe\s"PRAGMA\sthreads"\scommand.
+D 2014-08-25T15:13:22.455
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -217,18 +217,18 @@ F src/parse.y 22d6a074e5f5a7258947a1dc55a9bf946b765dd0
 F src/pcache.c da602c5447051705cab41604bf3276815eb569d0
 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
 F src/pcache1.c c5af6403a55178c9d1c09e4f77b0f9c88822762c
-F src/pragma.c d10ef67c4de79f78188b965b4b7988aff1d66f2e
+F src/pragma.c 4ed8bc86d1a9ee336e66bc441b30abb702f4de33
 F src/prepare.c 3842c1dfc0b053458e3adcf9f6efc48e03e3fe3d
 F src/printf.c 00986c86ddfffefc2fd3c73667ff51b3b9709c74
 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece
 F src/resolve.c 0ea356d32a5e884add23d1b9b4e8736681dd5697
 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be
 F src/select.c f8b0b6c43bee15f4e239ead1c9c9e3009e507e39
-F src/shell.c 200772eebd7b0fcf2072fc3dbd95d694389d5efa
+F src/shell.c 6dab215a30f7ca4d5fc31338c44b007bb6ef0dee
 F src/sqlite.h.in fef15a64d1358f5c365bd3f46f4c1915d5a5e5f0
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
-F src/sqliteInt.h 80d0bb053ef728896142c4e808bfcdc49494e9be
+F src/sqliteInt.h d8eb2d4d4ce26365dc9d49efee3bc880618e87c2
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -292,7 +292,7 @@ F src/vdbeapi.c cda974083d7597f807640d344ffcf76d872201ce
 F src/vdbeaux.c cef5d34a64ae3a65b56d96d3fd663246ec8e1c36
 F src/vdbeblob.c 848238dc73e93e48432991bb5651bf87d865eca4
 F src/vdbemem.c 4c9d686da474957d2e78834f13cc5f141fe6b87f
-F src/vdbesort.c b9a830685826c057cfd41993902a5afc6fe436e1
+F src/vdbesort.c 3a76f51efdf0790fd3d26afabdd81e0a21f52ae7
 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
 F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
 F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a
@@ -1158,7 +1158,7 @@ F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6
 F tool/mkautoconfamal.sh 5dc5010e2e748a9e1bba67baca5956a2c2deda7b
 F tool/mkkeywordhash.c dfff09dbbfaf950e89af294f48f902181b144670
 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
-F tool/mkpragmatab.tcl 78a77b2c554d534c6f2dc903130186ed15715460
+F tool/mkpragmatab.tcl cce51d8f60c7f145d8fccabe6b5dfdedf31c5f5c
 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
 F tool/mksqlite3c-noext.tcl 88a1e3b0c769773fb7a9ebb363ffc603a4ac21d8
 F tool/mksqlite3c.tcl e72c0c97fe1a105fa9616483e652949be2199fe6
@@ -1193,7 +1193,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 05807c4122505567ec64fb2d142077f48a0a10b1 54164ce47cfc3ad5dd8797114e4ba78811f23bef
-R c157557aea90a1674d041ac0f1de2f68
+P dfdc900f5d1a31ee5c5f35a630c4a8253e69093b
+R 4c161b4070e5a7022237a28172d6e331
 U drh
-Z 10ad80e0aa78a5fbf32d4d843030da4f
+Z 1c68bfb86ec54e7d60991aea6df8a67a
index 8fecff4bd8bf3d2be208fc0e1bd3d1c87110ec14..645cc6429f04901bb630b0397e98cec634341898 100644 (file)
@@ -1 +1 @@
-dfdc900f5d1a31ee5c5f35a630c4a8253e69093b
\ No newline at end of file
+29c5e8a7c9d7ce349a1e1d72082d23450e877b45
\ No newline at end of file
index 9ed5e13eb0fb1c4ff6bfdfc99bf79d4ea73e319d..897d3b5d24702ebf10abf66ff9621f4960b55bad 100644 (file)
 #define PragTyp_TABLE_INFO                    30
 #define PragTyp_TEMP_STORE                    31
 #define PragTyp_TEMP_STORE_DIRECTORY          32
-#define PragTyp_WAL_AUTOCHECKPOINT            33
-#define PragTyp_WAL_CHECKPOINT                34
-#define PragTyp_ACTIVATE_EXTENSIONS           35
-#define PragTyp_HEXKEY                        36
-#define PragTyp_KEY                           37
-#define PragTyp_REKEY                         38
-#define PragTyp_LOCK_STATUS                   39
-#define PragTyp_PARSER_TRACE                  40
+#define PragTyp_THREADS                       33
+#define PragTyp_WAL_AUTOCHECKPOINT            34
+#define PragTyp_WAL_CHECKPOINT                35
+#define PragTyp_ACTIVATE_EXTENSIONS           36
+#define PragTyp_HEXKEY                        37
+#define PragTyp_KEY                           38
+#define PragTyp_REKEY                         39
+#define PragTyp_LOCK_STATUS                   40
+#define PragTyp_PARSER_TRACE                  41
 #define PragFlag_NeedSchema           0x01
 static const struct sPragmaNames {
   const char *const zName;  /* Name of pragma */
@@ -418,6 +419,10 @@ static const struct sPragmaNames {
     /* ePragFlag: */ 0,
     /* iArg:      */ 0 },
 #endif
+  { /* zName:     */ "threads",
+    /* ePragTyp:  */ PragTyp_THREADS,
+    /* ePragFlag: */ 0,
+    /* iArg:      */ 0 },
 #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   { /* zName:     */ "user_version",
     /* ePragTyp:  */ PragTyp_HEADER_VALUE,
@@ -465,7 +470,7 @@ static const struct sPragmaNames {
     /* iArg:      */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
 #endif
 };
-/* Number of pragmas: 56 on by default, 69 total. */
+/* Number of pragmas: 57 on by default, 70 total. */
 /* End of the automatically generated pragma table.
 ***************************************************************************/
 
@@ -2273,6 +2278,27 @@ void sqlite3Pragma(
     break;
   }
 
+  /*
+  **   PRAGMA threads
+  **   PRAGMA threads = N
+  **
+  ** Configure the maximum number of worker threads.  Return the new
+  ** maximum, which might be less than requested.
+  */
+  case PragTyp_THREADS: {
+    sqlite3_int64 N;
+    if( sqlite3GlobalConfig.bCoreMutex
+     && zRight
+     && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK
+     && N>=0
+    ){
+      if( N>sqlite3GlobalConfig.nWorker ) N = sqlite3GlobalConfig.nWorker;
+      db->mxWorker = N&0xff;
+    }
+    returnSingleInt(pParse, "soft_heap_limit",  db->mxWorker);
+    break;
+  }
+
 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
   /*
   ** Report the current state of file logs for all databases
index f2a275fe39c89a397d9753828e0bf85fbea550f8..0357c1a082bc5c078c584fd940b8d5c110ec680e 100644 (file)
@@ -3817,10 +3817,10 @@ static void main_init(ShellState *data) {
   data->showHeader = 0;
   sqlite3_config(SQLITE_CONFIG_URI, 1);
   sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
+  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+  sqlite3_config(SQLITE_CONFIG_WORKER_THREADS, 64);
   sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
   sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
-  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
-  sqlite3_config(SQLITE_CONFIG_WORKER_THREADS, 4);
 }
 
 /*
index f3d49a7b10847256a42a02c508004f9128cfb60b..ce123b395fca3d68b898fc5a8f313a419d0cf355 100644 (file)
@@ -1012,6 +1012,7 @@ struct sqlite3 {
   u8 suppressErr;               /* Do not issue error messages if true */
   u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */
   u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */
+  u8 mxWorker;                  /* Maximum number of worker threads */
   int nextPagesize;             /* Pagesize after VACUUM if >0 */
   u32 magic;                    /* Magic number for detect library misuse */
   int nChange;                  /* Value returned by sqlite3_changes() */
index 6915a2a9b9126685136bd6396d0db081cdd040fa..e71b19fc1164569191f698faffd676befd8c849c 100644 (file)
@@ -795,8 +795,10 @@ int sqlite3VdbeSorterInit(
   int rc = SQLITE_OK;
 #if SQLITE_MAX_WORKER_THREADS==0
 # define nWorker 0
+#elif SQLITE_MAX_WORKER_THREADS>=SORTER_MAX_MERGE_COUNT
+  int nWorker = MIN(SORTER_MAX_MERGE_COUNT-1, db->mxWorker);
 #else
-  int nWorker = (sqlite3GlobalConfig.bCoreMutex?sqlite3GlobalConfig.nWorker:0);
+  int nWorker = db->mxWorker;
 #endif
 
   assert( pCsr->pKeyInfo && pCsr->pBt==0 );
index 28a1e468b89ed2a3a3d0971402c23ab1350a027d..aa7c8078c556446a10dea6e8a5a39d4781329681 100644 (file)
@@ -294,6 +294,8 @@ set pragma_def {
   IF:   defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
 
   NAME: soft_heap_limit
+
+  NAME: threads
 }
 fconfigure stdout -translation lf
 set name {}