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

Improve concurrency in test_multiplex.c. Add a switch to "threadtest3" allowing it to run using the multiplexor VFS.

FossilOrigin-Name: 9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd
This commit is contained in:
dan
2015-12-03 11:51:18 +00:00
parent c18ed977e8
commit 48c06f32ca
5 changed files with 45 additions and 25 deletions

View File

@ -795,8 +795,8 @@ THREADTEST3_SRC = $(TOP)/test/threadtest3.c \
$(TOP)/test/tt3_stress.c \
$(TOP)/test/tt3_lookaside1.c
threadtest3$(EXE): sqlite3.o $(THREADTEST3_SRC)
$(TCCX) $(TOP)/test/threadtest3.c sqlite3.o -o $@ $(THREADLIB)
threadtest3$(EXE): libsqlite3.a $(THREADTEST3_SRC) $(TOP)/src/test_multiplex.c
$(TCCX) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c libsqlite3.a -o $@ $(THREADLIB)
threadtest: threadtest3$(EXE)
./threadtest3$(EXE)

View File

@ -1,5 +1,5 @@
C A\sunix\sVFS\schange\sreplaces\sfsync()\swith\sfstat()\swhen\susing\sSQLITE_NO_SYNC,\sso\nset\sPRAGMA\ssynchronous=OFF\sin\sthe\ssysfault-3\stest\sto\savoid\serroneously\scausing\nerrors\sin\sxSync.
D 2015-12-03T01:48:32.232
C Improve\sconcurrency\sin\stest_multiplex.c.\sAdd\sa\sswitch\sto\s"threadtest3"\sallowing\sit\sto\srun\susing\sthe\smultiplexor\sVFS.
D 2015-12-03T11:51:18.767
F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d
@ -263,7 +263,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
F main.mk 9001039f432baeba1074e2d1885f3dfd572b8636
F main.mk 2a1196d5e10ce062862b24a4cf9a985fe477de34
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@ -375,7 +375,7 @@ F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202
F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa
F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4
F src/test_malloc.c 8e1c2112fa4f543b46c990a8872f9e6d37938744
F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce
F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d
F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c
F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10
@ -1074,7 +1074,7 @@ F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46
F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8
F test/threadtest3.c 0707c28e0954acbef654f91675e14f3573cf9a10
F test/threadtest3.c 469ea7fe7030d75bd67dcf8047b16c1deea5210d
F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925
F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c
F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660
@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 4f2bcff94c672312805be1400050a7026f93a9d7
R 029751c01b929451cff95b86da0868ac
U drh
Z 7f6ec6c824be76681c81bd551b601799
P 4f7f355021f9eb048fffc84e559bfb3fdb1e1e69
R 17fe6dc83cb64fc6198b93af9ffea9ca
U dan
Z de557aa3ec0a739d4121e9d650d8e092

View File

@ -1 +1 @@
4f7f355021f9eb048fffc84e559bfb3fdb1e1e69
9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd

View File

@ -189,8 +189,11 @@ static struct {
int isInitialized;
/* For run-time access any of the other global data structures in this
** shim, the following mutex must be held.
*/
** shim, the following mutex must be held. In practice, all this mutex
** protects is add/remove operations to/from the linked list of group objects
** starting at pGroups below. More specifically, it protects the value of
** pGroups itself, and the pNext/pPrev fields of each multiplexGroup
** structure. */
sqlite3_mutex *pMutex;
/* List of multiplexGroup objects.
@ -758,11 +761,8 @@ static int multiplexRead(
multiplexConn *p = (multiplexConn*)pConn;
multiplexGroup *pGroup = p->pGroup;
int rc = SQLITE_OK;
int nMutex = 0;
multiplexEnter(); nMutex++;
if( !pGroup->bEnabled ){
sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);
multiplexLeave(); nMutex--;
if( pSubOpen==0 ){
rc = SQLITE_IOERR_READ;
}else{
@ -772,9 +772,7 @@ static int multiplexRead(
while( iAmt > 0 ){
int i = (int)(iOfst / pGroup->szChunk);
sqlite3_file *pSubOpen;
if( nMutex==0 ){ multiplexEnter(); nMutex++; }
pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1);
multiplexLeave(); nMutex--;
if( pSubOpen ){
int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) - pGroup->szChunk;
if( extra<0 ) extra = 0;
@ -791,8 +789,7 @@ static int multiplexRead(
}
}
}
assert( nMutex==0 || nMutex==1 );
if( nMutex ) multiplexLeave();
return rc;
}
@ -809,7 +806,6 @@ static int multiplexWrite(
multiplexConn *p = (multiplexConn*)pConn;
multiplexGroup *pGroup = p->pGroup;
int rc = SQLITE_OK;
multiplexEnter();
if( !pGroup->bEnabled ){
sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);
if( pSubOpen==0 ){
@ -834,7 +830,6 @@ static int multiplexWrite(
}
}
}
multiplexLeave();
return rc;
}

View File

@ -88,6 +88,8 @@
#include <fcntl.h>
#include <errno.h>
#include "test_multiplex.h"
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
@ -1460,13 +1462,36 @@ int main(int argc, char **argv){
argc = 2;
argv = substArgv;
}
/* Loop through the command-line arguments to ensure that each argument
** selects at least one test. If not, assume there is a typo on the
** command-line and bail out with the usage message. */
for(iArg=1; iArg<argc; iArg++){
const char *zArg = argv[iArg];
if( zArg[0]=='-' ){
if( sqlite3_stricmp(zArg, "-multiplexor")==0 ){
/* Install the multiplexor VFS as the default */
int rc = sqlite3_multiplex_initialize(0, 1);
if( rc!=SQLITE_OK ){
fprintf(stderr, "Failed to install multiplexor VFS (%d)\n", rc);
return 253;
}
}
else {
goto usage;
}
continue;
}
for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
if( sqlite3_strglob(argv[iArg],aTest[i].zTest)==0 ) break;
if( sqlite3_strglob(zArg, aTest[i].zTest)==0 ) break;
}
if( i>=sizeof(aTest)/sizeof(aTest[0]) ) goto usage;
}
for(iArg=1; iArg<argc; iArg++){
if( argv[iArg][0]=='-' ) continue;
for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
char const *z = aTest[i].zTest;
if( sqlite3_strglob(argv[iArg],z)==0 ){
@ -1483,7 +1508,7 @@ int main(int argc, char **argv){
return (nGlobalErr>0 ? 255 : 0);
usage:
printf("Usage: %s [testname|testprefix*]...\n", argv[0]);
printf("Usage: %s [-multiplexor] [testname|testprefix*]...\n", argv[0]);
printf("Available tests are:\n");
for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
printf(" %s\n", aTest[i].zTest);