/ Check-in [61853bc1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix another lsmtest build problem. Add the "-trans BOOLEAN" option to "lsmtest speed2".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lsm-vtab
Files: files | file ages | folders
SHA3-256:61853bc171e7c3af1db6a33ac8b1ad21e1c08e8d6b317fe061fdcd89c9a42e88
User & Date: dan 2017-06-07 19:46:18
Context
2017-06-15
15:06
Merge the latest changes from trunk. check-in: 60105c22 user: drh tags: lsm-vtab
2017-06-07
19:46
Fix another lsmtest build problem. Add the "-trans BOOLEAN" option to "lsmtest speed2". check-in: 61853bc1 user: dan tags: lsm-vtab
2017-06-06
16:14
Fix a threading problem in lsm test code. check-in: 501238b9 user: dan tags: lsm-vtab
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/Makefile.

    43     43   # all: lsm.so
    44     44   
    45     45   LSMOPTS = -DLSM_MUTEX_PTHREADS=1 -I$(LSMDIR)
    46     46   
    47     47   lsm.so:	$(LSMOBJ)
    48     48   	$(TCCX) -shared -o lsm.so $(LSMOBJ)
    49     49   
    50         -%.o:	$(LSMDIR)/%.c $(LSMHDR)
           50  +%.o:	$(LSMDIR)/%.c $(LSMHDR) sqlite3.h
    51     51   	$(TCCX) $(LSMOPTS) -c $<
    52     52   	
    53         -lsmtest$(EXE): $(LSMOBJ) $(LSMTESTSRC) $(LSMTESTHDR)
           53  +lsmtest$(EXE): $(LSMOBJ) $(LSMTESTSRC) $(LSMTESTHDR) sqlite3.o
    54     54   	# $(TCPPX) -c $(TOP)/lsm-test/lsmtest_tdb2.cc
    55         -	$(TCCX) $(LSMOPTS) $(LSMTESTSRC) $(LSMOBJ) -o lsmtest$(EXE) $(THREADLIB) -lsqlite3 
           55  +	$(TCCX) $(LSMOPTS) $(LSMTESTSRC) $(LSMOBJ) sqlite3.o -o lsmtest$(EXE) $(THREADLIB) 
    56     56   

Changes to ext/lsm1/lsm-test/lsmtest_main.c.

     1      1   
     2         -#include <stdarg.h>
            2  +#include "stdarg.h"
     3      3   #include "lsmtest.h"
     4      4   #include "stdio.h"
     5      5   #include "assert.h"
     6      6   #include "string.h"
     7      7   #include "stdlib.h"
     8      8   
     9      9   #include <sqlite3.h>
................................................................................
   359    359   }
   360    360   
   361    361   char *testMallocVPrintf(const char *zFormat, va_list ap){
   362    362     int nByte;
   363    363     va_list copy;
   364    364     char *zRet;
   365    365   
   366         -  va_copy(copy, ap);
          366  +  __va_copy(copy, ap);
   367    367     nByte = vsnprintf(0, 0, zFormat, copy);
   368    368     va_end(copy);
   369    369   
   370    370     assert( nByte>=0 );
   371    371     zRet = (char *)testMalloc(nByte+1);
   372    372     vsnprintf(zRet, nByte+1, zFormat, ap);
   373    373     return zRet;
................................................................................
   568    568   #define ST_WRITE   1
   569    569   #define ST_PAUSE   2
   570    570   #define ST_FETCH   3
   571    571   #define ST_SCAN    4
   572    572   #define ST_NSCAN   5
   573    573   #define ST_KEYSIZE 6
   574    574   #define ST_VALSIZE 7
          575  +#define ST_TRANS   8
   575    576   
   576    577   
   577    578   static void print_speed_test_help(){
   578    579     printf(
   579    580   "\n"
   580    581   "Repeat the following $repeat times:\n"
   581    582   "  1. Insert $write key-value pairs. One transaction for each write op.\n"
................................................................................
   589    590   "  -repeat  $repeat                 (default value 10)\n"
   590    591   "  -write   $write                  (default value 10000)\n"
   591    592   "  -pause   $pause                  (default value 0)\n"
   592    593   "  -fetch   $fetch                  (default value 0)\n"
   593    594   "  -keysize $keysize                (default value 12)\n"
   594    595   "  -valsize $valsize                (default value 100)\n"
   595    596   "  -system  $system                 (default value \"lsm\")\n"
          597  +"  -trans   $trans                  (default value 0)\n"
   596    598   "\n"
   597    599   );
   598    600   }
   599    601   
   600    602   int do_speed_test2(int nArg, char **azArg){
   601    603     struct Option {
   602    604       const char *zOpt;
................................................................................
   607    609       { "-write",   ST_WRITE,  10000},
   608    610       { "-pause",   ST_PAUSE,      0},
   609    611       { "-fetch",   ST_FETCH,      0},
   610    612       { "-scan",    ST_SCAN,       0},
   611    613       { "-nscan",   ST_NSCAN,      0},
   612    614       { "-keysize", ST_KEYSIZE,   12},
   613    615       { "-valsize", ST_VALSIZE,  100},
          616  +    { "-trans",   ST_TRANS,      0},
   614    617       { "-system",  -1,            0},
   615    618       { "help",     -2,            0},
   616    619       {0, 0, 0}
   617    620     };
   618    621     int i;
   619         -  int aParam[8];
          622  +  int aParam[9];
   620    623     int rc = 0;
   621    624     int bReadonly = 0;
   622    625     int nContent = 0;
   623    626   
   624    627     TestDb *pDb;
   625    628     Datasource *pData;
   626    629     DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 0, 0, 0, 0 };
................................................................................
   708    711       int iFetch;
   709    712       int nWrite = aParam[ST_WRITE];
   710    713   
   711    714       if( bReadonly ){
   712    715         msWrite = 0;
   713    716       }else{
   714    717         testTimeInit();
          718  +
          719  +      if( aParam[ST_TRANS] ) testBegin(pDb, 2, &rc);
   715    720         testWriteDatasourceRange(pDb, pData, i*nWrite, nWrite, &rc);
          721  +      if( aParam[ST_TRANS] ) testCommit(pDb, 0, &rc);
          722  +
   716    723         msWrite = testTimeGet();
   717    724         nContent += nWrite;
   718    725       }
   719    726   
   720    727       if( aParam[ST_PAUSE] ){
   721    728         if( aParam[ST_PAUSE]/1000 ) sleep(aParam[ST_PAUSE]/1000);
   722    729         if( aParam[ST_PAUSE]%1000 ) usleep(1000 * (aParam[ST_PAUSE]%1000));
   723    730       }
   724    731   
   725    732       if( aParam[ST_FETCH] ){
   726    733         testTimeInit();
          734  +      if( aParam[ST_TRANS] ) testBegin(pDb, 1, &rc);
   727    735         for(iFetch=0; iFetch<aParam[ST_FETCH]; iFetch++){
   728    736           int iKey = testPrngValue(i*nWrite+iFetch) % nContent;
   729    737   #ifndef NDEBUG
   730    738           testDatasourceFetch(pDb, pData, iKey, &rc);
   731    739   #else
   732    740           void *pKey; int nKey;           /* Database key to query for */
   733    741           void *pVal; int nVal;           /* Result of query */
................................................................................
   734    742   
   735    743           testDatasourceEntry(pData, iKey, &pKey, &nKey, 0, 0);
   736    744           rc = tdb_fetch(pDb, pKey, nKey, &pVal, &nVal);
   737    745           if( rc==0 && nVal<0 ) rc = 1;
   738    746           if( rc ) break;
   739    747   #endif
   740    748         }
          749  +      if( aParam[ST_TRANS] ) testCommit(pDb, 0, &rc);
   741    750         msFetch = testTimeGet();
   742    751       }else{
   743    752         msFetch = 0;
   744    753       }
   745    754   
   746    755       if( i==(aParam[ST_REPEAT]-1) ){
   747    756         testTimeInit();

Changes to ext/lsm1/lsm-test/lsmtest_tdb.c.

   689    689     sqlite3_exec(pDb->db, zPragma, 0, 0, 0);
   690    690     sqlite3_free(zPragma);
   691    691   
   692    692     /* sqlite3_exec(pDb->db, "PRAGMA locking_mode=EXCLUSIVE", 0, 0, 0); */
   693    693     sqlite3_exec(pDb->db, "PRAGMA synchronous=OFF", 0, 0, 0);
   694    694     sqlite3_exec(pDb->db, "PRAGMA journal_mode=WAL", 0, 0, 0);
   695    695     sqlite3_exec(pDb->db, "PRAGMA wal_autocheckpoint=4096", 0, 0, 0);
          696  +  if( zSpec ){
          697  +    rc = sqlite3_exec(pDb->db, zSpec, 0, 0, 0);
          698  +    if( rc!=SQLITE_OK ){
          699  +      sql_close((TestDb *)pDb);
          700  +      return rc;
          701  +    }
          702  +  }
   696    703   
   697    704     *ppDb = (TestDb *)pDb;
   698    705     return 0;
   699    706   }
   700    707   /* 
   701    708   ** End wrapper for SQLite.
   702    709   *************************************************************************/

Changes to ext/lsm1/lsm-test/lsmtest_tdb3.c.

   504    504     testFree(pDb->aFile[1].aSector);
   505    505   
   506    506     memset(pDb, sizeof(LsmDb), 0x11);
   507    507     testFree((char *)pDb->pBuf);
   508    508     testFree((char *)pDb);
   509    509     return rc;
   510    510   }
          511  +
          512  +static void mt_signal_worker(LsmDb*, int);
   511    513   
   512    514   static int waitOnCheckpointer(LsmDb *pDb, lsm_db *db){
   513    515     int nSleep = 0;
   514    516     int nKB;
   515    517     int rc;
   516    518   
   517    519     do {
   518    520       nKB = 0;
   519    521       rc = lsm_info(db, LSM_INFO_CHECKPOINT_SIZE, &nKB);
   520    522       if( rc!=LSM_OK || nKB<pDb->nMtMaxCkpt ) break;
          523  +#ifdef LSM_MUTEX_PTHREADS
          524  +    mt_signal_worker(pDb, 1);
          525  +#endif
   521    526       usleep(5000);
   522    527       nSleep += 5;
   523    528     }while( 1 );
   524    529   
   525    530   #if 0
   526    531       if( nSleep ) printf("# waitOnCheckpointer(): nSleep=%d\n", nSleep);
   527    532   #endif
   528    533   
   529    534     return rc;
   530    535   }
   531    536   
   532         -static void mt_signal_worker(LsmDb*, int);
   533         -
   534    537   static int waitOnWorker(LsmDb *pDb){
   535    538     int rc;
   536    539     int nLimit = -1;
   537    540     int nSleep = 0;
   538    541   
   539    542     rc = lsm_config(pDb->db, LSM_CONFIG_AUTOFLUSH, &nLimit);
   540    543     do {
................................................................................
   787    790   #ifdef HAVE_ZLIB
   788    791       { "compression",      0, TEST_COMPRESSION },
   789    792   #endif
   790    793       { 0, 0 }
   791    794     };
   792    795     const char *z = zStr;
   793    796     int nThread = 1;
          797  +
          798  +  if( zStr==0 ) return 0;
   794    799   
   795    800     assert( db );
   796    801     while( z[0] ){
   797    802       const char *zStart;
   798    803   
   799    804       /* Skip whitespace */
   800    805       while( *z==' ' ) z++;