• Home
  • Raw
  • Download

Lines Matching refs:pCache

14491   PCache *pCache;                /* PRIVATE: Cache that owns this page */  member
14601 SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));
45231 sqlite3_pcache *pCache; /* Pluggable cache module */
45247 void pcacheDump(PCache *pCache){
45255 if( pCache->pCache==0 ) return;
45256 N = sqlite3PcachePagecount(pCache);
45259 pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0);
45267 sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0);
45287 PCache *pCache;
45290 pCache = pPg->pCache;
45291 assert( pCache!=0 ); /* Every page has an associated PCache */
45294 assert( pCache->pDirty!=pPg ); /* CLEAN pages not on dirty list */
45295 assert( pCache->pDirtyTail!=pPg );
45337 PCache *p = pPage->pCache;
45407 if( p->pCache->bPurgeable ){
45408 pcacheTrace(("%p.UNPIN %d\n", p->pCache, p->pgno));
45409 sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);
45410 pcacheDump(p->pCache);
45495 SQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
45496 assert( pCache->nRefSum==0 && pCache->pDirty==0 );
45497 if( pCache->szPage ){
45500 szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)),
45501 pCache->bPurgeable
45504 sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache));
45505 if( pCache->pCache ){
45506 sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);
45508 pCache->pCache = pNew;
45509 pCache->szPage = szPage;
45510 pcacheTrace(("%p.PAGESIZE %d\n",pCache,szPage));
45540 PCache *pCache, /* Obtain the page from this cache */
45547 assert( pCache!=0 );
45548 assert( pCache->pCache!=0 );
45550 assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );
45559 eCreate = createFlag & pCache->eCreate;
45561 assert( createFlag==0 || pCache->eCreate==eCreate );
45562 assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) );
45563 pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);
45564 pcacheTrace(("%p.FETCH %d%s (result: %p)\n",pCache,pgno,
45581 PCache *pCache, /* Obtain the page from this cache */
45586 if( pCache->eCreate==2 ) return 0;
45588 if( sqlite3PcachePagecount(pCache)>pCache->szSpill ){
45598 for(pPg=pCache->pSynced;
45602 pCache->pSynced = pPg;
45604 for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);
45612 sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),
45613 numberOfCachePages(pCache));
45615 pcacheTrace(("%p.SPILL %d\n",pCache,pPg->pgno));
45616 rc = pCache->xStress(pCache->pStress, pPg);
45617 pcacheDump(pCache);
45623 *ppPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2);
45637 PCache *pCache, /* Obtain the page from this cache */
45650 pPgHdr->pCache = pCache;
45653 return sqlite3PcacheFetchFinish(pCache,pgno,pPage);
45663 PCache *pCache, /* Obtain the page from this cache */
45673 return pcacheFetchFinishWithInit(pCache, pgno, pPage);
45675 pCache->nRefSum++;
45687 p->pCache->nRefSum--;
45704 p->pCache->nRefSum++;
45718 p->pCache->nRefSum--;
45719 sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1);
45733 pcacheTrace(("%p.DIRTY %d\n",p->pCache,p->pgno));
45752 pcacheTrace(("%p.CLEAN %d\n",p->pCache,p->pgno));
45762 SQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache *pCache){
45764 pcacheTrace(("%p.CLEAN-ALL\n",pCache));
45765 while( (p = pCache->pDirty)!=0 ){
45773 SQLITE_PRIVATE void sqlite3PcacheClearWritable(PCache *pCache){
45775 pcacheTrace(("%p.CLEAR-WRITEABLE\n",pCache));
45776 for(p=pCache->pDirty; p; p=p->pDirtyNext){
45779 pCache->pSynced = pCache->pDirtyTail;
45785 SQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *pCache){
45787 for(p=pCache->pDirty; p; p=p->pDirtyNext){
45790 pCache->pSynced = pCache->pDirtyTail;
45797 PCache *pCache = p->pCache;
45801 pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno));
45802 sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);
45818 SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
45819 if( pCache->pCache ){
45822 pcacheTrace(("%p.TRUNCATE %d\n",pCache,pgno));
45823 for(p=pCache->pDirty; p; p=pNext){
45835 if( pgno==0 && pCache->nRefSum ){
45837 pPage1 = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache,1,0);
45840 memset(pPage1->pBuf, 0, pCache->szPage);
45844 sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);
45851 SQLITE_PRIVATE void sqlite3PcacheClose(PCache *pCache){
45852 assert( pCache->pCache!=0 );
45853 pcacheTrace(("%p.CLOSE\n",pCache));
45854 sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);
45860 SQLITE_PRIVATE void sqlite3PcacheClear(PCache *pCache){
45861 sqlite3PcacheTruncate(pCache, 0);
45940 SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){
45942 for(p=pCache->pDirty; p; p=p->pDirtyNext){
45945 return pcacheSortDirtyList(pCache->pDirty);
45954 SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){
45955 return pCache->nRefSum;
45968 SQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){
45969 assert( pCache->pCache!=0 );
45970 return sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache);
45977 SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){
45978 return numberOfCachePages(pCache);
45985 SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){
45986 assert( pCache->pCache!=0 );
45987 pCache->szCache = mxPage;
45988 sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,
45989 numberOfCachePages(pCache));
45999 assert( p->pCache!=0 );
46014 SQLITE_PRIVATE void sqlite3PcacheShrink(PCache *pCache){
46015 assert( pCache->pCache!=0 );
46016 sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);
46029 SQLITE_PRIVATE int sqlite3PCachePercentDirty(PCache *pCache){
46032 int nCache = numberOfCachePages(pCache);
46033 for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext) nDirty++;
46043 SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){
46045 for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){
46154 PCache1 *pCache; /* Cache that currently owns this page */
46329 static int pcache1InitBulk(PCache1 *pCache){
46334 if( pCache->nMax<3 ) return 0;
46337 szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;
46341 if( szBulk > pCache->szAlloc*(i64)pCache->nMax ){
46342 szBulk = pCache->szAlloc*(i64)pCache->nMax;
46344 zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
46347 int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
46349 PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];
46354 pX->pNext = pCache->pFree;
46355 pCache->pFree = pX;
46356 zBulk += pCache->szAlloc;
46359 return pCache->pFree!=0;
46459 static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){
46463 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
46464 if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
46465 p = pCache->pFree;
46466 pCache->pFree = p->pNext;
46474 assert( pCache->pGroup==&pcache1.grp );
46475 pcache1LeaveMutex(pCache->pGroup);
46479 pPg = pcache1Alloc(pCache->szPage);
46480 p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra);
46487 pPg = pcache1Alloc(pCache->szAlloc);
46488 p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
46492 pcache1EnterMutex(pCache->pGroup);
46500 (*pCache->pnPurgeable)++;
46508 PCache1 *pCache;
46510 pCache = p->pCache;
46511 assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) );
46513 p->pNext = pCache->pFree;
46514 pCache->pFree = p;
46521 (*pCache->pnPurgeable)--;
46557 static int pcache1UnderMemoryPressure(PCache1 *pCache){
46558 if( pcache1.nSlot && (pCache->szPage+pCache->szExtra)<=pcache1.szSlot ){
46620 assert( sqlite3_mutex_held(pPage->pCache->pGroup->mutex) );
46626 assert( pPage->pCache->pGroup->lru.isAnchor==1 );
46627 pPage->pCache->nRecyclable--;
46641 PCache1 *pCache = pPage->pCache;
46644 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
46645 h = pPage->iKey % pCache->nHash;
46646 for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext);
46649 pCache->nPage--;
46657 static void pcache1EnforceMaxPage(PCache1 *pCache){
46658 PGroup *pGroup = pCache->pGroup;
46664 assert( p->pCache->pGroup==pGroup );
46669 if( pCache->nPage==0 && pCache->pBulk ){
46670 sqlite3_free(pCache->pBulk);
46671 pCache->pBulk = pCache->pFree = 0;
46683 PCache1 *pCache, /* The cache to truncate */
46688 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
46689 assert( pCache->iMaxKey >= iLimit );
46690 assert( pCache->nHash > 0 );
46691 if( pCache->iMaxKey - iLimit < pCache->nHash ){
46696 h = iLimit % pCache->nHash;
46697 iStop = pCache->iMaxKey % pCache->nHash;
46702 h = pCache->nHash/2;
46708 assert( h<pCache->nHash );
46709 pp = &pCache->apHash[h];
46712 pCache->nPage--;
46722 h = (h+1) % pCache->nHash;
46724 assert( nPage<0 || pCache->nPage==(unsigned)nPage );
46801 PCache1 *pCache; /* The newly created page cache */
46809 pCache = (PCache1 *)sqlite3MallocZero(sz);
46810 if( pCache ){
46812 pGroup = (PGroup*)&pCache[1];
46821 pCache->pGroup = pGroup;
46822 pCache->szPage = szPage;
46823 pCache->szExtra = szExtra;
46824 pCache->szAlloc = szPage + szExtra + ROUND8(sizeof(PgHdr1));
46825 pCache->bPurgeable = (bPurgeable ? 1 : 0);
46827 pcache1ResizeHash(pCache);
46829 pCache->nMin = 10;
46830 pGroup->nMinPage += pCache->nMin;
46832 pCache->pnPurgeable = &pGroup->nPurgeable;
46835 pCache->pnPurgeable = &dummyCurrentPage;
46838 if( pCache->nHash==0 ){
46839 pcache1Destroy((sqlite3_pcache*)pCache);
46840 pCache = 0;
46843 return (sqlite3_pcache *)pCache;
46852 PCache1 *pCache = (PCache1 *)p;
46853 if( pCache->bPurgeable ){
46854 PGroup *pGroup = pCache->pGroup;
46856 pGroup->nMaxPage += (nMax - pCache->nMax);
46858 pCache->nMax = nMax;
46859 pCache->n90pct = pCache->nMax*9/10;
46860 pcache1EnforceMaxPage(pCache);
46871 PCache1 *pCache = (PCache1*)p;
46872 if( pCache->bPurgeable ){
46873 PGroup *pGroup = pCache->pGroup;
46878 pcache1EnforceMaxPage(pCache);
46889 PCache1 *pCache = (PCache1*)p;
46890 pcache1EnterMutex(pCache->pGroup);
46891 n = pCache->nPage;
46892 pcache1LeaveMutex(pCache->pGroup);
46906 PCache1 *pCache,
46911 PGroup *pGroup = pCache->pGroup;
46915 assert( pCache->nPage >= pCache->nRecyclable );
46916 nPinned = pCache->nPage - pCache->nRecyclable;
46918 assert( pCache->n90pct == pCache->nMax*9/10 );
46921 || nPinned>=pCache->n90pct
46922 || (pcache1UnderMemoryPressure(pCache) && pCache->nRecyclable<nPinned)
46927 if( pCache->nPage>=pCache->nHash ) pcache1ResizeHash(pCache);
46928 assert( pCache->nHash>0 && pCache->apHash );
46931 if( pCache->bPurgeable
46933 && ((pCache->nPage+1>=pCache->nMax) || pcache1UnderMemoryPressure(pCache))
46940 pOther = pPage->pCache;
46941 if( pOther->szAlloc != pCache->szAlloc ){
46945 pGroup->nPurgeable -= (pOther->bPurgeable - pCache->bPurgeable);
46953 pPage = pcache1AllocPage(pCache, createFlag==1);
46957 unsigned int h = iKey % pCache->nHash;
46958 pCache->nPage++;
46960 pPage->pNext = pCache->apHash[h];
46961 pPage->pCache = pCache;
46965 pCache->apHash[h] = pPage;
46966 if( iKey>pCache->iMaxKey ){
46967 pCache->iMaxKey = iKey;
47037 PCache1 *pCache = (PCache1 *)p;
47041 pPage = pCache->apHash[iKey % pCache->nHash];
47056 return pcache1FetchStage2(pCache, iKey, createFlag);
47067 PCache1 *pCache = (PCache1 *)p;
47070 pcache1EnterMutex(pCache->pGroup);
47072 assert( pPage==0 || pCache->iMaxKey>=iKey );
47073 pcache1LeaveMutex(pCache->pGroup);
47083 PCache1 *pCache = (PCache1 *)p;
47087 assert( pCache->bPurgeable || createFlag!=1 );
47088 assert( pCache->bPurgeable || pCache->nMin==0 );
47089 assert( pCache->bPurgeable==0 || pCache->nMin==10 );
47090 assert( pCache->nMin==0 || pCache->bPurgeable );
47091 assert( pCache->nHash>0 );
47093 if( pCache->pGroup->mutex ){
47113 PCache1 *pCache = (PCache1 *)p;
47115 PGroup *pGroup = pCache->pGroup;
47117 assert( pPage->pCache==pCache );
47134 pCache->nRecyclable++;
47137 pcache1LeaveMutex(pCache->pGroup);
47149 PCache1 *pCache = (PCache1 *)p;
47154 assert( pPage->pCache==pCache );
47156 pcache1EnterMutex(pCache->pGroup);
47158 h = iOld%pCache->nHash;
47159 pp = &pCache->apHash[h];
47165 h = iNew%pCache->nHash;
47167 pPage->pNext = pCache->apHash[h];
47168 pCache->apHash[h] = pPage;
47169 if( iNew>pCache->iMaxKey ){
47170 pCache->iMaxKey = iNew;
47173 pcache1LeaveMutex(pCache->pGroup);
47184 PCache1 *pCache = (PCache1 *)p;
47185 pcache1EnterMutex(pCache->pGroup);
47186 if( iLimit<=pCache->iMaxKey ){
47187 pcache1TruncateUnsafe(pCache, iLimit);
47188 pCache->iMaxKey = iLimit-1;
47190 pcache1LeaveMutex(pCache->pGroup);
47199 PCache1 *pCache = (PCache1 *)p;
47200 PGroup *pGroup = pCache->pGroup;
47201 assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
47203 if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);
47204 assert( pGroup->nMaxPage >= pCache->nMax );
47205 pGroup->nMaxPage -= pCache->nMax;
47206 assert( pGroup->nMinPage >= pCache->nMin );
47207 pGroup->nMinPage -= pCache->nMin;
47209 pcache1EnforceMaxPage(pCache);
47211 sqlite3_free(pCache->pBulk);
47212 sqlite3_free(pCache->apHash);
47213 sqlite3_free(pCache);