Index: src/global.c
==================================================================
--- src/global.c
+++ src/global.c
@@ -165,11 +165,10 @@
(void*)0, /* pPage */
0, /* szPage */
0, /* nPage */
0, /* mxParserStack */
0, /* sharedCacheEnabled */
- SQLITE_DEFAULT_WORKER_THREADS, /* nWorker */
/* All the rest should always be initialized to zero */
0, /* isInit */
0, /* inProgress */
0, /* isMutexInit */
0, /* isMallocInit */
Index: src/main.c
==================================================================
--- src/main.c
+++ src/main.c
@@ -513,19 +513,10 @@
sqlite3GlobalConfig.nHeap = va_arg(ap, int);
break;
}
#endif
- case SQLITE_CONFIG_WORKER_THREADS: {
-#if SQLITE_MAX_WORKER_THREADS>0
- int n = va_arg(ap, int);
- if( n>SQLITE_MAX_WORKER_THREADS ) n = SQLITE_MAX_WORKER_THREADS;
- if( n>=0 ) sqlite3GlobalConfig.nWorker = n;
-#endif
- break;
- }
-
default: {
rc = SQLITE_ERROR;
break;
}
}
Index: src/pragma.c
==================================================================
--- src/pragma.c
+++ src/pragma.c
@@ -2290,11 +2290,11 @@
if( sqlite3GlobalConfig.bCoreMutex
&& zRight
&& sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK
&& N>=0
){
- if( N>sqlite3GlobalConfig.nWorker ) N = sqlite3GlobalConfig.nWorker;
+ if( N>SQLITE_MAX_WORKER_THREADS ) N = SQLITE_MAX_WORKER_THREADS;
db->mxWorker = N&0xff;
}
returnSingleInt(pParse, "soft_heap_limit", db->mxWorker);
break;
}
Index: src/shell.c
==================================================================
--- src/shell.c
+++ src/shell.c
@@ -3816,11 +3816,10 @@
memcpy(data->newline,"\r\n", 3);
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," ...> ");
}
/*
Index: src/sqlite.h.in
==================================================================
--- src/sqlite.h.in
+++ src/sqlite.h.in
@@ -1716,20 +1716,10 @@
**
^This option is only available if SQLite is compiled for Windows
** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
** that specifies the maximum size of the created heap.
**
-**
-** [[SQLITE_CONFIG_WORKER_THREADS]]
-** SQLITE_CONFIG_WORKER_THREADS
-** ^SQLITE_CONFIG_WORKER_THREADS takes a single argument of type int.
-** It is used to set the number of background worker threads that may be
-** launched when sorting large amounts of data. A value of 0 means launch
-** no background threads at all. The maximum number of background threads
-** allowed is configured at build-time by the SQLITE_MAX_WORKER_THREADS
-** pre-processor option.
-**
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -1750,11 +1740,10 @@
#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
-#define SQLITE_CONFIG_WORKER_THREADS 24 /* int nWorker */
/*
** CAPI3REF: Database Connection Configuration Options
**
** These constants are the available integer configuration options that
Index: src/sqliteInt.h
==================================================================
--- src/sqliteInt.h
+++ src/sqliteInt.h
@@ -439,13 +439,14 @@
** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
** to zero.
*/
#if SQLITE_TEMP_STORE==3
# undef SQLITE_MAX_WORKER_THREADS
+# define SQLITE_MAX_WORKER_THREADS 0
#endif
#ifndef SQLITE_MAX_WORKER_THREADS
-# define SQLITE_MAX_WORKER_THREADS 0
+# define SQLITE_MAX_WORKER_THREADS 4
#endif
#ifndef SQLITE_DEFAULT_WORKER_THREADS
# define SQLITE_DEFAULT_WORKER_THREADS 0
#endif
#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS
@@ -2762,11 +2763,10 @@
void *pPage; /* Page cache memory */
int szPage; /* Size of each page in pPage[] */
int nPage; /* Number of pages in pPage[] */
int mxParserStack; /* maximum depth of the parser stack */
int sharedCacheEnabled; /* true if shared-cache mode enabled */
- int nWorker; /* Number of worker threads to use */
/* The above might be initialized to non-zero. The following need to always
** initially be zero, however. */
int isInit; /* True after initialization has finished */
int inProgress; /* True while initialization in progress */
int isMutexInit; /* True after mutexes are initialized */
Index: src/test_malloc.c
==================================================================
--- src/test_malloc.c
+++ src/test_malloc.c
@@ -1251,35 +1251,10 @@
Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
return TCL_OK;
}
-/*
-** Usage: sqlite3_config_worker_threads N
-*/
-static int test_config_worker_threads(
- void * clientData,
- Tcl_Interp *interp,
- int objc,
- Tcl_Obj *CONST objv[]
-){
- int rc;
- int nThread;
-
- if( objc!=2 ){
- Tcl_WrongNumArgs(interp, 1, objv, "N");
- return TCL_ERROR;
- }
- if( Tcl_GetIntFromObj(interp, objv[1], &nThread) ){
- return TCL_ERROR;
- }
-
- rc = sqlite3_config(SQLITE_CONFIG_WORKER_THREADS, nThread);
- Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
-
- return TCL_OK;
-}
/*
** Usage: sqlite3_dump_memsys3 FILENAME
** sqlite3_dump_memsys5 FILENAME
**
@@ -1530,11 +1505,10 @@
{ "sqlite3_config_memstatus", test_config_memstatus ,0 },
{ "sqlite3_config_lookaside", test_config_lookaside ,0 },
{ "sqlite3_config_error", test_config_error ,0 },
{ "sqlite3_config_uri", test_config_uri ,0 },
{ "sqlite3_config_cis", test_config_cis ,0 },
- { "sqlite3_config_worker_threads", test_config_worker_threads ,0 },
{ "sqlite3_db_config_lookaside",test_db_config_lookaside ,0 },
{ "sqlite3_dump_memsys3", test_dump_memsys3 ,3 },
{ "sqlite3_dump_memsys5", test_dump_memsys3 ,5 },
{ "sqlite3_install_memsys3", test_install_memsys3 ,0 },
{ "sqlite3_memdebug_vfs_oom_test", test_vfs_oom_test ,0 },
Index: src/vdbesort.c
==================================================================
--- src/vdbesort.c
+++ src/vdbesort.c
@@ -793,14 +793,20 @@
int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */
int sz; /* Size of pSorter in bytes */
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 = db->mxWorker;
+ int nWorker = sqlite3TempInMemory(db) ? 0 : db->mxWorker ;
+#endif
+
+ /* Do not allow the total number of threads (main thread + all workers)
+ ** to exceed the maximum merge count */
+#if SQLITE_MAX_WORKER_THREADS>=SORTER_MAX_MERGE_COUNT
+ if( nWorker>=SORTER_MAX_MERGE_COUNT ){
+ nWorker = SORTER_MAX_MERGE_COUNT-1;
+ }
#endif
assert( pCsr->pKeyInfo && pCsr->pBt==0 );
szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nField-1)*sizeof(CollSeq*);
sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
Index: test/sort.test
==================================================================
--- test/sort.test
+++ test/sort.test
@@ -542,11 +542,10 @@
6 0 0 file false true 1000000
7 0 0 file false true 10000
} {
db close
sqlite3_shutdown
- sqlite3_config_worker_threads $nWorker
if {$coremutex} {
sqlite3_config multithread
} else {
sqlite3_config singlethread
}
@@ -554,11 +553,12 @@
sorter_test_fakeheap $fakeheap
sqlite3_soft_heap_limit $softheaplimit
reset_db
sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
- execsql "PRAGMA temp_store = $tmpstore"
+ execsql "PRAGMA temp_store = $tmpstore; PRAGMA threads = $nWorker"
+
set ten [string repeat X 10300]
set one [string repeat y 200]
if {$softheaplimit} {
@@ -600,11 +600,10 @@
sorter_test_fakeheap 0
}
db close
sqlite3_shutdown
-sqlite3_config_worker_threads 0
set t(0) singlethread
set t(1) multithread
set t(2) serialized
sqlite3_config $t($sqlite_options(threadsafe))
sqlite3_initialize
@@ -635,6 +634,5 @@
do_execsql_test 17.1 {
SELECT * FROM sqlite_master ORDER BY sql;
} {}
finish_test
-
Index: test/sort2.test
==================================================================
--- test/sort2.test
+++ test/sort2.test
@@ -20,13 +20,12 @@
foreach {tn script} {
1 { }
2 {
catch { db close }
- sqlite3_shutdown
- sqlite3_config_worker_threads 7
reset_db
+ catch { db eval {PRAGMA threads=7} }
}
} {
eval $script
@@ -74,15 +73,8 @@
)
SELECT count(x), length(y) FROM r GROUP BY (x%5)
} {
200000 100 200000 100 200000 100 200000 100 200000 100
}
-
- db close
- sqlite3_shutdown
- sqlite3_config_worker_threads 0
- sqlite3_initialize
-
}
finish_test
-
Index: test/sort4.test
==================================================================
--- test/sort4.test
+++ test/sort4.test
@@ -17,15 +17,11 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix sort4
# Configure the sorter to use 3 background threads.
-catch { db close }
-sqlite3_shutdown
-sqlite3_config_worker_threads 3
-sqlite3_initialize
-reset_db
+db eval {PRAGMA threads=3}
# Minimum number of seconds to run for. If the value is 0, each test
# is run exactly once. Otherwise, tests are repeated until the timeout
# expires.
set SORT4TIMEOUT 0
@@ -188,11 +184,6 @@
set iNow [clock_seconds]
if {$iNow>=$iTimeLimit} break
do_test "$testprefix-([expr $iTimeLimit-$iNow] seconds remain)" {} {}
}
-catch { db close }
-sqlite3_shutdown
-sqlite3_config_worker_threads 0
-sqlite3_initialize
finish_test
-
Index: test/sortfault.test
==================================================================
--- test/sortfault.test
+++ test/sortfault.test
@@ -28,13 +28,11 @@
3 100000 1 file multithread false false
4 2000000 0 file singlethread false true
} {
if {$sqlite_options(threadsafe)} { set threadsmode singlethread }
- catch { db close }
- sqlite3_shutdown
- sqlite3_config_worker_threads $nWorker
+ db eval "PRAGMA threads=$nWorker"
sqlite3_config $threadsmode
if { $lookaside } {
sqlite3_config_lookaside 100 500
} else {
sqlite3_config_lookaside 0 0
@@ -108,11 +106,10 @@
}
}
catch { db close }
sqlite3_shutdown
-sqlite3_config_worker_threads 0
set t(0) singlethread
set t(1) multithread
set t(2) serialized
sqlite3_config $t($sqlite_options(threadsafe))
sqlite3_config_lookaside 100 500
@@ -164,6 +161,5 @@
} -test {
faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]]
}
finish_test
-