diff options
author | drh <drh@noemail.net> | 2009-01-07 03:59:47 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2009-01-07 03:59:47 +0000 |
commit | f2a84e3ca6ba12edb05cdaa24cd82fa9c8c9aa7b (patch) | |
tree | 1cc49ef7336f2c10650f96370412207deb019b3a /src/test_pcache.c | |
parent | d6e5e098165150062ab2e8c1acd311a9b5c2bee8 (diff) | |
download | sqlite-f2a84e3ca6ba12edb05cdaa24cd82fa9c8c9aa7b.tar.gz sqlite-f2a84e3ca6ba12edb05cdaa24cd82fa9c8c9aa7b.zip |
Add a HIGHSTRESS parameter to the sqlite3_config_alt_pcache debugging
command in the test harness - to force calling pagerStress() more
frequently. (CVS 6127)
FossilOrigin-Name: e426860b94f5b47e3a265549dbac64a421cae425
Diffstat (limited to 'src/test_pcache.c')
-rw-r--r-- | src/test_pcache.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/test_pcache.c b/src/test_pcache.c index 58f5b3981..05bc8f7e4 100644 --- a/src/test_pcache.c +++ b/src/test_pcache.c @@ -21,7 +21,7 @@ ** This pagecache implementation is designed for simplicity ** not speed. ** -** $Id: test_pcache.c,v 1.1 2008/11/19 01:20:26 drh Exp $ +** $Id: test_pcache.c,v 1.2 2009/01/07 03:59:47 drh Exp $ */ #include "sqlite3.h" #include <string.h> @@ -36,8 +36,9 @@ typedef struct testpcacheGlobalType testpcacheGlobalType; struct testpcacheGlobalType { void *pDummy; /* Dummy allocation to simulate failures */ int nInstance; /* Number of current instances */ - unsigned discardChance; /* Chance of discarding on an unpin */ + unsigned discardChance; /* Chance of discarding on an unpin (0-100) */ unsigned prngSeed; /* Seed for the PRNG */ + unsigned highStress; /* Call xStress agressively */ }; static testpcacheGlobalType testpcacheGlobal; @@ -210,6 +211,15 @@ static void *testpcacheFetch( return 0; } + /* Do not allocate if highStress is enabled and createFlag is not 2. + ** + ** The highStress setting causes pagerStress() to be called much more + ** often, which exercises the pager logic more intensely. + */ + if( testpcacheGlobal.highStress && createFlag<2 ){ + return 0; + } + /* Find a free page to allocate if there are any free pages. ** Withhold TESTPCACHE_RESERVE free pages until createFlag is 2. */ @@ -401,7 +411,8 @@ static void testpcacheDestroy(sqlite3_pcache *pCache){ void installTestPCache( int installFlag, /* True to install. False to uninstall. */ unsigned discardChance, /* 0-100. Chance to discard on unpin */ - unsigned prngSeed /* Seed for the PRNG */ + unsigned prngSeed, /* Seed for the PRNG */ + unsigned highStress /* Call xStress agressively */ ){ static const sqlite3_pcache_methods testPcache = { (void*)&testpcacheGlobal, @@ -424,6 +435,7 @@ void installTestPCache( assert( discardChance<=100 ); testpcacheGlobal.discardChance = discardChance; testpcacheGlobal.prngSeed = prngSeed ^ (prngSeed<<16); + testpcacheGlobal.highStress = highStress; if( installFlag!=isInstalled ){ if( installFlag ){ sqlite3_config(SQLITE_CONFIG_GETPCACHE, &defaultPcache); |