From: Adam Crume Date: Wed, 10 Sep 2014 20:30:14 +0000 (-0700) Subject: rbd-replay: Add --dump-perf-counters option X-Git-Tag: v0.88~176^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8d23e8dbdcc47e23fca66c1c6b6449d679f713fa;p=ceph.git rbd-replay: Add --dump-perf-counters option Signed-off-by: Adam Crume --- diff --git a/doc/man/8/rbd-replay.rst b/doc/man/8/rbd-replay.rst index 55a607f897c7..e590659c8948 100644 --- a/doc/man/8/rbd-replay.rst +++ b/doc/man/8/rbd-replay.rst @@ -41,6 +41,14 @@ Options Add a rule to map image names in the trace to image names in the replay cluster. A rule of image1@snap1=image2@snap2 would map snap1 of image1 to snap2 of image2. +.. option:: --dump-perf-counters + + **Experimental** + Dump performance counters to standard out before an image is closed. + Performance counters may be dumped multiple times if multiple images are closed, + or if the same image is opened and closed multiple times. + Performance counters and their meaning may change between versions. + Examples ======== diff --git a/man/rbd-replay.8 b/man/rbd-replay.8 index 87cde1388ad9..e50c2fdcd8a7 100644 --- a/man/rbd-replay.8 +++ b/man/rbd-replay.8 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "RBD-REPLAY" "8" "August 07, 2014" "dev" "Ceph" +.TH "RBD-REPLAY" "8" "September 10, 2014" "dev" "Ceph" .SH NAME rbd-replay \- replay rados block device (RBD) workloads . @@ -93,6 +93,15 @@ Only replay non\-destructive requests. Add a rule to map image names in the trace to image names in the replay cluster. A rule of image1@snap1=image2@snap2 would map snap1 of image1 to snap2 of image2. .UNINDENT +.INDENT 0.0 +.TP +.B \-\-dump\-perf\-counters +\fBExperimental\fP +Dump performance counters to standard out before an image is closed. +Performance counters may be dumped multiple times if multiple images are closed, +or if the same image is opened and closed multiple times. +Performance counters and their meaning may change between versions. +.UNINDENT .SH EXAMPLES .sp To replay workload1 as fast as possible: @@ -124,7 +133,7 @@ rbd\-replay \-\-map\-image=prod_image=test_image workload1 the Ceph documentation at \fI\%http://ceph.com/docs\fP for more information. .SH SEE ALSO .sp -\fBceph\fP(8), +\fBrbd\-replay\-prep\fP(8), \fBrbd\fP(8) .SH COPYRIGHT 2010-2014, Inktank Storage, Inc. and contributors. Licensed under Creative Commons BY-SA diff --git a/src/rbd_replay/Replayer.cc b/src/rbd_replay/Replayer.cc index ffd04a919dba..19403e51a3d6 100644 --- a/src/rbd_replay/Replayer.cc +++ b/src/rbd_replay/Replayer.cc @@ -226,7 +226,18 @@ void Replayer::put_image(imagectx_id_t imagectx_id, librbd::Image *image) { void Replayer::erase_image(imagectx_id_t imagectx_id) { boost::unique_lock lock(m_images_mutex); - delete m_images[imagectx_id]; + librbd::Image* image = m_images[imagectx_id]; + if (m_dump_perf_counters) { + string command = "perf dump"; + cmdmap_t cmdmap; + string format = "json-pretty"; + bufferlist out; + g_ceph_context->do_command(command, cmdmap, format, &out); + out.write_stream(cout); + cout << std::endl; + cout.flush(); + } + delete image; m_images.erase(imagectx_id); } @@ -281,6 +292,16 @@ void Replayer::wait_for_actions(const vector &deps) { void Replayer::clear_images() { boost::unique_lock lock(m_images_mutex); + if (m_dump_perf_counters && !m_images.empty()) { + string command = "perf dump"; + cmdmap_t cmdmap; + string format = "json-pretty"; + bufferlist out; + g_ceph_context->do_command(command, cmdmap, format, &out); + out.write_stream(cout); + cout << std::endl; + cout.flush(); + } pair p; BOOST_FOREACH(p, m_images) { delete p.second; diff --git a/src/rbd_replay/Replayer.hpp b/src/rbd_replay/Replayer.hpp index 56b4fd7f9467..1cbecc2fe7a3 100644 --- a/src/rbd_replay/Replayer.hpp +++ b/src/rbd_replay/Replayer.hpp @@ -113,6 +113,10 @@ public: m_image_name_map = map; } + void set_dump_perf_counters(bool dump_perf_counters) { + m_dump_perf_counters = dump_perf_counters; + } + const ImageNameMap &image_name_map() const { return m_image_name_map; } @@ -139,6 +143,7 @@ private: float m_latency_multiplier; bool m_readonly; ImageNameMap m_image_name_map; + bool m_dump_perf_counters; std::map m_images; boost::shared_mutex m_images_mutex; diff --git a/src/rbd_replay/rbd-replay.cc b/src/rbd_replay/rbd-replay.cc index f600ead91767..695053ebacdc 100644 --- a/src/rbd_replay/rbd-replay.cc +++ b/src/rbd_replay/rbd-replay.cc @@ -42,6 +42,13 @@ static void usage(const char* program) { cout << " --read-only Only perform non-destructive operations." << std::endl; cout << " --map-image Add a rule to map image names in the trace to" << std::endl; cout << " image names in the replay cluster." << std::endl; + cout << " --dump-perf-counters *Experimental*" << std::endl; + cout << " Dump performance counters to standard out before" << std::endl; + cout << " an image is closed. Performance counters may be dumped" << std::endl; + cout << " multiple times if multiple images are closed, or if" << std::endl; + cout << " the same image is opened and closed multiple times." << std::endl; + cout << " Performance counters and their meaning may change between" << std::endl; + cout << " versions." << std::endl; cout << std::endl; cout << "Image mapping rules:" << std::endl; cout << "A rule of image1@snap1=image2@snap2 would map snap1 of image1 to snap2 of" << std::endl; @@ -62,6 +69,7 @@ int main(int argc, const char **argv) { ImageNameMap image_name_map; std::string val; std::ostringstream err; + bool dump_perf_counters = false; for (i = args.begin(); i != args.end(); ) { if (ceph_argparse_double_dash(args, i)) { break; @@ -86,6 +94,8 @@ int main(int argc, const char **argv) { } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) { usage(argv[0]); return 0; + } else if (ceph_argparse_flag(args, i, "--dump-perf-counters", (char*)NULL)) { + dump_perf_counters = true; } else if (get_remainder(*i, "-")) { cerr << "Unrecognized argument: " << *i << std::endl; return 1; @@ -112,5 +122,6 @@ int main(int argc, const char **argv) { replayer.set_pool_name(pool_name); replayer.set_readonly(readonly); replayer.set_image_name_map(image_name_map); + replayer.set_dump_perf_counters(dump_perf_counters); replayer.run(replay_file); }