Add pcache tracing macros. Off by default. Requires changing an "#if 0"
and recompiling to enable. FossilOrigin-Name: d9313d19c75a62f558b3df6b15595b15bbfa0b62
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
C Add\sanother\stest\scase\sto\stemptable3.test.
|
||||
D 2016-05-10T20:16:43.237
|
||||
C Add\spcache\stracing\smacros.\s\sOff\sby\sdefault.\s\sRequires\schanging\san\s"#if\s0"\nand\srecompiling\sto\senable.
|
||||
D 2016-05-11T10:57:04.047
|
||||
F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd
|
||||
@@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
||||
F src/pager.c dd77be61e439d2bc8d5d4cb8c29595f3ff1c446c
|
||||
F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681
|
||||
F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e
|
||||
F src/pcache.c b3230ecfc7f797063fbe167f2845da363e8f07f8
|
||||
F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6
|
||||
F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9
|
||||
F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d
|
||||
F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84
|
||||
@@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 20cf8811caf705b482be100baecb3ef72aee2d5a
|
||||
R 3a9fed64484c9373e69d538aa10775ab
|
||||
U dan
|
||||
Z 7b172879dcc2b05a1f7487ac7eeeddea
|
||||
P 223640243efc52c14bb2bb540833a2a624eaa41a
|
||||
R 0792de46be2b6fbaa9f6c79c63b41f67
|
||||
U drh
|
||||
Z 0ddceb59c6efe2505feeee700b7e5172
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
223640243efc52c14bb2bb540833a2a624eaa41a
|
||||
d9313d19c75a62f558b3df6b15595b15bbfa0b62
|
||||
+27
-1
@@ -31,6 +31,16 @@ struct PCache {
|
||||
sqlite3_pcache *pCache; /* Pluggable cache module */
|
||||
};
|
||||
|
||||
/*
|
||||
** Debug tracing macros
|
||||
*/
|
||||
#if defined(SQLITE_DEBUG) && 0
|
||||
int sqlite3PcacheTrace = 1;
|
||||
# define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;}
|
||||
#else
|
||||
# define pcacheTrace(X)
|
||||
#endif
|
||||
|
||||
/********************************** Linked List Management ********************/
|
||||
|
||||
/* Allowed values for second argument to pcacheManageDirtyList() */
|
||||
@@ -47,6 +57,9 @@ struct PCache {
|
||||
static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){
|
||||
PCache *p = pPage->pCache;
|
||||
|
||||
pcacheTrace(("%p.DIRTYLIST.%s %d\n", p,
|
||||
addRemove==1 ? "REMOVE" : addRemove==2 ? "ADD" : "FRONT",
|
||||
pPage->pgno));
|
||||
if( addRemove & PCACHE_DIRTYLIST_REMOVE ){
|
||||
assert( pPage->pDirtyNext || pPage==p->pDirtyTail );
|
||||
assert( pPage->pDirtyPrev || pPage==p->pDirty );
|
||||
@@ -106,6 +119,7 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){
|
||||
*/
|
||||
static void pcacheUnpin(PgHdr *p){
|
||||
if( p->pCache->bPurgeable ){
|
||||
pcacheTrace(("%p.UNPIN %d\n", p->pCache, p->pgno));
|
||||
sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);
|
||||
}
|
||||
}
|
||||
@@ -176,6 +190,7 @@ int sqlite3PcacheOpen(
|
||||
p->pStress = pStress;
|
||||
p->szCache = 100;
|
||||
p->szSpill = 1;
|
||||
pcacheTrace(("%p.OPEN szPage %d bPurgeable %d\n",p,szPage,bPurgeable));
|
||||
return sqlite3PcacheSetPageSize(p, szPage);
|
||||
}
|
||||
|
||||
@@ -198,6 +213,7 @@ int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
|
||||
}
|
||||
pCache->pCache = pNew;
|
||||
pCache->szPage = szPage;
|
||||
pcacheTrace(("%p.PAGESIZE %d\n",pCache,szPage));
|
||||
}
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@@ -232,6 +248,7 @@ sqlite3_pcache_page *sqlite3PcacheFetch(
|
||||
int createFlag /* If true, create page if it does not exist already */
|
||||
){
|
||||
int eCreate;
|
||||
sqlite3_pcache_page *pRes;
|
||||
|
||||
assert( pCache!=0 );
|
||||
assert( pCache->pCache!=0 );
|
||||
@@ -249,7 +266,10 @@ sqlite3_pcache_page *sqlite3PcacheFetch(
|
||||
assert( eCreate==0 || eCreate==1 || eCreate==2 );
|
||||
assert( createFlag==0 || pCache->eCreate==eCreate );
|
||||
assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) );
|
||||
return sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);
|
||||
pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);
|
||||
pcacheTrace(("%p.FETCH %d%s (result: %p)\n",pCache,pgno,
|
||||
createFlag?" create":"",pRes));
|
||||
return pRes;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -294,6 +314,7 @@ int sqlite3PcacheFetchStress(
|
||||
sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),
|
||||
numberOfCachePages(pCache));
|
||||
#endif
|
||||
pcacheTrace(("%p.SPILL %d\n",pCache,pPg->pgno));
|
||||
rc = pCache->xStress(pCache->pStress, pPg);
|
||||
if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
|
||||
return rc;
|
||||
@@ -407,6 +428,7 @@ void sqlite3PcacheMakeDirty(PgHdr *p){
|
||||
p->flags &= ~PGHDR_DONT_WRITE;
|
||||
if( p->flags & PGHDR_CLEAN ){
|
||||
p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);
|
||||
pcacheTrace(("%p.DIRTY %d\n",p->pCache,p->pgno));
|
||||
assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );
|
||||
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);
|
||||
}
|
||||
@@ -423,6 +445,7 @@ void sqlite3PcacheMakeClean(PgHdr *p){
|
||||
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);
|
||||
p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE);
|
||||
p->flags |= PGHDR_CLEAN;
|
||||
pcacheTrace(("%p.CLEAN %d\n",p->pCache,p->pgno));
|
||||
if( p->nRef==0 ){
|
||||
pcacheUnpin(p);
|
||||
}
|
||||
@@ -468,6 +491,7 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){
|
||||
PCache *pCache = p->pCache;
|
||||
assert( p->nRef>0 );
|
||||
assert( newPgno>0 );
|
||||
pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno));
|
||||
sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);
|
||||
p->pgno = newPgno;
|
||||
if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){
|
||||
@@ -488,6 +512,7 @@ void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
|
||||
if( pCache->pCache ){
|
||||
PgHdr *p;
|
||||
PgHdr *pNext;
|
||||
pcacheTrace(("%p.TRUNCATE %d\n",pCache,pgno));
|
||||
for(p=pCache->pDirty; p; p=pNext){
|
||||
pNext = p->pDirtyNext;
|
||||
/* This routine never gets call with a positive pgno except right
|
||||
@@ -518,6 +543,7 @@ void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
|
||||
*/
|
||||
void sqlite3PcacheClose(PCache *pCache){
|
||||
assert( pCache->pCache!=0 );
|
||||
pcacheTrace(("%p.CLOSE\n",pCache));
|
||||
sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user