]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Pick up a small performance increase by eliminating the pcacheRef() function. (CVS...
authordanielk1977 <danielk1977@noemail.net>
Mon, 25 Aug 2008 14:49:42 +0000 (14:49 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 25 Aug 2008 14:49:42 +0000 (14:49 +0000)
FossilOrigin-Name: e3840fbf0adf824941a4b9b3cac3a869f195d6f8

manifest
manifest.uuid
src/pcache.c

index 42cf73f8c491b2f1378be4b43a0617a36decd0e2..375d2ce900ed810d1b2da7a97fba34614f889c73 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Additional\scoverage\stesting\sin\sthe\snew\sname\sresolver\smodule.\s(CVS\s5608)
-D 2008-08-25T12:14:09
+C Pick\sup\sa\ssmall\sperformance\sincrease\sby\seliminating\sthe\spcacheRef()\sfunction.\s(CVS\s5609)
+D 2008-08-25T14:49:42
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 689e14735f862a5553bceef206d8c13e29504e44
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -138,7 +138,7 @@ F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
 F src/pager.c a175ce0a026177ca24b48b2944670404bcec90d8
 F src/pager.h 3b9c138d2e744b9d6e61d4c2742301e3bf464864
 F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
-F src/pcache.c 67c402c23d90ac8cea02c917f18245ade6a44e1d
+F src/pcache.c 4883f3714503242057643a5dddbc74065def5157
 F src/pcache.h f03fc3b8241da092bd929ba0eec15e84d9d2cca0
 F src/pragma.c f5b271b090af7fcedd308d7c5807a5503f7a853d
 F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510
@@ -623,7 +623,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 635933b1cae6c43656260555089952e2925c3292
-R 425df6baa72dc44cb2b3af4ba0d5d71f
-U drh
-Z 402656fa4c5ab25e1bc6c1040a95ee16
+P 0d61960afd35721d6d07acd75288c20d2cd6fda1
+R a45c0ea79cdddeaf5b79e95fe71c1625
+U danielk1977
+Z d37cbd289bc865902ff5dd4aff605824
index 3ee9d6acee652f214547574fb36ad80910f0a36d..ff14a6714abdf80e0871bdf92f37fa1cffbc2494 100644 (file)
@@ -1 +1 @@
-0d61960afd35721d6d07acd75288c20d2cd6fda1
\ No newline at end of file
+e3840fbf0adf824941a4b9b3cac3a869f195d6f8
\ No newline at end of file
index b26bc58b1f812256d4c0f0bdbae5bd2599b78998..fd0f6ee20c013d9e761cd4309bee18034178b788 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file implements that page cache.
 **
-** @(#) $Id: pcache.c,v 1.12 2008/08/25 07:12:29 danielk1977 Exp $
+** @(#) $Id: pcache.c,v 1.13 2008/08/25 14:49:42 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -111,26 +111,6 @@ static struct PCacheGlobal {
 #define pcacheEnterGlobal() sqlite3_mutex_enter(pcache.mutex_lru)
 #define pcacheExitGlobal()  sqlite3_mutex_leave(pcache.mutex_lru)
 
-/*
-** Increment the reference count on both page p and its cache by n.
-*/
-static void pcacheRef(PgHdr *p, int n){
-  /* This next block assert()s that the number of references to the 
-  ** PCache is the sum of the number of references to all pages in
-  ** the PCache. This is a bit expensive to leave turned on all the 
-  ** time, even in debugging builds.
-  */
-#if 0
-  PgHdr *pHdr;
-  int nRef = 0;
-  for(pHdr=p->pCache->pClean; pHdr; pHdr=pHdr->pNext) nRef += pHdr->nRef;
-  for(pHdr=p->pCache->pDirty; pHdr; pHdr=pHdr->pNext) nRef += pHdr->nRef;
-  assert( p->pCache->nRef==nRef );
-#endif
-  p->nRef += n;
-  p->pCache->nRef += n;
-}
-
 /********************************** Linked List Management ********************/
 
 #ifndef NDEBUG
@@ -658,7 +638,9 @@ int sqlite3PcacheFetch(
           pcacheRemoveFromLruList(pPage);
           pcacheExitGlobal();
         }
-        pcacheRef(pPage, 1);
+        if( (pPage->nRef++)==0 ){
+          pCache->nRef++;
+        }
         *ppPage = pPage;
         return SQLITE_OK;
       }
@@ -682,10 +664,10 @@ int sqlite3PcacheFetch(
     pPage->pPager = 0;
     pPage->flags = 0;
     pPage->pDirty = 0;
-    pPage->nRef = 0;
     pPage->pgno = pgno;
     pPage->pCache = pCache;
-    pcacheRef(pPage, 1);
+    pPage->nRef = 1;
+    pCache->nRef++;
     pcacheAddToList(&pCache->pClean, pPage);
     pcacheAddToHash(pPage);
   }else{
@@ -702,22 +684,25 @@ int sqlite3PcacheFetch(
 void sqlite3PcacheRelease(PgHdr *p){
   assert( p->nRef>0 );
   assert( p->pCache->iInUseDB || p->pCache->iInUseMM );
-  pcacheRef(p, -1);
-  if( p->nRef!=0 ) return;
-  if( p->pCache->xDestroy ){
-    p->pCache->xDestroy(p);
-  }
+  p->nRef--;
+  if( p->nRef==0 ){
+    PCache *pCache = p->pCache;
+    pCache->nRef--;
+    if( p->pCache->xDestroy ){
+      p->pCache->xDestroy(p);
+    }
 #if 0
-  if( (p->flags & PGHDR_DIRTY)!=0 ) return;
+    if( (p->flags & PGHDR_DIRTY)!=0 ) return;
 #endif
-  pcacheEnterGlobal();
-  pcacheAddToLruList(p);
-  pcacheExitGlobal();
+    pcacheEnterGlobal();
+    pcacheAddToLruList(p);
+    pcacheExitGlobal();
+  }
 }
 
 void sqlite3PcacheRef(PgHdr *p){
-  assert(p->nRef>=0);
-  pcacheRef(p, 1);
+  assert(p->nRef>0);
+  p->nRef++;
 }
 
 /*