Commit a3221f86 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

closes #5419 account for actual time slept, not just how long we wanted to...

closes #5419 account for actual time slept, not just how long we wanted to sleep, and set an alarm to make sure it doesn't take too long to end the test


git-svn-id: file:///svn/toku/tokudb@49986 c7de825b-a66e-492c-adef-691d508d4ae1
parent 04b309f8
......@@ -1451,9 +1451,23 @@ static void *test_time(void *arg) {
printf("Sleeping for %d seconds\n", num_seconds);
}
for (int i = 0; i < num_seconds; ) {
struct timeval tv[2];
const int sleeptime = intmin(tte->cli_args->performance_period, num_seconds - i);
int r = gettimeofday(&tv[0], nullptr);
assert_zero(r);
usleep(sleeptime*1000*1000);
r = gettimeofday(&tv[1], nullptr);
assert_zero(r);
int actual_sleeptime = tv[1].tv_sec - tv[0].tv_sec;
if (abs(actual_sleeptime - sleeptime) <= 1) {
// Close enough, no need to alarm the user, and we didn't check nsec.
i += sleeptime;
} else {
if (verbose) {
printf("tried to sleep %d secs, actually slept %d secs\n", sleeptime, actual_sleeptime);
}
i += actual_sleeptime;
}
if (tte->cli_args->print_performance && tte->cli_args->print_iteration_performance) {
perf_formatter->iteration(tte->cli_args, i, last_counter_values, counters, tte->num_wes);
}
......@@ -1519,11 +1533,18 @@ static int run_workers(
void *ret;
r = toku_pthread_join(time_tid, &ret); assert_zero(r);
if (verbose) printf("%lu joined\n", (unsigned long) time_tid);
// Set an alarm that will kill us if it takes too long to join all the
// threads (i.e. there is some runaway thread).
unsigned int remaining = alarm((num_seconds / 10 < 30) ? 30 : num_seconds / 10);
assert_zero(remaining);
for (int i = 0; i < num_threads; ++i) {
r = toku_pthread_join(tids[i], &ret); assert_zero(r);
if (verbose)
printf("%lu joined\n", (unsigned long) tids[i]);
}
// All threads joined, deschedule the alarm.
remaining = alarm(0);
assert(remaining > 0);
if (cli_args->print_performance) {
uint64_t *counters[num_threads];
......@@ -1644,9 +1665,11 @@ static int fill_table_from_fun(DB_ENV *env, DB *db, int num_elements, int key_bu
// the caller can checkpoint if they want.
r = txn->commit(txn, DB_TXN_NOSYNC); CKERR(r);
txn = nullptr;
if (verbose) {
progress_cb(puts_per_txn);
}
}
}
if (txn) {
r = txn->commit(txn, DB_TXN_NOSYNC);
invariant_zero(r);
......@@ -1740,7 +1763,7 @@ static void report_overall_fill_table_progress(int num_rows) {
if (t1 > last_report + minimum_report_period
&& toku_sync_bool_compare_and_swap(&reporting, 0, 1) == 0) {
double inserts_per_sec = (rows_so_far*1000000) / ((t1 - t0) * 1.0);
printf("fill tables: %ldpct complete, %.2lf rows/sec\n",
printf("fill tables: %ld%% complete, %.2lf rows/sec\n",
(long)(progress * 100), inserts_per_sec);
last_progress = progress;
last_report = t1;
......@@ -1832,7 +1855,6 @@ static int open_tables(DB_ENV **env_res, DB **db_res, int num_DBs,
r = env->cleaner_set_iterations(env, env_args.cleaner_iterations); CKERR(r);
*env_res = env;
for (int i = 0; i < num_DBs; i++) {
DB *db;
char name[30];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment