1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Begin purging dirty pages from the cache once 90% of the cache is dirty (insteadof waiting until it is 100% dirty). This improves performance in some circumstances by effectively reserving 10% of the configured page-cache for frequently reused read-only pages. (CVS 6341)

FossilOrigin-Name: 823fe7f5551e121e211d1ede606a7ce7487ffe0d
This commit is contained in:
danielk1977
2009-03-05 14:59:39 +00:00
parent c427740b78
commit 6fa0fe13f0
4 changed files with 25 additions and 23 deletions

View File

@ -1,5 +1,5 @@
C Comment\sout\sa\srecently\sadded\sassert\sstatement\sthat\sis\sfailing.\s(CVS\s6340)
D 2009-03-05T14:53:18
C Begin\spurging\sdirty\spages\sfrom\sthe\scache\sonce\s90%\sof\sthe\scache\sis\sdirty\s(insteadof\swaiting\suntil\sit\sis\s100%\sdirty).\sThis\simproves\sperformance\sin\ssome\scircumstances\sby\seffectively\sreserving\s10%\sof\sthe\sconfigured\spage-cache\sfor\sfrequently\sreused\sread-only\spages.\s(CVS\s6341)
D 2009-03-05T14:59:40
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in d64baddbf55cdf33ff030e14da837324711a4ef7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -147,7 +147,7 @@ F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f
F src/parse.y c315b6f9bf6c7e7ec985481f81b6a45dba6c26d0
F src/pcache.c fcf7738c83c4d3e9d45836b2334c8a368cc41274
F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
F src/pcache1.c dabb8ab14827e090321f17150ce96fda172974e8
F src/pcache1.c f12518540ba776df3051215c4244e9cdc06b09cd
F src/pragma.c 22ed04836aab8ce134c53be1ca896f3ad20fabdb
F src/prepare.c 1a2d40c0c5fb9f244cf5e3aacc33abcc1e7b095a
F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f
@ -485,7 +485,7 @@ F test/pager2.test d4b7f6b70ff018b9995e622a32526b275f515042
F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
F test/pagesize.test 0d9ff3fedfce6e5ffe8fa7aca9b6d3433a2e843b
F test/pcache.test ccd18b4d2b432f44319a82b0367ed843ee18cebd
F test/pcache.test 70ad1d65cf73f6a0a7501e0236312eb214d93a55
F test/pcache2.test 46efd980a89f737847b99327bda19e08fe11e402
F test/permutations.test 2e777ae1eeb11b777b31aad929c4351464758441
F test/pragma.test a35b0be36542477183168cdb8b743f5c0d883c4d
@ -703,7 +703,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 68abcb278ced40c0d97af724dbd1b751a3becdc2
R 0b19691adcd1739892b0541fe5daf832
P d0b2015f1caf2fc60ec82bd8e760f7b61befa3b4
R 039bb14c767370b62d0edeb68de61ac0
U danielk1977
Z e314e181dfce2d061b5e2a985f7bf325
Z 7a03629d714ccf300df7a819fca83b05

View File

@ -1 +1 @@
d0b2015f1caf2fc60ec82bd8e760f7b61befa3b4
823fe7f5551e121e211d1ede606a7ce7487ffe0d

View File

@ -16,7 +16,7 @@
** If the default page cache implementation is overriden, then neither of
** these two features are available.
**
** @(#) $Id: pcache1.c,v 1.8 2009/01/23 16:45:01 danielk1977 Exp $
** @(#) $Id: pcache1.c,v 1.9 2009/03/05 14:59:40 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -516,7 +516,7 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){
nPinned = pCache->nPage - pCache->nRecyclable;
if( createFlag==1 && pCache->bPurgeable && (
nPinned>=(pcache1.nMaxPage+pCache->nMin-pcache1.nMinPage)
|| nPinned>=(pCache->nMax)
|| nPinned>=(pCache->nMax * 9 / 10)
)){
goto fetch_out;
}

View File

@ -11,7 +11,7 @@
#
# This file is focused on testing the pcache module.
#
# $Id: pcache.test,v 1.3 2009/01/07 15:33:46 drh Exp $
# $Id: pcache.test,v 1.4 2009/03/05 14:59:40 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -30,11 +30,11 @@ do_test pcache-1.1 {
do_test pcache-1.2 {
sqlite3 db test.db
execsql {
PRAGMA cache_size=10;
PRAGMA cache_size=12;
PRAGMA auto_vacuum=0;
}
pcache_stats
} {current 1 max 10 min 10 recyclable 1}
} {current 1 max 12 min 10 recyclable 1}
do_test pcache-1.3 {
execsql {
@ -46,7 +46,7 @@ do_test pcache-1.3 {
CREATE TABLE t5(a, b, c);
}
pcache_stats
} {current 6 max 10 min 10 recyclable 0}
} {current 6 max 12 min 10 recyclable 0}
do_test pcache-1.4 {
execsql {
@ -56,13 +56,13 @@ do_test pcache-1.4 {
CREATE TABLE t9(a, b, c);
}
pcache_stats
} {current 10 max 10 min 10 recyclable 0}
} {current 10 max 12 min 10 recyclable 0}
do_test pcache-1.5 {
sqlite3 db2 test.db
execsql "PRAGMA cache_size=10" db2
pcache_stats
} {current 11 max 20 min 20 recyclable 1}
} {current 11 max 22 min 20 recyclable 1}
do_test pcache-1.6.1 {
execsql {
@ -70,7 +70,7 @@ do_test pcache-1.6.1 {
SELECT * FROM sqlite_master;
} db2
pcache_stats
} {current 11 max 20 min 20 recyclable 0}
} {current 11 max 22 min 20 recyclable 0}
# At this point connection db2 has a read lock on the database file and a
# single pinned page in its cache. Connection [db] is holding 10 dirty
@ -87,16 +87,18 @@ do_test pcache-1.6.2 {
CREATE INDEX i7 ON t7(a, b);
CREATE INDEX i8 ON t8(a, b);
CREATE INDEX i9 ON t9(a, b);
CREATE INDEX i10 ON t9(a, b);
CREATE INDEX i11 ON t9(a, b);
}
pcache_stats
} {current 20 max 20 min 20 recyclable 0}
} {current 23 max 22 min 20 recyclable 0}
do_test pcache-1.7 {
execsql {
CREATE TABLE t10(a, b, c);
}
pcache_stats
} {current 21 max 20 min 20 recyclable 0}
} {current 24 max 22 min 20 recyclable 0}
# Rolling back the transaction held by db2 at this point releases a pinned
# page. Because the number of allocated pages is greater than the
@ -106,22 +108,22 @@ do_test pcache-1.7 {
do_test pcache-1.8 {
execsql {ROLLBACK} db2
pcache_stats
} {current 20 max 20 min 20 recyclable 0}
} {current 23 max 22 min 20 recyclable 0}
do_test pcache-1.9 {
execsql COMMIT
pcache_stats
} {current 20 max 20 min 20 recyclable 20}
} {current 22 max 22 min 20 recyclable 22}
do_test pcache-1.10 {
db2 close
pcache_stats
} {current 10 max 10 min 10 recyclable 10}
} {current 12 max 12 min 10 recyclable 12}
do_test pcache-1.11 {
execsql { PRAGMA cache_size = 20 }
pcache_stats
} {current 10 max 20 min 10 recyclable 10}
} {current 12 max 20 min 10 recyclable 12}
do_test pcache-1.12 {
execsql {