Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Small performance optimization in pcache1. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ffd437da9541f8a2792e3e07c0a43f38 |
User & Date: | drh 2017-08-30 04:44:59.152 |
Context
2017-08-30
| ||
13:21 | Remove unnecessary "__declspec(dllexport)" qualifiers from generated file shell.c. (check-in: bcc20be5b2 user: dan tags: trunk) | |
04:44 | Small performance optimization in pcache1. (check-in: ffd437da95 user: drh tags: trunk) | |
2017-08-29
| ||
20:21 | Faster memory allocation from lookaside by not trying to keep track of the number of outstanding allocations, and rather computing that value only when requested. (check-in: a06263f1ef user: drh tags: trunk) | |
Changes
Changes to src/pcache1.c.
︙ | |||
133 134 135 136 137 138 139 | 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 | - + - + + + | ** SQLITE_MUTEX_STATIC_LRU. */ struct PGroup { sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ unsigned int nMaxPage; /* Sum of nMax for purgeable caches */ unsigned int nMinPage; /* Sum of nMin for purgeable caches */ unsigned int mxPinned; /* nMaxpage + 10 - nMinPage */ |
︙ | |||
439 440 441 442 443 444 445 | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | - + - - - + - - | #endif if( pPg==0 ) return 0; p->page.pBuf = pPg; p->page.pExtra = &p[1]; p->isBulkLocal = 0; p->isAnchor = 0; } |
︙ | |||
604 605 606 607 608 609 610 | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | - + | ** If there are currently more than nMaxPage pages allocated, try ** to recycle pages to reduce the number allocated to nMaxPage. */ static void pcache1EnforceMaxPage(PCache1 *pCache){ PGroup *pGroup = pCache->pGroup; PgHdr1 *p; assert( sqlite3_mutex_held(pGroup->mutex) ); |
︙ | |||
775 776 777 778 779 780 781 782 783 784 785 786 787 788 | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | + + + + | pCache->bPurgeable = (bPurgeable ? 1 : 0); pcache1EnterMutex(pGroup); pcache1ResizeHash(pCache); if( bPurgeable ){ pCache->nMin = 10; pGroup->nMinPage += pCache->nMin; pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pCache->pnPurgeable = &pGroup->nPurgeable; }else{ static unsigned int dummyCurrentPage; pCache->pnPurgeable = &dummyCurrentPage; } pcache1LeaveMutex(pGroup); if( pCache->nHash==0 ){ pcache1Destroy((sqlite3_pcache*)pCache); pCache = 0; } } |
︙ | |||
884 885 886 887 888 889 890 | 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | - + | pcache1RemoveFromHash(pPage, 0); pcache1PinPage(pPage); pOther = pPage->pCache; if( pOther->szAlloc != pCache->szAlloc ){ pcache1FreePage(pPage); pPage = 0; }else{ |
︙ | |||
1065 1066 1067 1068 1069 1070 1071 | 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | - + | /* It is an error to call this function if the page is already ** part of the PGroup LRU list. */ assert( pPage->pLruPrev==0 && pPage->pLruNext==0 ); assert( PAGE_IS_PINNED(pPage) ); |
︙ | |||
1244 1245 1246 1247 1248 1249 1250 | 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | - + | ){ PgHdr1 *p; int nRecyclable = 0; for(p=pcache1.grp.lru.pLruNext; p && !p->isAnchor; p=p->pLruNext){ assert( PAGE_IS_UNPINNED(p) ); nRecyclable++; } |