From: drh Date: Sat, 2 May 2015 19:54:35 +0000 (+0000) Subject: Improvements to fuzzershell: Avoid excess memory allocations when loading X-Git-Tag: version-3.8.10~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a57c17d0f818fadfce2fc592bc33d9cdf050fed;p=thirdparty%2Fsqlite.git Improvements to fuzzershell: Avoid excess memory allocations when loading many files. Show the total runtime on final output. Show individual filenames as they are processed even if they are single test-case files. FossilOrigin-Name: 34a722a2f3331c35211526c9ec055d4d9175c965 --- diff --git a/manifest b/manifest index dc584aea02..048dee03ad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s".limit"\scommand\sto\sthe\scommand-line\sshell. -D 2015-05-02T17:40:23.555 +C Improvements\sto\sfuzzershell:\sAvoid\sexcess\smemory\sallocations\swhen\sloading\nmany\sfiles.\s\sShow\sthe\stotal\sruntime\son\sfinal\soutput.\s\sShow\sindividual\sfilenames\nas\sthey\sare\sprocessed\seven\sif\sthey\sare\ssingle\stest-case\sfiles. +D 2015-05-02T19:54:35.010 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e628c50e237251fc7e768bef14ee7e822ad69e69 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1208,7 +1208,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c beafb3f10b02fedab02d364054290d93cfa42c8e +F tool/fuzzershell.c e8be9a8bd8e0e7814592c5e3e38de99ad7beee83 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 78c7ec95931265b89a92f6a799fc9b1a9f0476bf -R b4e016ae5f2b9a1c3d3b22b5f2592000 +P 803cb60e75e0b09a526eefec11139cb3e8ae8c7c +R a10ebc5ebd493f767d287662e8eaf180 U drh -Z d46a3572f454bea0b6b400466ab43088 +Z 6cb1cc7bdaf6b986d5c102ca2fc3f2f8 diff --git a/manifest.uuid b/manifest.uuid index 940f87c4fd..356c6a5181 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -803cb60e75e0b09a526eefec11139cb3e8ae8c7c \ No newline at end of file +34a722a2f3331c35211526c9ec055d4d9175c965 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index 6d12a29793..4eea55ba0e 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -451,9 +451,10 @@ int main(int argc, char **argv){ int nInFile = 0; /* Number of input files to read */ char **azInFile = 0; /* Array of input file names */ int jj; /* Loop counter for azInFile[] */ + sqlite3_int64 iBegin; /* Start time for the whole program */ sqlite3_int64 iStart, iEnd; /* Start and end-times for a test case */ - + iBegin = timeOfDay(); zFailCode = getenv("TEST_FAILURE"); g.zArgv0 = argv[0]; zPrompt = ""; @@ -612,13 +613,15 @@ int main(int argc, char **argv){ zPrompt = ""; } while( !feof(in) ){ - zIn = realloc(zIn, nAlloc); - if( zIn==0 ) fatalError("out of memory"); got = fread(zIn+nIn, 1, nAlloc-nIn-1, in); nIn += (int)got; zIn[nIn] = 0; if( got==0 ) break; - nAlloc += nAlloc+1000; + if( nAlloc - nIn - 1 < 100 ){ + nAlloc += nAlloc+1000; + zIn = realloc(zIn, nAlloc); + if( zIn==0 ) fatalError("out of memory"); + } } if( in!=stdin ) fclose(in); lastPct = -1; @@ -670,6 +673,8 @@ int main(int argc, char **argv){ lastPct = pct; } } + }else if( nInFile>1 ){ + printf("%s\n", zPrompt); } fflush(stdout); @@ -803,8 +808,10 @@ int main(int argc, char **argv){ /* Report total number of tests run */ if( nTest>1 && !quietFlag ){ - printf("%s: 0 errors out of %d tests\nSQLite %s %s\n", - g.zArgv0, nTest, sqlite3_libversion(), sqlite3_sourceid()); + sqlite3_int64 iElapse = timeOfDay() - iBegin; + printf("%s: 0 errors out of %d tests in %d.%03d seconds\nSQLite %s %s\n", + g.zArgv0, nTest, (int)(iElapse/1000), (int)(iElapse%1000), + sqlite3_libversion(), sqlite3_sourceid()); } /* Write the unique test cases if the --unique-cases flag was used