From: dan Date: Wed, 11 May 2016 15:41:15 +0000 (+0000) Subject: Remove some a small amount of redundant code related to PCache.pSynced from pcache.c. X-Git-Tag: version-3.13.0~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2ef900ade31284cbd710bf2fe2c4a88400eed6a;p=thirdparty%2Fsqlite.git Remove some a small amount of redundant code related to PCache.pSynced from pcache.c. FossilOrigin-Name: 9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 --- diff --git a/manifest b/manifest index a0a2ed640a..a51e55cb83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sreset\sthe\spage\scache\swhen\sa\srollback\sjournal\struncate\sfails,\sas\sdoing\nso\scan\scause\sloss\sof\sinformation\sfor\san\sin-memory\sTEMP\sfile. -D 2016-05-11T12:47:46.752 +C Remove\ssome\sa\ssmall\samount\sof\sredundant\scode\srelated\sto\sPCache.pSynced\sfrom\spcache.c. +D 2016-05-11T15:41:15.317 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 cb7a3990eabd895f6487c0856a7fec02b5e40faa F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6 +F src/pcache.c 4af980bc2a987cf81ddbe867d238c9ccdbaac95c 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 42fb6f1e99a6c31889819a0302679d598dc0ab1b -R 6af21f51682f416bafd722831c805292 -U drh -Z f092752ae332e4cfbb76f62bab02296e +P 345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 +R 410857f6cadf18a1818aed66391afc72 +U dan +Z b239392669bc1d86adff0f06ee03f5ae diff --git a/manifest.uuid b/manifest.uuid index 39ea1115d0..9b2b37fae9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 \ No newline at end of file +9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index 7505547c25..54b4044a01 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -15,6 +15,22 @@ /* ** A complete page cache is an instance of this structure. +** +** pDirty, pDirtyTail, pSynced: +** All dirty pages are linked into the doubly linked list using +** PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order +** such that p was added to the list more recently than p->pDirtyNext. +** PCache.pDirty points to the first (newest) element in the list and +** pDirtyTail to the last (oldest). +** +** The PCache.pSynced variable is used to optimize searching for a dirty +** page to eject from the cache mid-transaction. It is better to eject +** a page that does not require a journal sync than one that does. +** Therefore, pSynced is maintained to that it *almost* always points +** to either the oldest page in the pDirty/pDirtyTail list that has a +** clear PGHDR_NEED_SYNC flag or to a page that is older than this one +** (so that the right page to eject can be found by following pDirtyPrev +** pointers). */ struct PCache { PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */ @@ -66,11 +82,7 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ /* Update the PCache1.pSynced variable if necessary. */ if( p->pSynced==pPage ){ - PgHdr *pSynced = pPage->pDirtyPrev; - while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){ - pSynced = pSynced->pDirtyPrev; - } - p->pSynced = pSynced; + p->pSynced = pPage->pDirtyPrev; } if( pPage->pDirtyNext ){ @@ -296,7 +308,11 @@ int sqlite3PcacheFetchStress( ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC ** cleared), but if that is not possible settle for any other ** unreferenced dirty page. - */ + ** + ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC + ** flag is currently referenced, then the following may leave pSynced + ** set incorrectly (pointing to other than the LRU page with NEED_SYNC + ** cleared). This is Ok, as pSynced is just an optimization. */ for(pPg=pCache->pSynced; pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); pPg=pPg->pDirtyPrev