Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch pcache-bulk-local Excluding Merge-Ins
This is equivalent to a diff from 6d2999afbc to c1e2ed0ef4
2015-07-08
| ||
16:22 | Enhance the pcache1 page cache so that it tries to allocate a block of SQLITE_DEFAULT_PCACHE_INITSZ pages from malloc() on startup, and uses those preallocated pages when possible rather than going to malloc() for each individual page. About a 5% performance increase for some workloads. (check-in: 5348ffc3fd user: drh tags: trunk) | |
14:13 | Comment fix. No changes to code. (Closed-Leaf check-in: c1e2ed0ef4 user: drh tags: pcache-bulk-local) | |
13:40 | Do not do the bulk pcache1 allocations if SQLITE_CONFIG_PAGECACHE specifies a global page cache buffer. (check-in: 75d98dae67 user: drh tags: pcache-bulk-local) | |
2015-07-06
| ||
20:27 | Speed up seek operations on fts5 b-tree structures. (check-in: 7b7da1eb43 user: dan tags: trunk) | |
18:54 | Enhance separate pcache1 to allocate a block of pages from heap on startup, if possible, for a 5.2% performance improvement. (check-in: aa7341c873 user: drh tags: pcache-bulk-local) | |
2015-07-05
| ||
22:15 | Do not allow recursive CTEs that use aggregate queries in the recursive part. (check-in: 6d2999afbc user: drh tags: trunk) | |
2015-07-04
| ||
18:44 | Optimize seek operations on fts5 b-trees. (check-in: 8cf02090ce user: dan tags: trunk) | |
Changes to src/btree.c.
︙ | |||
9115 9116 9117 9118 9119 9120 9121 | 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 | - + | */ i = get2byte(&data[hdr+1]); while( i>0 ){ int size, j; assert( (u32)i<=usableSize-4 ); /* Enforced by btreeInitPage() */ size = get2byte(&data[i+2]); assert( (u32)(i+size)<=usableSize ); /* Enforced by btreeInitPage() */ |
︙ |
Changes to src/global.c.
︙ | |||
182 183 184 185 186 187 188 | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | - + | SQLITE_DEFAULT_MMAP_SIZE, /* szMmap */ SQLITE_MAX_MMAP_SIZE, /* mxMmap */ (void*)0, /* pScratch */ 0, /* szScratch */ 0, /* nScratch */ (void*)0, /* pPage */ 0, /* szPage */ |
︙ |
Changes to src/pcache1.c.
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - | ** runtime using sqlite3_config(SQLITE_CONFIG_PCACHE_HDRSZ, &size). The ** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this ** size can vary according to architecture, compile-time options, and ** SQLite library version number. ** ** If SQLITE_PCACHE_SEPARATE_HEADER is defined, then the extension is obtained ** using a separate memory allocation from the database page content. This |
︙ | |||
101 102 103 104 105 106 107 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | - - + + + + + + - - + + + - + | struct PCache1 { /* Cache configuration parameters. Page size (szPage) and the purgeable ** flag (bPurgeable) are set when the cache is created. nMax may be ** modified at any time by a call to the pcache1Cachesize() method. ** The PGroup mutex must be held when accessing nMax. */ PGroup *pGroup; /* PGroup this cache belongs to */ |
︙ | |||
204 205 206 207 208 209 210 211 212 213 214 215 216 217 | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | + | ** ** This routine is called from sqlite3_initialize() and so it is guaranteed ** to be serialized already. There is no need for further mutexing. */ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){ if( pcache1.isInit ){ PgFreeslot *p; if( pBuf==0 ) sz = n = 0; sz = ROUNDDOWN8(sz); pcache1.szSlot = sz; pcache1.nSlot = pcache1.nFreeSlot = n; pcache1.nReserve = n>90 ? 10 : (n/10 + 1); pcache1.pStart = pBuf; pcache1.pFree = 0; pcache1.bUnderPressure = 0; |
︙ | |||
268 269 270 271 272 273 274 | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | - + - + - + - | } return p; } /* ** Free an allocated buffer obtained from pcache1Alloc(). */ |
︙ | |||
321 322 323 324 325 326 327 | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | + + + + + + + - - - - - + + + + + + + - - - - - - - + + + + + + + - - + + + - - - + + + + + - - - - + + + + - - - - - - + - - - + + + + + + + + - - + + - | /* ** Allocate a new page object initially associated with cache pCache. */ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ PgHdr1 *p = 0; void *pPg; assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); if( pCache->pFree ){ p = pCache->pFree; pCache->pFree = p->pNext; p->pNext = 0; }else{ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
︙ | |||
568 569 570 571 572 573 574 575 576 577 578 579 580 581 | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | + + + + + + + + + + + + + + + + + + + + + + + + + | /* ** Implementation of the sqlite3_pcache.xInit method. */ static int pcache1Init(void *NotUsed){ UNUSED_PARAMETER(NotUsed); assert( pcache1.isInit==0 ); memset(&pcache1, 0, sizeof(pcache1)); /* ** The pcache1.separateCache variable is true if each PCache has its own ** private PGroup (mode-1). pcache1.separateCache is false if the single ** PGroup in pcache1.grp is used for all page caches (mode-2). ** ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT ** ** * Use a unified cache in single-threaded applications that have ** configured a start-time buffer for use as page-cache memory using ** sqlite3_config(SQLITE_CONFIG_PAGECACHE, pBuf, sz, N) with non-NULL ** pBuf argument. ** ** * Otherwise use separate caches (mode-1) */ #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) pcache1.separateCache = 0; #elif SQLITE_THREADSAFE pcache1.separateCache = sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.bCoreMutex>0; #else pcache1.separateCache = sqlite3GlobalConfig.pPage==0; #endif #if SQLITE_THREADSAFE if( sqlite3GlobalConfig.bCoreMutex ){ pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); } #endif pcache1.grp.mxPinned = 10; |
︙ | |||
603 604 605 606 607 608 609 | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** Allocate a new cache. */ static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){ PCache1 *pCache; /* The newly created page cache */ PGroup *pGroup; /* The group the new page cache will belong to */ int sz; /* Bytes of memory required to allocate the new cache */ |
︙ | |||
738 739 740 741 742 743 744 | 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | - + - - - - + + + - - - - - - - + - - | return 0; } if( pCache->nPage>=pCache->nHash ) pcache1ResizeHash(pCache); assert( pCache->nHash>0 && pCache->apHash ); /* Step 4. Try to recycle a page. */ |
︙ | |||
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | + | assert( pGroup->nMaxPage >= pCache->nMax ); pGroup->nMaxPage -= pCache->nMax; assert( pGroup->nMinPage >= pCache->nMin ); pGroup->nMinPage -= pCache->nMin; pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pcache1EnforceMaxPage(pGroup); pcache1LeaveMutex(pGroup); sqlite3_free(pCache->pBulk); sqlite3_free(pCache->apHash); sqlite3_free(pCache); } /* ** This function is called during initialization (sqlite3_initialize()) to ** install the default pluggable cache module, assuming the user has not |
︙ | |||
1088 1089 1090 1091 1092 1093 1094 | 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | - + | ** been released, the function returns. The return value is the total number ** of bytes of memory released. */ int sqlite3PcacheReleaseMemory(int nReq){ int nFree = 0; assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
︙ |
Changes to src/sqliteInt.h.
︙ | |||
505 506 507 508 509 510 511 512 513 514 515 516 517 518 | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | + + + + + + + + + + | # 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 #endif /* ** The default initial allocation for the pagecache when using separate ** pagecaches for each database connection. A positive number is the ** number of pages. A negative number N translations means that a buffer ** of -1024*N bytes is allocated and used for as many pages as it will hold. */ #ifndef SQLITE_DEFAULT_PCACHE_INITSZ # define SQLITE_DEFAULT_PCACHE_INITSZ 100 #endif /* ** GCC does not define the offsetof() macro so we'll have to do it ** ourselves. */ #ifndef offsetof #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) |
︙ |
Changes to test/memdb.test.
︙ | |||
415 416 417 418 419 420 421 | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | - + - - - + + | execsql { PRAGMA auto_vacuum = full; CREATE TABLE t1(a); INSERT INTO t1 VALUES(randstr(1000,1000)); INSERT INTO t1 VALUES(randstr(1000,1000)); INSERT INTO t1 VALUES(randstr(1000,1000)); } |
Changes to test/memsubsys1.test.
︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | + | set xtra_size 290 # Test 1: Both PAGECACHE and SCRATCH are shut down. # db close sqlite3_shutdown sqlite3_config_lookaside 0 0 sqlite3_config_pagecache 0 0 sqlite3_initialize reset_highwater_marks build_test_db memsubsys1-1 {PRAGMA page_size=1024} do_test memsubsys1-1.3 { set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] } 0 do_test memsubsys1-1.4 { |
︙ | |||
111 112 113 114 115 116 117 118 119 120 | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | + - | # Test 3: Activate PAGECACHE with 20 pages but use the wrong page size # so that PAGECACHE is not used. # db close sqlite3_shutdown sqlite3_config_pagecache [expr 512+$xtra_size] 20 sqlite3_config singlethread sqlite3_initialize reset_highwater_marks build_test_db memsubsys1-3.1 {PRAGMA page_size=1024} |
︙ | |||
308 309 310 311 312 313 314 315 316 317 | 309 310 311 312 313 314 315 316 317 318 319 | + | db close sqlite3_shutdown sqlite3_config_memstatus 1 sqlite3_config_pagecache 0 0 sqlite3_config_scratch 0 0 sqlite3_config_lookaside 100 500 sqlite3_config serialized sqlite3_initialize autoinstall_test_functions finish_test |
Changes to test/pcache2.test.
︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | + | # pages are being used for cache. # do_test pcache2-1.1 { db close sqlite3_reset_auto_extension sqlite3_shutdown sqlite3_config_pagecache 6000 100 sqlite3_config singlethread sqlite3_initialize autoinstall_test_functions sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1 sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0 } {0 0 0} # Open up two database connections to separate files. |
︙ | |||
69 70 71 72 73 74 75 76 77 78 79 | 70 71 72 73 74 75 76 77 78 79 80 81 | + | } {0 13 13} db close catch {db2 close} sqlite3_reset_auto_extension sqlite3_shutdown sqlite3_config_pagecache 0 0 sqlite3_config serialized sqlite3_initialize autoinstall_test_functions finish_test |
Changes to test/speedtest1.c.
︙ | |||
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 | + | int doIncrvac = 0; /* True for --incrvacuum */ const char *zJMode = 0; /* Journal mode */ const char *zKey = 0; /* Encryption key */ int nLook = 0, szLook = 0; /* --lookaside configuration */ int noSync = 0; /* True for --nosync */ int pageSize = 0; /* Desired page size. 0 means default */ int nPCache = 0, szPCache = 0;/* --pcache configuration */ int doPCache = 0; /* True if --pcache is seen */ int nScratch = 0, szScratch=0;/* --scratch configuration */ int showStats = 0; /* True for --stats */ int nThread = 0; /* --threads value */ const char *zTSet = "main"; /* Which --testset torun */ int doTrace = 0; /* True for --trace */ const char *zEncoding = 0; /* --utf16be or --utf16le */ const char *zDbName = 0; /* Name of the test database */ |
︙ | |||
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 | 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 | + | }else if( strcmp(z,"pagesize")==0 ){ if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); pageSize = integerValue(argv[++i]); }else if( strcmp(z,"pcache")==0 ){ if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); nPCache = integerValue(argv[i+1]); szPCache = integerValue(argv[i+2]); doPCache = 1; i += 2; }else if( strcmp(z,"primarykey")==0 ){ g.zPK = "PRIMARY KEY"; }else if( strcmp(z,"reprepare")==0 ){ g.bReprepare = 1; }else if( strcmp(z,"scratch")==0 ){ if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); |
︙ | |||
1313 1314 1315 1316 1317 1318 1319 | 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 | + - - - - + + + + + | #if SQLITE_VERSION_NUMBER>=3006001 if( nHeap>0 ){ pHeap = malloc( nHeap ); if( pHeap==0 ) fatal_error("cannot allocate %d-byte heap\n", nHeap); rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap); if( rc ) fatal_error("heap configuration failed: %d\n", rc); } if( doPCache ){ |
︙ |