Lines Matching refs:pCache

8820   PCache *pCache;                /* Cache that owns this page */  member
8909 SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));
35204 sqlite3_pcache *pCache; /* Pluggable cache module */
35230 static int pcacheCheckSynced(PCache *pCache){
35232 for(p=pCache->pDirtyTail; p!=pCache->pSynced; p=p->pDirtyPrev){
35243 PCache *p = pPage->pCache;
35280 PCache *p = pPage->pCache;
35304 PCache *pCache = p->pCache;
35305 if( pCache->bPurgeable ){
35307 pCache->pPage1 = 0;
35309 sqlite3GlobalConfig.pcache.xUnpin(pCache->pCache, p, 0);
35366 SQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
35367 assert( pCache->nRef==0 && pCache->pDirty==0 );
35368 if( pCache->pCache ){
35369 sqlite3GlobalConfig.pcache.xDestroy(pCache->pCache);
35370 pCache->pCache = 0;
35371 pCache->pPage1 = 0;
35373 pCache->szPage = szPage;
35380 PCache *pCache, /* Obtain the page from this cache */
35388 assert( pCache!=0 );
35395 if( !pCache->pCache && createFlag ){
35398 nByte = pCache->szPage + pCache->szExtra + sizeof(PgHdr);
35399 p = sqlite3GlobalConfig.pcache.xCreate(nByte, pCache->bPurgeable);
35403 sqlite3GlobalConfig.pcache.xCachesize(p, pCache->nMax);
35404 pCache->pCache = p;
35407 eCreate = createFlag * (1 + (!pCache->bPurgeable || !pCache->pDirty));
35408 if( pCache->pCache ){
35409 pPage = sqlite3GlobalConfig.pcache.xFetch(pCache->pCache, pgno, eCreate);
35420 expensive_assert( pcacheCheckSynced(pCache) );
35421 for(pPg=pCache->pSynced;
35425 pCache->pSynced = pPg;
35427 for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);
35435 sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),
35436 pCache->nMax);
35438 rc = pCache->xStress(pCache->pStress, pPg);
35444 pPage = sqlite3GlobalConfig.pcache.xFetch(pCache->pCache, pgno, 2);
35451 pPage->pExtra = (void*)&((char *)pPage->pData)[pCache->szPage];
35452 memset(pPage->pExtra, 0, pCache->szExtra);
35453 pPage->pCache = pCache;
35456 assert( pPage->pCache==pCache );
35459 assert( pPage->pExtra==(void *)&((char *)&pPage[1])[pCache->szPage] );
35462 pCache->nRef++;
35466 pCache->pPage1 = pPage;
35481 PCache *pCache = p->pCache;
35482 pCache->nRef--;
35507 PCache *pCache;
35512 pCache = p->pCache;
35513 pCache->nRef--;
35515 pCache->pPage1 = 0;
35517 sqlite3GlobalConfig.pcache.xUnpin(pCache->pCache, p, 1);
35550 SQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache *pCache){
35552 while( (p = pCache->pDirty)!=0 ){
35560 SQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *pCache){
35562 for(p=pCache->pDirty; p; p=p->pDirtyNext){
35565 pCache->pSynced = pCache->pDirtyTail;
35572 PCache *pCache = p->pCache;
35575 sqlite3GlobalConfig.pcache.xRekey(pCache->pCache, p, p->pgno, newPgno);
35592 SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
35593 if( pCache->pCache ){
35596 for(p=pCache->pDirty; p; p=pNext){
35608 if( pgno==0 && pCache->pPage1 ){
35609 memset(pCache->pPage1->pData, 0, pCache->szPage);
35612 sqlite3GlobalConfig.pcache.xTruncate(pCache->pCache, pgno+1);
35619 SQLITE_PRIVATE void sqlite3PcacheClose(PCache *pCache){
35620 if( pCache->pCache ){
35621 sqlite3GlobalConfig.pcache.xDestroy(pCache->pCache);
35628 SQLITE_PRIVATE void sqlite3PcacheClear(PCache *pCache){
35629 sqlite3PcacheTruncate(pCache, 0);
35705 SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){
35707 for(p=pCache->pDirty; p; p=p->pDirtyNext){
35710 return pcacheSortDirtyList(pCache->pDirty);
35716 SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){
35717 return pCache->nRef;
35730 SQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){
35732 if( pCache->pCache ){
35733 nPage = sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache);
35742 SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){
35743 return pCache->nMax;
35750 SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){
35751 pCache->nMax = mxPage;
35752 if( pCache->pCache ){
35753 sqlite3GlobalConfig.pcache.xCachesize(pCache->pCache, mxPage);
35763 SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){
35765 for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){
35931 PCache1 *pCache; /* Cache that currently owns this page */
35990 #define PGHDR1_TO_PAGE(p) (void*)(((char*)p) - p->pCache->szPage)
35997 #define PAGE_SET_BLOCKPTR(pCache, pPg, pBlock) \
35998 ( *(PGroupBlock **)&(((u8*)pPg)[sizeof(PgHdr1) + pCache->szPage]) = pBlock )
36000 #define PAGE_GET_BLOCKPTR(pCache, pPg) \
36001 ( *(PGroupBlock **)&(((u8*)pPg)[sizeof(PgHdr1) + pCache->szPage]) )
36164 static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
36165 int nByte = sizeof(PgHdr1) + pCache->szPage;
36170 PGroup *pGroup = pCache->pGroup;
36212 pcache1LeaveMutex(pCache->pGroup);
36215 pcache1EnterMutex(pCache->pGroup);
36243 PAGE_SET_BLOCKPTR(pCache, pPg, pBlock);
36257 p = PAGE_TO_PGHDR1(pCache, pPg);
36258 if( pCache->bPurgeable ){
36259 pCache->pGroup->nCurrentPage++;
36265 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
36266 pcache1LeaveMutex(pCache->pGroup);
36268 pcache1EnterMutex(pCache->pGroup);
36270 p = PAGE_TO_PGHDR1(pCache, pPg);
36271 if( pCache->bPurgeable ){
36272 pCache->pGroup->nCurrentPage++;
36290 PCache1 *pCache = p->pCache;
36294 PGroupBlock *pBlock = PAGE_GET_BLOCKPTR(pCache, pPg);
36319 PGroup *pGroup = p->pCache->pGroup;
36331 assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) );
36334 if( pCache->bPurgeable ){
36335 pCache->pGroup->nCurrentPage--;
36373 static int pcache1UnderMemoryPressure(PCache1 *pCache){
36374 if( pcache1.nSlot && pCache->szPage<=pcache1.szSlot ){
36437 PCache1 *pCache;
36441 pCache = pPage->pCache;
36442 pGroup = pCache->pGroup;
36459 pPage->pCache->nRecyclable--;
36472 PCache1 *pCache = pPage->pCache;
36475 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
36476 h = pPage->iKey % pCache->nHash;
36477 for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext);
36480 pCache->nPage--;
36491 assert( p->pCache->pGroup==pGroup );
36506 PCache1 *pCache, /* The cache to truncate */
36511 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
36512 for(h=0; h<pCache->nHash; h++){
36513 PgHdr1 **pp = &pCache->apHash[h];
36517 pCache->nPage--;
36527 assert( pCache->nPage==nPage );
36566 PCache1 *pCache; /* The newly created page cache */
36589 pCache = (PCache1 *)sqlite3_malloc(sz);
36590 if( pCache ){
36591 memset(pCache, 0, sz);
36593 pGroup = (PGroup*)&pCache[1];
36598 pCache->pGroup = pGroup;
36599 pCache->szPage = szPage;
36600 pCache->bPurgeable = (bPurgeable ? 1 : 0);
36602 pCache->nMin = 10;
36604 pGroup->nMinPage += pCache->nMin;
36609 return (sqlite3_pcache *)pCache;
36618 PCache1 *pCache = (PCache1 *)p;
36619 if( pCache->bPurgeable ){
36620 PGroup *pGroup = pCache->pGroup;
36622 pGroup->nMaxPage += (nMax - pCache->nMax);
36624 pCache->nMax = nMax;
36625 pCache->n90pct = pCache->nMax*9/10;
36636 PCache1 *pCache = (PCache1*)p;
36637 pcache1EnterMutex(pCache->pGroup);
36638 n = pCache->nPage;
36639 pcache1LeaveMutex(pCache->pGroup);
36699 PCache1 *pCache = (PCache1 *)p;
36703 assert( pCache->bPurgeable || createFlag!=1 );
36704 assert( pCache->bPurgeable || pCache->nMin==0 );
36705 assert( pCache->bPurgeable==0 || pCache->nMin==10 );
36706 assert( pCache->nMin==0 || pCache->bPurgeable );
36707 pcache1EnterMutex(pGroup = pCache->pGroup);
36710 if( pCache->nHash>0 ){
36711 unsigned int h = iKey % pCache->nHash;
36712 for(pPage=pCache->apHash[h]; pPage&&pPage->iKey!=iKey; pPage=pPage->pNext);
36729 pGroup = pCache->pGroup;
36734 nPinned = pCache->nPage - pCache->nRecyclable;
36737 assert( pCache->n90pct == pCache->nMax*9/10 );
36740 || nPinned>=(int)pCache->n90pct
36741 || pcache1UnderMemoryPressure(pCache)
36746 if( pCache->nPage>=pCache->nHash && pcache1ResizeHash(pCache) ){
36751 if( pCache->bPurgeable && pGroup->pLruTail && (
36752 (pCache->nPage+1>=pCache->nMax)
36754 || pcache1UnderMemoryPressure(pCache)
36760 if( (pOtherCache = pPage->pCache)->szPage!=pCache->szPage ){
36765 (pOtherCache->bPurgeable - pCache->bPurgeable);
36774 pPage = pcache1AllocPage(pCache);
36779 unsigned int h = iKey % pCache->nHash;
36780 pCache->nPage++;
36782 pPage->pNext = pCache->apHash[h];
36783 pPage->pCache = pCache;
36787 pCache->apHash[h] = pPage;
36791 if( pPage && iKey>pCache->iMaxKey ){
36792 pCache->iMaxKey = iKey;
36805 PCache1 *pCache = (PCache1 *)p;
36806 PgHdr1 *pPage = PAGE_TO_PGHDR1(pCache, pPg);
36807 PGroup *pGroup = pCache->pGroup;
36809 assert( pPage->pCache==pCache );
36831 pCache->nRecyclable++;
36834 pcache1LeaveMutex(pCache->pGroup);
36846 PCache1 *pCache = (PCache1 *)p;
36847 PgHdr1 *pPage = PAGE_TO_PGHDR1(pCache, pPg);
36851 assert( pPage->pCache==pCache );
36853 pcache1EnterMutex(pCache->pGroup);
36855 h = iOld%pCache->nHash;
36856 pp = &pCache->apHash[h];
36862 h = iNew%pCache->nHash;
36864 pPage->pNext = pCache->apHash[h];
36865 pCache->apHash[h] = pPage;
36866 if( iNew>pCache->iMaxKey ){
36867 pCache->iMaxKey = iNew;
36870 pcache1LeaveMutex(pCache->pGroup);
36881 PCache1 *pCache = (PCache1 *)p;
36882 pcache1EnterMutex(pCache->pGroup);
36883 if( iLimit<=pCache->iMaxKey ){
36884 pcache1TruncateUnsafe(pCache, iLimit);
36885 pCache->iMaxKey = iLimit-1;
36887 pcache1LeaveMutex(pCache->pGroup);
36896 PCache1 *pCache = (PCache1 *)p;
36897 PGroup *pGroup = pCache->pGroup;
36898 assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
36900 pcache1TruncateUnsafe(pCache, 0);
36901 pGroup->nMaxPage -= pCache->nMax;
36902 pGroup->nMinPage -= pCache->nMin;
36906 sqlite3_free(pCache->apHash);
36907 sqlite3_free(pCache);