Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove the SQLITE_CONFIG_WORKER_THREADS configuration parameter. The number of worker threads in the sorter is now determined only by the PRAGMA threads=N setting. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | threads |
Files: | files | file ages | folders |
SHA1: |
e3305d4b4efcbe06945ce7f6ec0f2e86 |
User & Date: | drh 2014-08-25 23:44:44.281 |
Context
2014-08-29
| ||
14:40 | Merge recent performance enhancements from trunk onto the threads branch. (check-in: 35c44a3c73 user: drh tags: threads) | |
2014-08-25
| ||
23:44 | Remove the SQLITE_CONFIG_WORKER_THREADS configuration parameter. The number of worker threads in the sorter is now determined only by the PRAGMA threads=N setting. (check-in: e3305d4b4e user: drh tags: threads) | |
22:43 | Merge the CAST operator enhancements from trunk. (check-in: 6c8f86e4e0 user: drh tags: threads) | |
Changes
Changes to src/global.c.
︙ | ︙ | |||
163 164 165 166 167 168 169 | 0, /* szScratch */ 0, /* nScratch */ (void*)0, /* pPage */ 0, /* szPage */ 0, /* nPage */ 0, /* mxParserStack */ 0, /* sharedCacheEnabled */ | < | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 0, /* szScratch */ 0, /* nScratch */ (void*)0, /* pPage */ 0, /* szPage */ 0, /* nPage */ 0, /* mxParserStack */ 0, /* sharedCacheEnabled */ /* All the rest should always be initialized to zero */ 0, /* isInit */ 0, /* inProgress */ 0, /* isMutexInit */ 0, /* isMallocInit */ 0, /* isPCacheInit */ 0, /* nRefInitMutex */ |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
511 512 513 514 515 516 517 | #if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC) case SQLITE_CONFIG_WIN32_HEAPSIZE: { sqlite3GlobalConfig.nHeap = va_arg(ap, int); break; } #endif | < < < < < < < < < | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | #if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC) case SQLITE_CONFIG_WIN32_HEAPSIZE: { sqlite3GlobalConfig.nHeap = va_arg(ap, int); break; } #endif default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; |
︙ | ︙ |
Changes to src/pragma.c.
︙ | ︙ | |||
2288 2289 2290 2291 2292 2293 2294 | case PragTyp_THREADS: { sqlite3_int64 N; if( sqlite3GlobalConfig.bCoreMutex && zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK && N>=0 ){ | | | 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 | case PragTyp_THREADS: { sqlite3_int64 N; if( sqlite3GlobalConfig.bCoreMutex && zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK && N>=0 ){ if( N>SQLITE_MAX_WORKER_THREADS ) N = SQLITE_MAX_WORKER_THREADS; db->mxWorker = N&0xff; } returnSingleInt(pParse, "soft_heap_limit", db->mxWorker); break; } #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
3814 3815 3816 3817 3818 3819 3820 | data->mode = MODE_List; memcpy(data->separator,"|", 2); 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); | < | 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 | data->mode = MODE_List; memcpy(data->separator,"|", 2); 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_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); } /* ** Output text to the console in a font that attracts extra attention. */ |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
1714 1715 1716 1717 1718 1719 1720 | ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]] ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE ** <dd>^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. ** </dl> | < < < < < < < < < < | 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 | ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]] ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE ** <dd>^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. ** </dl> */ #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* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ |
︙ | ︙ | |||
1748 1749 1750 1751 1752 1753 1754 | #define SQLITE_CONFIG_URI 17 /* int */ #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ #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 */ | < | 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 | #define SQLITE_CONFIG_URI 17 /* int */ #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ #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 */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** |
︙ | ︙ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
437 438 439 440 441 442 443 444 445 | /* ** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if ** 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 #endif #ifndef SQLITE_MAX_WORKER_THREADS | > | | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | /* ** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if ** 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 4 #endif #ifndef SQLITE_DEFAULT_WORKER_THREADS # define SQLITE_DEFAULT_WORKER_THREADS 0 #endif #if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS # undef SQLITE_MAX_WORKER_THREADS # define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS |
︙ | ︙ | |||
2760 2761 2762 2763 2764 2765 2766 | int szScratch; /* Size of each scratch buffer */ int nScratch; /* Number of scratch buffers */ 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 */ | < | 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 | int szScratch; /* Size of each scratch buffer */ int nScratch; /* Number of scratch buffers */ 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 */ /* 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 */ int isMallocInit; /* True after malloc is initialized */ int isPCacheInit; /* True after malloc is initialized */ |
︙ | ︙ |
Changes to src/test_malloc.c.
︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 | rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis); Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 | rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis); Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); return TCL_OK; } /* ** Usage: sqlite3_dump_memsys3 FILENAME ** sqlite3_dump_memsys5 FILENAME ** ** Write a summary of unfreed memsys3 allocations to FILENAME. */ |
︙ | ︙ | |||
1528 1529 1530 1531 1532 1533 1534 | { "sqlite3_config_heap", test_config_heap ,0 }, { "sqlite3_config_heap_size", test_config_heap_size ,0 }, { "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 }, | < | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 | { "sqlite3_config_heap", test_config_heap ,0 }, { "sqlite3_config_heap_size", test_config_heap_size ,0 }, { "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_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 }, }; int i; |
︙ | ︙ |
Changes to src/vdbesort.c.
︙ | ︙ | |||
791 792 793 794 795 796 797 | VdbeSorter *pSorter; /* The new sorter */ KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */ 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 | > > > > > > | | < | > | 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | VdbeSorter *pSorter; /* The new sorter */ KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */ 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 #else 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); pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo); |
︙ | ︙ |
Changes to test/sort.test.
︙ | ︙ | |||
540 541 542 543 544 545 546 | 4 1000000 3 file true false 0 5 0 0 memory false true 0 6 0 0 file false true 1000000 7 0 0 file false true 10000 } { db close sqlite3_shutdown | < | > | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | 4 1000000 3 file true false 0 5 0 0 memory false true 0 6 0 0 file false true 1000000 7 0 0 file false true 10000 } { db close sqlite3_shutdown if {$coremutex} { sqlite3_config multithread } else { sqlite3_config singlethread } sqlite3_initialize 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; PRAGMA threads = $nWorker" set ten [string repeat X 10300] set one [string repeat y 200] if {$softheaplimit} { execsql { PRAGMA cache_size = 20 }; } else { |
︙ | ︙ | |||
598 599 600 601 602 603 604 | } [list 2 $one 4 $ten] sorter_test_fakeheap 0 } db close sqlite3_shutdown | < | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | } [list 2 $one 4 $ten] sorter_test_fakeheap 0 } db close sqlite3_shutdown set t(0) singlethread set t(1) multithread set t(2) serialized sqlite3_config $t($sqlite_options(threadsafe)) sqlite3_initialize sqlite3_soft_heap_limit 0 |
︙ | ︙ | |||
633 634 635 636 637 638 639 | reset_db do_execsql_test 17.1 { SELECT * FROM sqlite_master ORDER BY sql; } {} finish_test | < | 632 633 634 635 636 637 638 | reset_db do_execsql_test 17.1 { SELECT * FROM sqlite_master ORDER BY sql; } {} finish_test |
Changes to test/sort2.test.
︙ | ︙ | |||
18 19 20 21 22 23 24 | source $testdir/tester.tcl set testprefix sort2 foreach {tn script} { 1 { } 2 { catch { db close } | < < > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | source $testdir/tester.tcl set testprefix sort2 foreach {tn script} { 1 { } 2 { catch { db close } reset_db catch { db eval {PRAGMA threads=7} } } } { eval $script do_execsql_test $tn.1 { PRAGMA cache_size = 5; |
︙ | ︙ | |||
72 73 74 75 76 77 78 | SELECT x+1, randomblob(100) FROM r LIMIT 1000000 ) SELECT count(x), length(y) FROM r GROUP BY (x%5) } { 200000 100 200000 100 200000 100 200000 100 200000 100 } | < < < < < < < | 71 72 73 74 75 76 77 78 79 80 | SELECT x+1, randomblob(100) FROM r LIMIT 1000000 ) SELECT count(x), length(y) FROM r GROUP BY (x%5) } { 200000 100 200000 100 200000 100 200000 100 200000 100 } } finish_test |
Changes to test/sort4.test.
︙ | ︙ | |||
15 16 17 18 19 20 21 | # set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix sort4 # Configure the sorter to use 3 background threads. | < < | < < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix sort4 # Configure the sorter to use 3 background threads. 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 if {[permutation] == "multithread"} { set SORT4TIMEOUT 300 } |
︙ | ︙ | |||
186 187 188 189 190 191 192 | do_sorter_test $t.8 -repeats 10 -rows 100000 -read 10000 -cachesize 250 set iNow [clock_seconds] if {$iNow>=$iTimeLimit} break do_test "$testprefix-([expr $iTimeLimit-$iNow] seconds remain)" {} {} } | < < < < < | 182 183 184 185 186 187 188 189 | do_sorter_test $t.8 -repeats 10 -rows 100000 -read 10000 -cachesize 250 set iNow [clock_seconds] if {$iNow>=$iTimeLimit} break do_test "$testprefix-([expr $iTimeLimit-$iNow] seconds remain)" {} {} } finish_test |
Changes to test/sortfault.test.
︙ | ︙ | |||
26 27 28 29 30 31 32 | 1 0 0 file multithread false false 2 100000 0 file multithread false false 3 100000 1 file multithread false false 4 2000000 0 file singlethread false true } { if {$sqlite_options(threadsafe)} { set threadsmode singlethread } | < < | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 1 0 0 file multithread false false 2 100000 0 file multithread false false 3 100000 1 file multithread false false 4 2000000 0 file singlethread false true } { if {$sqlite_options(threadsafe)} { set threadsmode singlethread } db eval "PRAGMA threads=$nWorker" sqlite3_config $threadsmode if { $lookaside } { sqlite3_config_lookaside 100 500 } else { sqlite3_config_lookaside 0 0 } sqlite3_initialize |
︙ | ︙ | |||
106 107 108 109 110 111 112 | sqlite3_memdebug_vfs_oom_test 1 } } catch { db close } sqlite3_shutdown | < | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | sqlite3_memdebug_vfs_oom_test 1 } } catch { db close } sqlite3_shutdown set t(0) singlethread set t(1) multithread set t(2) serialized sqlite3_config $t($sqlite_options(threadsafe)) sqlite3_config_lookaside 100 500 sqlite3_initialize |
︙ | ︙ | |||
162 163 164 165 166 167 168 | do_faultsim_test 5.1 -faults oom* -body { execsql { SELECT * FROM t1 ORDER BY a } } -test { faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]] } finish_test | < | 159 160 161 162 163 164 165 | do_faultsim_test 5.1 -faults oom* -body { execsql { SELECT * FROM t1 ORDER BY a } } -test { faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]] } finish_test |