From d7a1ada9d39892e1e842a49cf17ef9e6c0fbe69c Mon Sep 17 00:00:00 2001 From: Jacob Leverich Date: Mon, 1 Jul 2013 10:08:16 -0700 Subject: [PATCH] Option to save latency measurements to a file. --- LogHistogramSampler.h | 6 ++++++ cmdline.ggo | 2 +- mutilate.cc | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/LogHistogramSampler.h b/LogHistogramSampler.h index 1fa4301..759d7f3 100644 --- a/LogHistogramSampler.h +++ b/LogHistogramSampler.h @@ -8,6 +8,7 @@ #include +#include "mutilate.h" #include "Operation.h" #define _POW 1.1 @@ -16,6 +17,8 @@ class LogHistogramSampler { public: std::vector bins; + std::vector samples; + double sum; double sum_sq; @@ -28,6 +31,7 @@ public: void sample(const Operation &op) { sample(op.time()); + if (args.save_given) samples.push_back(op); } void sample(double s) { @@ -97,6 +101,8 @@ public: sum += h.sum; sum_sq += h.sum_sq; + + for (auto i: h.samples) samples.push_back(i); } }; diff --git a/cmdline.ggo b/cmdline.ggo index ffe6531..32fd9e7 100644 --- a/cmdline.ggo +++ b/cmdline.ggo @@ -38,7 +38,6 @@ option "depth" d "Maximum depth to pipeline requests." int default="1" option "roundrobin" R "Assign threads to servers in round-robin fashion. \ By default, each thread connects to every server." -option "cork" - "Minimum timer interval, in usecs. (experimental)" int option "iadist" i "Inter-arrival distribution (distribution). Note: \ The distribution will automatically be adjusted to match the QPS given \ by --qps." string default="exponential" @@ -55,6 +54,7 @@ option "no_nodelay" - "Don't use TCP_NODELAY." option "warmup" w "Warmup time before starting measurement." int option "wait" W "Time to wait after startup to start measurement." int +option "save" - "Record latency samples to given file." string option "search" - "Search for the QPS where N-order statistic < Xus. \ (i.e. --search 95:1000 means find the QPS where 95% of requests are \ diff --git a/mutilate.cc b/mutilate.cc index 00d6aa7..c6e188e 100644 --- a/mutilate.cc +++ b/mutilate.cc @@ -610,6 +610,18 @@ int main(int argc, char **argv) { printf("TX %10" PRIu64 " bytes : %6.1f MB/s\n", stats.tx_bytes, (double) stats.tx_bytes / 1024 / 1024 / (stats.stop - stats.start)); + + if (args.save_given) { + printf("Saving latency samples to %s.\n", args.save_arg); + + FILE *file; + if ((file = fopen(args.save_arg, "w")) == NULL) + DIE("--save: failed to open %s: %s", args.save_arg, strerror(errno)); + + for (auto i: stats.get_sampler.samples) { + fprintf(file, "%f %f\n", i.start_time - boot_time, i.time()); + } + } } // if (args.threads_arg > 1) @@ -963,6 +975,9 @@ void do_mutilate(const vector& servers, options_t& options, } #endif + if (master && !args.scan_given && !args.search_given) + V("started at %f", get_time()); + start = get_time(); for (Connection *conn: connections) { conn->start_time = start; @@ -992,6 +1007,9 @@ void do_mutilate(const vector& servers, options_t& options, else break; } + if (master && !args.scan_given && !args.search_given) + V("stopped at %f options.time = %d", get_time(), options.time); + // Tear-down and accumulate stats. for (Connection *conn: connections) { stats.accumulate(conn->stats);