]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-replay: Add --dump-perf-counters option
authorAdam Crume <adamcrume@gmail.com>
Wed, 10 Sep 2014 20:30:14 +0000 (13:30 -0700)
committerAdam Crume <adamcrume@gmail.com>
Thu, 11 Sep 2014 23:48:08 +0000 (16:48 -0700)
Signed-off-by: Adam Crume <adamcrume@gmail.com>
doc/man/8/rbd-replay.rst
man/rbd-replay.8
src/rbd_replay/Replayer.cc
src/rbd_replay/Replayer.hpp
src/rbd_replay/rbd-replay.cc

index 55a607f897c78d4aef735cae408f4bdd5a1c1c6e..e590659c8948ade3ab1a2be20d9ec0988040e607 100644 (file)
@@ -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
 ========
index 87cde1388ad996cf1fdbead348a34e6d00e473cd..e50c2fdcd8a7e544bdbc03edc5469e1e699a918d 100644 (file)
@@ -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
index ffd04a919dba4bae60e8dd9d31af21d45bc15e89..19403e51a3d67ccfcb3965b508214d5dc22321c9 100644 (file)
@@ -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<boost::shared_mutex> 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<dependency_d> &deps) {
 
 void Replayer::clear_images() {
   boost::unique_lock<boost::shared_mutex> 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<imagectx_id_t, librbd::Image*> p;
   BOOST_FOREACH(p, m_images) {
     delete p.second;
index 56b4fd7f9467b44b774c6a4efc3fe093c1ff9939..1cbecc2fe7a3ba47bd871d384b02d620ad38b357 100644 (file)
@@ -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<imagectx_id_t, librbd::Image*> m_images;
   boost::shared_mutex m_images_mutex;
index f600ead91767e628d0850a44732eda62a8b1e16b..695053ebacdc9150e8e08a130ed4e9a55a9a4a09 100644 (file)
@@ -42,6 +42,13 @@ static void usage(const char* program) {
   cout << "  --read-only                     Only perform non-destructive operations." << std::endl;
   cout << "  --map-image <rule>              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);
 }