]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the new PGHDR_CLEAN bit to PgHdr.flags in pcache.c. This bit is always
authordrh <drh@noemail.net>
Mon, 29 Jun 2015 04:21:15 +0000 (04:21 +0000)
committerdrh <drh@noemail.net>
Mon, 29 Jun 2015 04:21:15 +0000 (04:21 +0000)
the opposite of PGHDR_DIRTY.  Use the extra bit to avoid a comparison
for a small performance boost.

FossilOrigin-Name: 8619fc346d9a5a66a3c4566b4cc032b6b6bf73fd

manifest
manifest.uuid
src/pcache.c
src/pcache.h

index 36bf514e3088c2e39c0db54398f0f373ee9216a3..14e35070b6a90ec76cc9cb910de98dfed53d0ceb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Very\ssmall\ssize\sreduction\sand\sperformance\sincrease\sin\ssqlite3BitvecTest().
-D 2015-06-29T03:28:43.213
+C Add\sthe\snew\sPGHDR_CLEAN\sbit\sto\sPgHdr.flags\sin\spcache.c.\s\sThis\sbit\sis\salways\nthe\sopposite\sof\sPGHDR_DIRTY.\s\sUse\sthe\sextra\sbit\sto\savoid\sa\scomparison\nfor\sa\ssmall\sperformance\sboost.
+D 2015-06-29T04:21:15.041
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -317,8 +317,8 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
 F src/pager.c db79b64a5498e2b3a72f0f6bc74faebe48da3e95
 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
 F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
-F src/pcache.c d8b19632706dd6b81b03d0c5fd1e6bab8c13d0b9
-F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8
+F src/pcache.c 994f15b465337a079feb04aac34c199dbc610247
+F src/pcache.h 445374bcf296515fb970c8bbf47c36222196d197
 F src/pcache1.c 9ec20f98f50ed7415019303ae9bd3745d4b7bd9b
 F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7
 F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc
@@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 18115164e12509ec21f34598089a7f1310048819
-R 01e6ba6910c7ae6426ef3c4845c78ace
+P 9b3a7281bd45994edf813a687e4b7a0761697929
+R 07d5c4c2284ae7b5a16a8d841b25dd0d
 U drh
-Z 0a8f5dc054956bcb3a50cf01c1349d73
+Z fa5a6a0b1c08c7af0b43f02924ea472a
index 137b2208028224af8d2fa5461db4b1ff81017c3b..1562298e0b17380ecef9dc69115d4c6b516eaf0b 100644 (file)
@@ -1 +1 @@
-9b3a7281bd45994edf813a687e4b7a0761697929
\ No newline at end of file
+8619fc346d9a5a66a3c4566b4cc032b6b6bf73fd
\ No newline at end of file
index d1b3f22a113d88082e1c868106876f6424f072ac..220f0bf5236548090bb7924a794df6ecf7d5c626 100644 (file)
@@ -328,6 +328,7 @@ static SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit(
   memset(pPgHdr->pExtra, 0, pCache->szExtra);
   pPgHdr->pCache = pCache;
   pPgHdr->pgno = pgno;
+  pPgHdr->flags = PGHDR_CLEAN;
   return sqlite3PcacheFetchFinish(pCache,pgno,pPage);
 }
 
@@ -366,7 +367,7 @@ void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){
   p->nRef--;
   if( p->nRef==0 ){
     p->pCache->nRef--;
-    if( (p->flags&PGHDR_DIRTY)==0 ){
+    if( p->flags&PGHDR_CLEAN ){
       pcacheUnpin(p);
     }else if( p->pDirtyPrev!=0 ){
       /* Move the page to the head of the dirty list. */
@@ -402,11 +403,14 @@ void sqlite3PcacheDrop(PgHdr *p){
 ** make it so.
 */
 void sqlite3PcacheMakeDirty(PgHdr *p){
-  p->flags &= ~PGHDR_DONT_WRITE;
   assert( p->nRef>0 );
-  if( 0==(p->flags & PGHDR_DIRTY) ){
-    p->flags |= PGHDR_DIRTY;
-    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);
+  if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){
+    p->flags &= ~PGHDR_DONT_WRITE;
+    if( p->flags & PGHDR_CLEAN ){
+      p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);
+      assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );
+      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);
+    }
   }
 }
 
@@ -416,8 +420,10 @@ void sqlite3PcacheMakeDirty(PgHdr *p){
 */
 void sqlite3PcacheMakeClean(PgHdr *p){
   if( (p->flags & PGHDR_DIRTY) ){
+    assert( (p->flags & PGHDR_CLEAN)==0 );
     pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);
     p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC);
+    p->flags |= PGHDR_CLEAN;
     if( p->nRef==0 ){
       pcacheUnpin(p);
     }
index 9ed62a88ff570b8f4a91f7d95d856a6ccb1df06a..14053c06f35940238b58af7f28cc64056f843010 100644 (file)
@@ -46,6 +46,7 @@ struct PgHdr {
 };
 
 /* Bit values for PgHdr.flags */
+#define PGHDR_CLEAN             0x001  /* Page is unchanged */
 #define PGHDR_DIRTY             0x002  /* Page has changed */
 #define PGHDR_NEED_SYNC         0x004  /* Fsync the rollback journal before
                                        ** writing this page to the database */