diff --git a/newbrt/brt.h b/newbrt/brt.h index acc78f4bfaf..93fd20d5d1e 100644 --- a/newbrt/brt.h +++ b/newbrt/brt.h @@ -213,6 +213,8 @@ int toku_brt_zombie_needed (BRT brt); int toku_brt_get_fragmentation(BRT brt, TOKU_DB_FRAGMENTATION report); +double get_tdiff(void) __attribute__((__visibility__("default"))); + //TODO: #1485 once we have multiple main threads, restore this code, analyze performance. #ifndef TOKU_MULTIPLE_MAIN_THREADS #define TOKU_MULTIPLE_MAIN_THREADS 0 diff --git a/newbrt/logger.c b/newbrt/logger.c index 04e5e5cf113..d689a0a3e5d 100644 --- a/newbrt/logger.c +++ b/newbrt/logger.c @@ -582,6 +582,20 @@ void toku_logger_trim_log_files (TOKULOGGER logger, BOOL trim_log_files) logger->trim_log_files = trim_log_files; } +double get_tdiff(void) { + static struct timeval prev={0,0}; + if (prev.tv_sec==0) { + gettimeofday(&prev, 0); + return 0.0; + } else { + struct timeval now; + gettimeofday(&now, 0); + double diff = now.tv_sec - prev.tv_sec + 1e-6*(now.tv_usec - prev.tv_usec); + prev = now; + return diff; + } +} + int toku_logger_maybe_fsync (TOKULOGGER logger, LSN lsn, int do_fsync) // Effect: If fsync is nonzero, then make sure that the log is flushed and synced at least up to lsn. // Entry: Holds input lock. The log entry has already been written to the input buffer. diff --git a/src/export.map b/src/export.map index ea362186206..06ecd78e9ef 100644 --- a/src/export.map +++ b/src/export.map @@ -65,6 +65,9 @@ toku_set_assert_on_write_enospc; test_db_redirect_dictionary; + + get_tdiff; + local: *; }; diff --git a/src/tests/test_groupcommit_count.c b/src/tests/test_groupcommit_count.c index 656f2a77e7e..4d74b898dff 100644 --- a/src/tests/test_groupcommit_count.c +++ b/src/tests/test_groupcommit_count.c @@ -83,8 +83,11 @@ get_fsync_count (void) { static int do_fsync (int fd) { + //fprintf(stderr, "%8.6fs Thread %ld start fsyncing\n", get_tdiff(), pthread_self()); inc_fsync_count(); - return fsync(fd); + int r = fsync(fd); + //fprintf(stderr, "%8.6fs Thread %ld done fsyncing\n", get_tdiff(), pthread_self()); + return r; } static const char *progname;