From: Jason Dillaman Date: Sun, 7 Sep 2014 04:50:55 +0000 (-0400) Subject: rbd: Use a rolling average to compute RBD write throughput X-Git-Tag: v0.88~165 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b47fdd400e14bd1b5e5bea9d18f895c92b8050be;p=ceph.git rbd: Use a rolling average to compute RBD write throughput Replace the cumulative average with a rolling average to better expose variations within IOS/sec and bytes/sec. Fixes: #9374 Signed-off-by: Jason Dillaman Reviewed-by: Josh Durgin --- diff --git a/src/rbd.cc b/src/rbd.cc index 661af01800d..01e8a86843e 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -29,6 +29,9 @@ #include "include/compat.h" #include "common/blkdev.h" +#include +#include +#include #include #include #include @@ -924,6 +927,20 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, thread_offset.push_back(start_pos); } + const int WINDOW_SIZE = 5; + typedef boost::accumulators::accumulator_set< + double, boost::accumulators::stats< + boost::accumulators::tag::rolling_sum> > RollingSum; + + RollingSum time_acc( + boost::accumulators::tag::rolling_window::window_size = WINDOW_SIZE); + RollingSum ios_acc( + boost::accumulators::tag::rolling_window::window_size = WINDOW_SIZE); + RollingSum off_acc( + boost::accumulators::tag::rolling_window::window_size = WINDOW_SIZE); + uint64_t cur_ios = 0; + uint64_t cur_off = 0; + printf(" SEC OPS OPS/SEC BYTES/SEC\n"); uint64_t off; for (off = 0; off < io_bytes; ) { @@ -935,6 +952,9 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, ++ios; off += io_size; + ++cur_ios; + cur_off += io_size; + if (pattern == "rand") { thread_offset[i] = (rand() % (size / io_size)) * io_size; } else { @@ -946,12 +966,21 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, utime_t now = ceph_clock_now(NULL); utime_t elapsed = now - start; - if (elapsed.sec() != last.sec()) { + if (last.is_zero()) { + last = elapsed; + } else if (elapsed.sec() != last.sec()) { + time_acc(elapsed - last); + ios_acc(static_cast(cur_ios)); + off_acc(static_cast(cur_off)); + cur_ios = 0; + cur_off = 0; + + double time_sum = boost::accumulators::rolling_sum(time_acc); printf("%5d %8d %8.2lf %8.2lf\n", - (int)elapsed, - (int)(ios - io_threads), - (double)(ios - io_threads) / elapsed, - (double)(off - io_threads * io_size) / elapsed); + (int)elapsed, + (int)(ios - io_threads), + boost::accumulators::rolling_sum(ios_acc) / time_sum, + boost::accumulators::rolling_sum(off_acc) / time_sum); last = elapsed; } }