From d753226b76e28839ce94a3ff44bb85ed8cc7e0e8 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 25 Mar 2019 18:59:03 +0300 Subject: [PATCH] Fix segfault somewhere inside C++ with multiple threads, fix stats --- main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 29b5220..7c27769 100644 --- a/main.cpp +++ b/main.cpp @@ -91,14 +91,14 @@ static void print_breakdown(const vector &all_ops, size_t thread_count) cout << " cnt=" << count << endl; } - cout << "Average iops: " << (all_ops.size() / dur2sec(totaltime)) << endl; + cout << "Average iops: " << (all_ops.size() * thread_count / dur2sec(totaltime)) << endl; cout << "Average latency: " << (dur2msec(totaltime) / all_ops.size()) << " ms" << endl; cout << "Total writes: " << all_ops.size() << endl; if (thread_count > 1) - cout << "iops per thread: " << (all_ops.size() / thread_count / dur2sec(totaltime)) << endl; + cout << "iops per thread: " << (all_ops.size() / dur2sec(totaltime)) << endl; } static void fill_urandom(char *buf, size_t len) @@ -167,7 +167,10 @@ static void do_bench(const unique_ptr &settings, const vectorthreads; i++) { listofops.push_back(vector()); + } + for (int i = 0; i < settings->threads; i++) + { sigset_t new_set; sigset_t old_set; sigfillset(&new_set); @@ -177,7 +180,7 @@ static void do_bench(const unique_ptr &settings, const vector(names.begin()+i*16, names.begin()+i*16+16), ref(ioctx), ref(listofops.back()))); + threads.push_back(thread(_do_bench, ref(settings), vector(names.begin()+i*16, names.begin()+i*16+16), ref(ioctx), ref(listofops[i]))); if ((err = pthread_sigmask(SIG_SETMASK, &old_set, NULL))) {