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

Add the --fsync flag to kvtest, and document the --nosync flag.

FossilOrigin-Name: 7fdc78a672b2ea6187dcb5fdf32f809bb8e4d501e2434f2233edc3bc2e3acc7c
This commit is contained in:
drh
2017-06-02 23:32:17 +00:00
parent a2e71ced79
commit f151890791
3 changed files with 29 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Work\stoward\senhancing\skvtest\sto\smeasure\swrite\sperformance.
D 2017-06-02T19:31:46.986
C Add\sthe\s--fsync\sflag\sto\skvtest,\sand\sdocument\sthe\s--nosync\sflag.
D 2017-06-02T23:32:17.964
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc
@ -925,7 +925,7 @@ F test/json102.test eeb54efa221e50b74a2d6fb9259963b48d7414dca3ce2fdfdeed45cb2848
F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0
F test/json104.test 877d5845f6303899b7889ea5dd1bea99076e3100574d5c536082245c5805dcaa
F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
F test/kvtest.c 63f9a1c31391f304e87d4854aea54c01afa9e4f6d05e11124598c7415b893a85
F test/kvtest.c bf2e7ae3de92d98147e8cd49fc550ee3382599aa20b7e2b60038b409a5b2ef34
F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302
@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P ab33d299c7dab52703d06f3441c8a98c6c809b2612ec65d71aab2919bd2b1540
R b213b6f467b3c9502658fd4e2800b6d6
P fc73e7d2f16386f96c55c42f9830193f7c178521a7ad90c3117b85ef629b5ce4
R ac814c325af013850c7ab30877776723
U drh
Z 24f39ffaffd16b2467372fb4bd435c2b
Z 8a788cf2631896aff995d8f1a4f42a59

View File

@ -1 +1 @@
fc73e7d2f16386f96c55c42f9830193f7c178521a7ad90c3117b85ef629b5ce4
7fdc78a672b2ea6187dcb5fdf32f809bb8e4d501e2434f2233edc3bc2e3acc7c

View File

@ -90,9 +90,11 @@ static const char zHelp[] =
" --cache-size N Database cache size\n"
" --count N Read N blobs\n"
" --desc Read blobs in descending order\n"
" --integrity-check Run 'PRAGMA integrity_check' after test\n"
" --fsync Synchronous file writes\n"
" --integrity-check Run \"PRAGMA integrity_check\" after test\n"
" --max-id N Maximum blob key to use\n"
" --mmap N Mmap as much as N bytes of DBFILE\n"
" --nosync Set \"PRAGMA synchronous=OFF\"\n"
" --jmode MODE Set MODE journal mode prior to starting\n"
" --random Read blobs in a random order\n"
" --start N Start reading with this blob key\n"
@ -541,11 +543,12 @@ static unsigned char *readFile(const char *zName, int *pnByte){
** Overwrite a file with randomness. Do not change the size of the
** file.
*/
static void updateFile(const char *zName, int *pnByte){
static void updateFile(const char *zName, int *pnByte, int doFsync){
FILE *out; /* FILE from which to read content of zName */
sqlite3_int64 sz; /* Size of zName in bytes */
size_t nWritten; /* Number of bytes actually read */
unsigned char *pBuf; /* Content to store on disk */
const char *zMode = "wb"; /* Mode for fopen() */
sz = fileSize(zName);
if( sz<0 ){
@ -558,11 +561,21 @@ static void updateFile(const char *zName, int *pnByte){
fatalError("Cannot allocate %lld bytes\n", sz);
}
sqlite3_randomness((int)sz, pBuf);
out = fopen(zName, "wb");
#if defined(_WIN32)
if( doFsync ) zMode = "wbc";
#endif
out = fopen(zName, zMode);
if( out==0 ){
fatalError("Cannot open \"%s\" for writing\n", zName);
}
nWritten = fwrite(pBuf, 1, (size_t)sz, out);
if( doFsync ){
#if defined(_WIN32)
fflush(out);
#else
fsync(fileno(out));
#endif
}
fclose(out);
if( nWritten!=(size_t)sz ){
fatalError("Wrote only %d of %d bytes to \"%s\"\n",
@ -728,6 +741,7 @@ static int runMain(int argc, char **argv){
int isUpdateTest = 0; /* Do in-place updates rather than reads */
int doIntegrityCk = 0; /* Run PRAGMA integrity_check after the test */
int noSync = 0; /* Disable synchronous mode */
int doFsync = 0; /* Update disk files synchronously */
sqlite3 *db = 0; /* Database connection */
sqlite3_stmt *pStmt = 0; /* Prepared statement for SQL access */
sqlite3_blob *pBlob = 0; /* Handle for incremental Blob I/O */
@ -816,6 +830,10 @@ static int runMain(int argc, char **argv){
noSync = 1;
continue;
}
if( strcmp(z, "-fsync")==0 ){
doFsync = 1;
continue;
}
fatalError("unknown option: \"%s\"", argv[i]);
}
if( eType==PATH_DB ){
@ -884,7 +902,7 @@ static int runMain(int argc, char **argv){
zKey = sqlite3_mprintf("%s/%06d", zDb, iKey);
nData = 0;
if( isUpdateTest ){
updateFile(zKey, &nData);
updateFile(zKey, &nData, doFsync);
}else{
pData = readFile(zKey, &nData);
sqlite3_free(pData);