aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-01-07 03:59:47 +0000
committerdrh <drh@noemail.net>2009-01-07 03:59:47 +0000
commitf2a84e3ca6ba12edb05cdaa24cd82fa9c8c9aa7b (patch)
tree1cc49ef7336f2c10650f96370412207deb019b3a /src
parentd6e5e098165150062ab2e8c1acd311a9b5c2bee8 (diff)
downloadsqlite-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')
-rw-r--r--src/test_malloc.c28
-rw-r--r--src/test_pcache.c18
2 files changed, 34 insertions, 12 deletions
diff --git a/src/test_malloc.c b/src/test_malloc.c
index 2009f5428..7519b5f7a 100644
--- a/src/test_malloc.c
+++ b/src/test_malloc.c
@@ -13,7 +13,7 @@
** This file contains code used to implement test interfaces to the
** memory allocation subsystem.
**
-** $Id: test_malloc.c,v 1.51 2008/11/19 01:20:26 drh Exp $
+** $Id: test_malloc.c,v 1.52 2009/01/07 03:59:47 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -962,22 +962,32 @@ static int test_alt_pcache(
Tcl_Obj *CONST objv[]
){
int installFlag;
- int discardChance;
- int prngSeed;
- extern void installTestPCache(int,unsigned,unsigned);
- if( objc!=4 ){
- Tcl_WrongNumArgs(interp, 1, objv, "INSTALLFLAG DISCARDCHANCE PRNGSEEED");
+ int discardChance = 0;
+ int prngSeed = 0;
+ int highStress = 0;
+ extern void installTestPCache(int,unsigned,unsigned,unsigned);
+ if( objc<2 || objc>5 ){
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "INSTALLFLAG DISCARDCHANCE PRNGSEEED HIGHSTRESS");
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(interp, objv[1], &installFlag) ) return TCL_ERROR;
- if( Tcl_GetIntFromObj(interp, objv[2], &discardChance) ) return TCL_ERROR;
- if( Tcl_GetIntFromObj(interp, objv[3], &prngSeed) ) return TCL_ERROR;
+ if( objc>=3 && Tcl_GetIntFromObj(interp, objv[2], &discardChance) ){
+ return TCL_ERROR;
+ }
+ if( objc>=4 && Tcl_GetIntFromObj(interp, objv[3], &prngSeed) ){
+ return TCL_ERROR;
+ }
+ if( objc>=5 && Tcl_GetIntFromObj(interp, objv[4], &highStress) ){
+ return TCL_ERROR;
+ }
if( discardChance<0 || discardChance>100 ){
Tcl_AppendResult(interp, "discard-chance should be between 0 and 100",
(char*)0);
return TCL_ERROR;
}
- installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed);
+ installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed,
+ (unsigned)highStress);
return TCL_OK;
}
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);