1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

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
This commit is contained in:
drh
2009-01-07 03:59:47 +00:00
parent d6e5e09816
commit f2a84e3ca6
4 changed files with 42 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
C Pager\schanges\sattempting\sto\sverify\sthat\sticket\s#2565\scannot\srecur.\s(CVS\s6126) C Add\sa\sHIGHSTRESS\sparameter\sto\sthe\ssqlite3_config_alt_pcache\sdebugging\ncommand\sin\sthe\stest\sharness\s-\sto\sforce\scalling\spagerStress()\smore\nfrequently.\s(CVS\s6127)
D 2009-01-07T02:03:35 D 2009-01-07T03:59:47
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -181,12 +181,12 @@ F src/test_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
F src/test_journal.c ce3da048786536f0264ca5135c9639e34d1fbe3f F src/test_journal.c ce3da048786536f0264ca5135c9639e34d1fbe3f
F src/test_loadext.c 97dc8800e46a46ed002c2968572656f37e9c0dd9 F src/test_loadext.c 97dc8800e46a46ed002c2968572656f37e9c0dd9
F src/test_malloc.c 5127337c9fb4c851a7f604c0170e0e5ca1fbfe33 F src/test_malloc.c cf348d78704340f72f8ab9f9327a6d4a0d71d351
F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071 F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
F src/test_mutex.c 66c4ab4e0396a440ddb17cd9b58a05305144f05d F src/test_mutex.c 66c4ab4e0396a440ddb17cd9b58a05305144f05d
F src/test_onefile.c fad2e1b589a840002b8f967ae24397c3ec4a090b F src/test_onefile.c fad2e1b589a840002b8f967ae24397c3ec4a090b
F src/test_osinst.c ae29e9c09485622a157849508302dd9ffe44f21f F src/test_osinst.c ae29e9c09485622a157849508302dd9ffe44f21f
F src/test_pcache.c 0008968cc36558c8253585e5d321eccba44edb80 F src/test_pcache.c 29464896d9c67832e4eef916c0682b98d7283d00
F src/test_schema.c 4b4bf7bb329326458c491b0e6facd4c8c4c5b479 F src/test_schema.c 4b4bf7bb329326458c491b0e6facd4c8c4c5b479
F src/test_server.c f0a403b5f699c09bd2b1236b6f69830fd6221f6b F src/test_server.c f0a403b5f699c09bd2b1236b6f69830fd6221f6b
F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4 F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4
@@ -692,7 +692,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 3c2f292fb7c79ba9be32fe8f19e52b35b9cadf6a P 15b9dac455b3f457bb177fc4985b45957647cbec
R f3e8e771965b44cff3d40a2642cd89a1 R e14c51ceac93b713fc890634eddc1ae9
U drh U drh
Z 34c6a839f70d49e19d88996d013df310 Z d1d04d55d5af4665fa8ebbfc334f2f8d

View File

@@ -1 +1 @@
15b9dac455b3f457bb177fc4985b45957647cbec e426860b94f5b47e3a265549dbac64a421cae425

View File

@@ -13,7 +13,7 @@
** This file contains code used to implement test interfaces to the ** This file contains code used to implement test interfaces to the
** memory allocation subsystem. ** 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 "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -962,22 +962,32 @@ static int test_alt_pcache(
Tcl_Obj *CONST objv[] Tcl_Obj *CONST objv[]
){ ){
int installFlag; int installFlag;
int discardChance; int discardChance = 0;
int prngSeed; int prngSeed = 0;
extern void installTestPCache(int,unsigned,unsigned); int highStress = 0;
if( objc!=4 ){ extern void installTestPCache(int,unsigned,unsigned,unsigned);
Tcl_WrongNumArgs(interp, 1, objv, "INSTALLFLAG DISCARDCHANCE PRNGSEEED"); if( objc<2 || objc>5 ){
Tcl_WrongNumArgs(interp, 1, objv,
"INSTALLFLAG DISCARDCHANCE PRNGSEEED HIGHSTRESS");
return TCL_ERROR; return TCL_ERROR;
} }
if( Tcl_GetIntFromObj(interp, objv[1], &installFlag) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[1], &installFlag) ) return TCL_ERROR;
if( Tcl_GetIntFromObj(interp, objv[2], &discardChance) ) return TCL_ERROR; if( objc>=3 && Tcl_GetIntFromObj(interp, objv[2], &discardChance) ){
if( Tcl_GetIntFromObj(interp, objv[3], &prngSeed) ) return TCL_ERROR; 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 ){ if( discardChance<0 || discardChance>100 ){
Tcl_AppendResult(interp, "discard-chance should be between 0 and 100", Tcl_AppendResult(interp, "discard-chance should be between 0 and 100",
(char*)0); (char*)0);
return TCL_ERROR; return TCL_ERROR;
} }
installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed); installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed,
(unsigned)highStress);
return TCL_OK; return TCL_OK;
} }

View File

@@ -21,7 +21,7 @@
** This pagecache implementation is designed for simplicity ** This pagecache implementation is designed for simplicity
** not speed. ** 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 "sqlite3.h"
#include <string.h> #include <string.h>
@@ -36,8 +36,9 @@ typedef struct testpcacheGlobalType testpcacheGlobalType;
struct testpcacheGlobalType { struct testpcacheGlobalType {
void *pDummy; /* Dummy allocation to simulate failures */ void *pDummy; /* Dummy allocation to simulate failures */
int nInstance; /* Number of current instances */ 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 prngSeed; /* Seed for the PRNG */
unsigned highStress; /* Call xStress agressively */
}; };
static testpcacheGlobalType testpcacheGlobal; static testpcacheGlobalType testpcacheGlobal;
@@ -210,6 +211,15 @@ static void *testpcacheFetch(
return 0; 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. /* Find a free page to allocate if there are any free pages.
** Withhold TESTPCACHE_RESERVE free pages until createFlag is 2. ** Withhold TESTPCACHE_RESERVE free pages until createFlag is 2.
*/ */
@@ -401,7 +411,8 @@ static void testpcacheDestroy(sqlite3_pcache *pCache){
void installTestPCache( void installTestPCache(
int installFlag, /* True to install. False to uninstall. */ int installFlag, /* True to install. False to uninstall. */
unsigned discardChance, /* 0-100. Chance to discard on unpin */ 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 = { static const sqlite3_pcache_methods testPcache = {
(void*)&testpcacheGlobal, (void*)&testpcacheGlobal,
@@ -424,6 +435,7 @@ void installTestPCache(
assert( discardChance<=100 ); assert( discardChance<=100 );
testpcacheGlobal.discardChance = discardChance; testpcacheGlobal.discardChance = discardChance;
testpcacheGlobal.prngSeed = prngSeed ^ (prngSeed<<16); testpcacheGlobal.prngSeed = prngSeed ^ (prngSeed<<16);
testpcacheGlobal.highStress = highStress;
if( installFlag!=isInstalled ){ if( installFlag!=isInstalled ){
if( installFlag ){ if( installFlag ){
sqlite3_config(SQLITE_CONFIG_GETPCACHE, &defaultPcache); sqlite3_config(SQLITE_CONFIG_GETPCACHE, &defaultPcache);