diff --git a/db-benchmark-test/Makefile b/db-benchmark-test/Makefile index a721718c019..a39d34e004a 100644 --- a/db-benchmark-test/Makefile +++ b/db-benchmark-test/Makefile @@ -27,7 +27,7 @@ TARGETS = $(TARGET_BDB) $(TARGET_TDB) default: $(TARGETS) -check: check-default +check: check-default check-x2 check-default: $(TARGET_TDB) $(VALGRIND) ./$(TARGET_TDB) @@ -35,6 +35,12 @@ check-default: $(TARGET_TDB) check-x: $(TARGET_TDB) $(VALGRIND) ./$(TARGET_TDB) -x + +# A fast transaction test that detects #455. +check-xfast: $(TARGET_TDB) + ./$(TARGET_TDB) ./db-benchmark-test-tokudb --noserial -x --valsize 1000 --cachesize 8000000 --xcount 1000 --periter 20000 1 + + clean: rm -rf $(TARGETS) $(BENCHDBS) *.gcno *.gcda *.gcov diff --git a/db-benchmark-test/db-benchmark-test.c b/db-benchmark-test/db-benchmark-test.c index b1c4912adb1..34d8e588ec5 100644 --- a/db-benchmark-test/db-benchmark-test.c +++ b/db-benchmark-test/db-benchmark-test.c @@ -17,10 +17,8 @@ #endif enum { SERIAL_SPACING = 1<<6 }; -enum { ITEMS_TO_INSERT_PER_ITERATION = 1<<20 }; -enum { ITEMS_PER_TRANSACTION = 1<<14 }; -//enum { ITEMS_TO_INSERT_PER_ITERATION = 1<<14 }; -enum { BOUND_INCREASE_PER_ITERATION = SERIAL_SPACING*ITEMS_TO_INSERT_PER_ITERATION }; +enum { DEFAULT_ITEMS_TO_INSERT_PER_ITERATION = 1<<20 }; +enum { DEFAULT_ITEMS_PER_TRANSACTION = 1<<14 }; #define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0); @@ -30,6 +28,9 @@ int valsize = sizeof (long long); int pagesize = 0; long long cachesize = 128*1024*1024; int dupflags = 0; +int noserial = 0; // Don't do the serial stuff +int items_per_transaction = DEFAULT_ITEMS_PER_TRANSACTION; +int items_per_iteration = DEFAULT_ITEMS_TO_INSERT_PER_ITERATION; #define STRINGIFY2(s) #s #define STRINGIFY(s) STRINGIFY2(s) @@ -61,12 +62,12 @@ void setup (void) { #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 4 if (dbenv->set_lk_max) { - r = dbenv->set_lk_max(dbenv, ITEMS_PER_TRANSACTION*2); + r = dbenv->set_lk_max(dbenv, items_per_transaction*2); assert(r==0); } #endif if (dbenv->set_lk_max_locks) { - r = dbenv->set_lk_max_locks(dbenv, ITEMS_PER_TRANSACTION*2); + r = dbenv->set_lk_max_locks(dbenv, items_per_transaction*2); assert(r == 0); } @@ -136,7 +137,7 @@ void insert (long long v) { int r = db->put(db, tid, toku_fill_dbt(&kt, kc, keysize), toku_fill_dbt(&vt, vc, valsize), DB_YESOVERWRITE); CKERR(r); if (do_transactions) { - if (n_insertions_since_txn_began>=ITEMS_PER_TRANSACTION) { + if (n_insertions_since_txn_began>=items_per_transaction) { n_insertions_since_txn_began=0; r = tid->commit(tid, 0); assert(r==0); r=dbenv->txn_begin(dbenv, 0, &tid, 0); assert(r==0); @@ -157,7 +158,7 @@ void serial_insert_from (long long from) { } } - for (i=0; itxn_begin(dbenv, 0, &tid, 0); assert(r==0); } - for (i=0; i= argc) return print_usage(argv[0]); + items_per_transaction = strtoll(argv[++i], 0, 10); + continue; + } + if (strcmp(arg, "--periter") == 0) { + if (i+1 >= argc) return print_usage(argv[0]); + items_per_iteration = strtoll(argv[++i], 0, 10); + continue; + } + if (strcmp(arg, "--cachesize") == 0) { if (i+1 >= argc) return print_usage(argv[0]); cachesize = strtoll(argv[++i], 0, 10); continue; @@ -271,9 +291,10 @@ int main (int argc, const char *argv[]) { print_usage(argv[0]); return 1; } - total_n_items = ITEMS_TO_INSERT_PER_ITERATION * (long long)n_iterations; + total_n_items = items_per_iteration * (long long)n_iterations; } - printf("Serial and random insertions of %d per batch%s\n", ITEMS_TO_INSERT_PER_ITERATION, do_transactions ? " (with transactions)" : ""); + if (!noserial) printf("serial and "); + printf("random insertions of %d per batch%s\n", items_per_iteration, do_transactions ? " (with transactions)" : ""); setup(); gettimeofday(&t1,0); biginsert(total_n_items, &t1);