Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improve concurrency in test_multiplex.c. Add a switch to "threadtest3" allowing it to run using the multiplexor VFS. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9d2c62b04e3a9ac5d9adea2aac7ec3f3 |
User & Date: | dan 2015-12-03 11:51:18.767 |
Context
2015-12-03
| ||
12:01 | Fix threadtest3 so that it builds using the autoconf build system. (check-in: d96de532cc user: dan tags: trunk) | |
11:51 | Improve concurrency in test_multiplex.c. Add a switch to "threadtest3" allowing it to run using the multiplexor VFS. (check-in: 9d2c62b04e user: dan tags: trunk) | |
01:48 | A unix VFS change replaces fsync() with fstat() when using SQLITE_NO_SYNC, so set PRAGMA synchronous=OFF in the sysfault-3 test to avoid erroneously causing errors in xSync. (check-in: 4f7f355021 user: drh tags: trunk) | |
Changes
Changes to main.mk.
︙ | ︙ | |||
791 792 793 794 795 796 797 | THREADTEST3_SRC = $(TOP)/test/threadtest3.c \ $(TOP)/test/tt3_checkpoint.c \ $(TOP)/test/tt3_index.c \ $(TOP)/test/tt3_vacuum.c \ $(TOP)/test/tt3_stress.c \ $(TOP)/test/tt3_lookaside1.c | | | | 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | THREADTEST3_SRC = $(TOP)/test/threadtest3.c \ $(TOP)/test/tt3_checkpoint.c \ $(TOP)/test/tt3_index.c \ $(TOP)/test/tt3_vacuum.c \ $(TOP)/test/tt3_stress.c \ $(TOP)/test/tt3_lookaside1.c 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) TEST_EXTENSION = $(SHPREFIX)testloadext.$(SO) $(TEST_EXTENSION): $(TOP)/src/test_loadext.c $(MKSHLIB) $(TOP)/src/test_loadext.c -o $(TEST_EXTENSION) |
︙ | ︙ |
Changes to src/test_multiplex.c.
︙ | ︙ | |||
185 186 187 188 189 190 191 | sqlite3_io_methods sIoMethodsV2; /* True when this shim has been initialized. */ int isInitialized; /* For run-time access any of the other global data structures in this | | > > > | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | sqlite3_io_methods sIoMethodsV2; /* True when this shim has been initialized. */ int isInitialized; /* For run-time access any of the other global data structures in this ** 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. */ multiplexGroup *pGroups; } gMultiplex; |
︙ | ︙ | |||
754 755 756 757 758 759 760 | void *pBuf, int iAmt, sqlite3_int64 iOfst ){ multiplexConn *p = (multiplexConn*)pConn; multiplexGroup *pGroup = p->pGroup; int rc = SQLITE_OK; | < < < < < | < < | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 | void *pBuf, int iAmt, sqlite3_int64 iOfst ){ multiplexConn *p = (multiplexConn*)pConn; multiplexGroup *pGroup = p->pGroup; int rc = SQLITE_OK; if( !pGroup->bEnabled ){ sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0); if( pSubOpen==0 ){ rc = SQLITE_IOERR_READ; }else{ rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst); } }else{ while( iAmt > 0 ){ int i = (int)(iOfst / pGroup->szChunk); sqlite3_file *pSubOpen; pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1); if( pSubOpen ){ int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) - pGroup->szChunk; if( extra<0 ) extra = 0; iAmt -= extra; rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst % pGroup->szChunk); if( rc!=SQLITE_OK ) break; pBuf = (char *)pBuf + iAmt; iOfst += iAmt; iAmt = extra; }else{ rc = SQLITE_IOERR_READ; break; } } } return rc; } /* Pass xWrite requests thru to the original VFS after ** determining the correct chunk to operate on. ** Break up writes across chunk boundaries. */ static int multiplexWrite( sqlite3_file *pConn, const void *pBuf, int iAmt, sqlite3_int64 iOfst ){ multiplexConn *p = (multiplexConn*)pConn; multiplexGroup *pGroup = p->pGroup; int rc = SQLITE_OK; if( !pGroup->bEnabled ){ sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0); if( pSubOpen==0 ){ rc = SQLITE_IOERR_WRITE; }else{ rc = pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt, iOfst); } |
︙ | ︙ | |||
830 831 832 833 834 835 836 | iOfst % pGroup->szChunk); pBuf = (char *)pBuf + iAmt; iOfst += iAmt; iAmt = extra; } } } | < | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | iOfst % pGroup->szChunk); pBuf = (char *)pBuf + iAmt; iOfst += iAmt; iAmt = extra; } } } return rc; } /* Pass xTruncate requests thru to the original VFS after ** determining the correct chunk to operate on. Delete any ** chunks above the truncate mark. */ |
︙ | ︙ |
Changes to test/threadtest3.c.
︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include <fcntl.h> #include <errno.h> /* * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. * * Equivalent code is available from RSA Data Security, Inc. | > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #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 * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. * * Equivalent code is available from RSA Data Security, Inc. |
︙ | ︙ | |||
1456 1457 1458 1459 1460 1461 1462 1463 1464 | int nTestfound = 0; sqlite3_config(SQLITE_CONFIG_MULTITHREAD); if( argc<2 ){ argc = 2; argv = substArgv; } for(iArg=1; iArg<argc; iArg++){ for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){ | > > > > > > > > > > > > > > > > > > > > > | > > | | 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | int nTestfound = 0; sqlite3_config(SQLITE_CONFIG_MULTITHREAD); if( argc<2 ){ 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(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 ){ printf("Running %s for %d seconds...\n", z, aTest[i].nMs/1000); fflush(stdout); aTest[i].xTest(aTest[i].nMs); nTestfound++; } } } if( nTestfound==0 ) goto usage; printf("%d errors out of %d tests\n", nGlobalErr, nTestfound); return (nGlobalErr>0 ? 255 : 0); usage: 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); } return 254; } |