]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: benchmark moves to a dedicated directory
authorLoic Dachary <loic@dachary.org>
Mon, 3 Feb 2014 11:50:20 +0000 (12:50 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 4 Feb 2014 13:17:46 +0000 (14:17 +0100)
Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/Makefile.am
src/test/erasure-code/Makefile.am [new file with mode: 0644]
src/test/erasure-code/ceph_erasure_code_benchmark.cc [new file with mode: 0644]
src/test/erasure-code/ceph_erasure_code_benchmark.h [new file with mode: 0644]
src/test/osd/ceph_erasure_code_benchmark.cc [deleted file]
src/test/osd/ceph_erasure_code_benchmark.h [deleted file]

index 84c9ef93874c7fa537333a83743e84ac8f4d3c66..91af9bc6fca0a098ac3a1853dba0017b76a0f20a 100644 (file)
@@ -1,3 +1,5 @@
+include test/erasure-code/Makefile.am
+
 ## Unknown/other tests
 
 ceph_test_timers_SOURCES = test/TestTimers.cc
@@ -181,15 +183,6 @@ ceph_multi_stress_watch_SOURCES = \
 ceph_multi_stress_watch_LDADD = $(LIBRADOS) $(CEPH_GLOBAL)
 bin_DEBUGPROGRAMS += ceph_multi_stress_watch 
 
-ceph_erasure_code_benchmark_SOURCES = \
-       test/osd/ceph_erasure_code_benchmark.cc
-ceph_erasure_code_benchmark_LDADD = $(LIBOSD) $(LIBCOMMON) $(BOOST_PROGRAM_OPTIONS_LIBS) $(CEPH_GLOBAL)
-if LINUX
-ceph_erasure_code_benchmark_LDADD += -ldl
-endif
-bin_DEBUGPROGRAMS += ceph_erasure_code_benchmark
-
-
 ## System tests
 
 if LINUX
@@ -959,7 +952,6 @@ noinst_HEADERS += \
        test/librados/test.h \
        test/ObjectMap/KeyValueDBMemory.h \
        test/omap_bench.h \
-       test/osd/ceph_erasure_code_benchmark.h \
        test/osdc/FakeWriteback.h \
        test/osd/Object.h \
        test/osd/RadosModel.h \
diff --git a/src/test/erasure-code/Makefile.am b/src/test/erasure-code/Makefile.am
new file mode 100644 (file)
index 0000000..d5e9eac
--- /dev/null
@@ -0,0 +1,10 @@
+ceph_erasure_code_benchmark_SOURCES = \
+       test/erasure-code/ceph_erasure_code_benchmark.cc
+ceph_erasure_code_benchmark_LDADD = $(LIBOSD) $(LIBCOMMON) $(BOOST_PROGRAM_OPTIONS_LIBS) $(CEPH_GLOBAL)
+if LINUX
+ceph_erasure_code_benchmark_LDADD += -ldl
+endif
+bin_DEBUGPROGRAMS += ceph_erasure_code_benchmark
+
+noinst_HEADERS += \
+       test/erasure-code/ceph_erasure_code_benchmark.h
diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.cc b/src/test/erasure-code/ceph_erasure_code_benchmark.cc
new file mode 100644 (file)
index 0000000..b4e02e4
--- /dev/null
@@ -0,0 +1,218 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ *
+ * Author: Loic Dachary <loic@dachary.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <boost/scoped_ptr.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/program_options/option.hpp>
+#include <boost/program_options/options_description.hpp>
+#include <boost/program_options/variables_map.hpp>
+#include <boost/program_options/cmdline.hpp>
+#include <boost/program_options/parsers.hpp>
+#include <boost/algorithm/string.hpp>
+
+#include "ceph_erasure_code_benchmark.h"
+#include "global/global_context.h"
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+#include "common/config.h"
+#include "common/Clock.h"
+#include "include/utime.h"
+#include "osd/ErasureCodePlugin.h"
+
+namespace po = boost::program_options;
+
+int ErasureCodeBench::setup(int argc, char** argv) {
+
+  po::options_description desc("Allowed options");
+  desc.add_options()
+    ("help,h", "produce help message")
+    ("size,s", po::value<int>()->default_value(1024 * 1024),
+     "size of the buffer to be encoded")
+    ("iterations,i", po::value<int>()->default_value(1),
+     "number of encode/decode runs")
+    ("plugin,p", po::value<string>()->default_value("jerasure"),
+     "erasure code plugin name")
+    ("workload,w", po::value<string>()->default_value("encode"),
+     "run either encode or decode")
+    ("erasures,e", po::value<int>()->default_value(1),
+     "number of erasures when decoding")
+    ("parameter,P", po::value<vector<string> >(),
+     "parameters")
+    ;
+
+  po::variables_map vm;
+  po::parsed_options parsed =
+    po::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
+  po::store(
+    parsed,
+    vm);
+  po::notify(vm);
+
+  vector<const char *> ceph_options, def_args;
+  vector<string> ceph_option_strings = po::collect_unrecognized(
+    parsed.options, po::include_positional);
+  ceph_options.reserve(ceph_option_strings.size());
+  for (vector<string>::iterator i = ceph_option_strings.begin();
+       i != ceph_option_strings.end();
+       ++i) {
+    ceph_options.push_back(i->c_str());
+  }
+
+  global_init(
+    &def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
+    CODE_ENVIRONMENT_UTILITY,
+    CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+  common_init_finish(g_ceph_context);
+  g_ceph_context->_conf->apply_changes(NULL);
+
+  if (vm.count("help")) {
+    cout << desc << std::endl;
+    return 1;
+  }
+
+  if (vm.count("parameter")) {
+    const vector<string> &p = vm["parameter"].as< vector<string> >();
+    for (vector<string>::const_iterator i = p.begin();
+        i != p.end();
+        i++) {
+      std::vector<std::string> strs;
+      boost::split(strs, *i, boost::is_any_of("="));
+      if (strs.size() != 2) {
+       cerr << "--parameter " << *i << " ignored because it does not contain exactly one =" << endl;
+      } else {
+       parameters[strs[0]] = strs[1];
+      }
+    }
+  }
+
+  if (parameters.count("erasure-code-directory") == 0)
+    parameters["erasure-code-directory"] = ".libs";
+
+  in_size = vm["size"].as<int>();
+  max_iterations = vm["iterations"].as<int>();
+  plugin = vm["plugin"].as<string>();
+  workload = vm["workload"].as<string>();
+  erasures = vm["erasures"].as<int>();
+
+  return 0;
+}
+
+int ErasureCodeBench::run() {
+  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+  instance.disable_dlclose = true;
+
+  if (workload == "encode")
+    return encode();
+  else
+    return decode();
+}
+
+int ErasureCodeBench::encode()
+{
+  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+  ErasureCodeInterfaceRef erasure_code;
+  int code = instance.factory(plugin, parameters, &erasure_code);
+  if (code)
+    return code;
+  int k = atoi(parameters["erasure-code-k"].c_str());
+  int m = atoi(parameters["erasure-code-m"].c_str());
+
+  bufferlist in;
+  in.append(string(in_size, 'X'));
+  set<int> want_to_encode;
+  for (int i = 0; i < k + m; i++) {
+    want_to_encode.insert(i);
+  }
+  utime_t begin_time = ceph_clock_now(g_ceph_context);
+  for (int i = 0; i < max_iterations; i++) {
+    map<int,bufferlist> encoded;
+    code = erasure_code->encode(want_to_encode, in, &encoded);
+    if (code)
+      return code;
+  }
+  utime_t end_time = ceph_clock_now(g_ceph_context);
+  cout << (end_time - begin_time) << "\t" << (max_iterations * (in_size / 1024)) << endl;
+  return 0;
+}
+
+int ErasureCodeBench::decode()
+{
+  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+  ErasureCodeInterfaceRef erasure_code;
+  int code = instance.factory(plugin, parameters, &erasure_code);
+  if (code)
+    return code;
+  int k = atoi(parameters["erasure-code-k"].c_str());
+  int m = atoi(parameters["erasure-code-m"].c_str());
+
+  bufferlist in;
+  in.append(string(in_size, 'X'));
+
+  set<int> want_to_encode;
+  for (int i = 0; i < k + m; i++) {
+    want_to_encode.insert(i);
+  }
+
+  map<int,bufferlist> encoded;
+  code = erasure_code->encode(want_to_encode, in, &encoded);
+  if (code)
+    return code;
+
+  set<int> want_to_read = want_to_encode;
+
+  utime_t begin_time = ceph_clock_now(g_ceph_context);
+  for (int i = 0; i < max_iterations; i++) {
+    map<int,bufferlist> chunks = encoded;
+    for (int j = 0; j < erasures; j++) {
+      int erasure;
+      do {
+       erasure = rand() % ( k + m );
+      } while(chunks.count(erasure) == 0);
+      chunks.erase(erasure);
+    }
+    map<int,bufferlist> decoded;
+    code = erasure_code->decode(want_to_read, chunks, &decoded);
+    if (code)
+      return code;
+  }
+  utime_t end_time = ceph_clock_now(g_ceph_context);
+  cout << (end_time - begin_time) << "\t" << (max_iterations * (in_size / 1024)) << endl;
+  return 0;
+}
+
+int main(int argc, char** argv) {
+  ErasureCodeBench ecbench;
+  int err = ecbench.setup(argc, argv);
+  if (err)
+    return err;
+  return ecbench.run();
+}
+
+/*
+ * Local Variables:
+ * compile-command: "cd ../.. ; make -j4 &&
+ *   make ceph_erasure_code_benchmark &&
+ *   valgrind --tool=memcheck --leak-check=full \
+ *      ./ceph_erasure_code_benchmark \
+ *      --plugin jerasure \
+ *      --parameter erasure-code-directory=.libs \
+ *      --parameter erasure-code-technique=reed_sol_van \
+ *      --parameter erasure-code-k=2 \
+ *      --parameter erasure-code-m=2 \
+ *      --iterations 1
+ * "
+ * End:
+ */
diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.h b/src/test/erasure-code/ceph_erasure_code_benchmark.h
new file mode 100644 (file)
index 0000000..df73aa7
--- /dev/null
@@ -0,0 +1,38 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ *
+ * Author: Loic Dachary <loic@dachary.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef CEPH_ERASURE_CODE_BENCHMARK_H
+#define CEPH_ERASURE_CODE_BENCHMARK_H
+
+#include <string>
+
+using namespace std;
+
+class ErasureCodeBench {
+  int in_size;
+  int max_iterations;
+  string plugin;
+  int erasures;
+  string workload;
+  map<string,string> parameters;
+public:
+  int setup(int argc, char** argv);
+  int run();
+  int decode();
+  int encode();
+};
+
+#endif
diff --git a/src/test/osd/ceph_erasure_code_benchmark.cc b/src/test/osd/ceph_erasure_code_benchmark.cc
deleted file mode 100644 (file)
index f4fdaf3..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
- *
- * Author: Loic Dachary <loic@dachary.org>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- */
-
-#include <boost/scoped_ptr.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/program_options/option.hpp>
-#include <boost/program_options/options_description.hpp>
-#include <boost/program_options/variables_map.hpp>
-#include <boost/program_options/cmdline.hpp>
-#include <boost/program_options/parsers.hpp>
-#include <boost/algorithm/string.hpp>
-
-#include "test/osd/ceph_erasure_code_benchmark.h"
-#include "global/global_context.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-#include "common/config.h"
-#include "common/Clock.h"
-#include "include/utime.h"
-#include "osd/ErasureCodePlugin.h"
-
-namespace po = boost::program_options;
-
-int ErasureCodeBench::setup(int argc, char** argv) {
-
-  po::options_description desc("Allowed options");
-  desc.add_options()
-    ("help,h", "produce help message")
-    ("size,s", po::value<int>()->default_value(1024 * 1024),
-     "size of the buffer to be encoded")
-    ("iterations,i", po::value<int>()->default_value(1),
-     "number of encode/decode runs")
-    ("plugin,p", po::value<string>()->default_value("jerasure"),
-     "erasure code plugin name")
-    ("workload,w", po::value<string>()->default_value("encode"),
-     "run either encode or decode")
-    ("erasures,e", po::value<int>()->default_value(1),
-     "number of erasures when decoding")
-    ("parameter,P", po::value<vector<string> >(),
-     "parameters")
-    ;
-
-  po::variables_map vm;
-  po::parsed_options parsed =
-    po::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
-  po::store(
-    parsed,
-    vm);
-  po::notify(vm);
-
-  vector<const char *> ceph_options, def_args;
-  vector<string> ceph_option_strings = po::collect_unrecognized(
-    parsed.options, po::include_positional);
-  ceph_options.reserve(ceph_option_strings.size());
-  for (vector<string>::iterator i = ceph_option_strings.begin();
-       i != ceph_option_strings.end();
-       ++i) {
-    ceph_options.push_back(i->c_str());
-  }
-
-  global_init(
-    &def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
-    CODE_ENVIRONMENT_UTILITY,
-    CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-  common_init_finish(g_ceph_context);
-  g_ceph_context->_conf->apply_changes(NULL);
-
-  if (vm.count("help")) {
-    cout << desc << std::endl;
-    return 1;
-  }
-
-  if (vm.count("parameter")) {
-    const vector<string> &p = vm["parameter"].as< vector<string> >();
-    for (vector<string>::const_iterator i = p.begin();
-        i != p.end();
-        i++) {
-      std::vector<std::string> strs;
-      boost::split(strs, *i, boost::is_any_of("="));
-      if (strs.size() != 2) {
-       cerr << "--parameter " << *i << " ignored because it does not contain exactly one =" << endl;
-      } else {
-       parameters[strs[0]] = strs[1];
-      }
-    }
-  }
-
-  if (parameters.count("erasure-code-directory") == 0)
-    parameters["erasure-code-directory"] = ".libs";
-
-  in_size = vm["size"].as<int>();
-  max_iterations = vm["iterations"].as<int>();
-  plugin = vm["plugin"].as<string>();
-  workload = vm["workload"].as<string>();
-  erasures = vm["erasures"].as<int>();
-
-  return 0;
-}
-
-int ErasureCodeBench::run() {
-  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
-  instance.disable_dlclose = true;
-
-  if (workload == "encode")
-    return encode();
-  else
-    return decode();
-}
-
-int ErasureCodeBench::encode()
-{
-  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
-  ErasureCodeInterfaceRef erasure_code;
-  int code = instance.factory(plugin, parameters, &erasure_code);
-  if (code)
-    return code;
-  int k = atoi(parameters["erasure-code-k"].c_str());
-  int m = atoi(parameters["erasure-code-m"].c_str());
-
-  bufferlist in;
-  in.append(string(in_size, 'X'));
-  set<int> want_to_encode;
-  for (int i = 0; i < k + m; i++) {
-    want_to_encode.insert(i);
-  }
-  utime_t begin_time = ceph_clock_now(g_ceph_context);
-  for (int i = 0; i < max_iterations; i++) {
-    map<int,bufferlist> encoded;
-    code = erasure_code->encode(want_to_encode, in, &encoded);
-    if (code)
-      return code;
-  }
-  utime_t end_time = ceph_clock_now(g_ceph_context);
-  cout << (end_time - begin_time) << "\t" << (max_iterations * (in_size / 1024)) << endl;
-  return 0;
-}
-
-int ErasureCodeBench::decode()
-{
-  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
-  ErasureCodeInterfaceRef erasure_code;
-  int code = instance.factory(plugin, parameters, &erasure_code);
-  if (code)
-    return code;
-  int k = atoi(parameters["erasure-code-k"].c_str());
-  int m = atoi(parameters["erasure-code-m"].c_str());
-
-  bufferlist in;
-  in.append(string(in_size, 'X'));
-
-  set<int> want_to_encode;
-  for (int i = 0; i < k + m; i++) {
-    want_to_encode.insert(i);
-  }
-
-  map<int,bufferlist> encoded;
-  code = erasure_code->encode(want_to_encode, in, &encoded);
-  if (code)
-    return code;
-
-  set<int> want_to_read = want_to_encode;
-
-  utime_t begin_time = ceph_clock_now(g_ceph_context);
-  for (int i = 0; i < max_iterations; i++) {
-    map<int,bufferlist> chunks = encoded;
-    for (int j = 0; j < erasures; j++) {
-      int erasure;
-      do {
-       erasure = rand() % ( k + m );
-      } while(chunks.count(erasure) == 0);
-      chunks.erase(erasure);
-    }
-    map<int,bufferlist> decoded;
-    code = erasure_code->decode(want_to_read, chunks, &decoded);
-    if (code)
-      return code;
-  }
-  utime_t end_time = ceph_clock_now(g_ceph_context);
-  cout << (end_time - begin_time) << "\t" << (max_iterations * (in_size / 1024)) << endl;
-  return 0;
-}
-
-int main(int argc, char** argv) {
-  ErasureCodeBench ecbench;
-  int err = ecbench.setup(argc, argv);
-  if (err)
-    return err;
-  return ecbench.run();
-}
-
-/*
- * Local Variables:
- * compile-command: "cd ../.. ; make -j4 &&
- *   make ceph_erasure_code_benchmark &&
- *   valgrind --tool=memcheck --leak-check=full \
- *      ./ceph_erasure_code_benchmark \
- *      --plugin jerasure \
- *      --parameter erasure-code-directory=.libs \
- *      --parameter erasure-code-technique=reed_sol_van \
- *      --parameter erasure-code-k=2 \
- *      --parameter erasure-code-m=2 \
- *      --iterations 1
- * "
- * End:
- */
diff --git a/src/test/osd/ceph_erasure_code_benchmark.h b/src/test/osd/ceph_erasure_code_benchmark.h
deleted file mode 100644 (file)
index 8ea60f9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
- *
- * Author: Loic Dachary <loic@dachary.org>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- */
-
-#ifndef CEPH_ERASURE_CODE_BENCHMARK_H
-#define CEPH_ERASURE_CODE_BENCHMARK_H
-
-#include <string>
-
-using namespace std;
-
-class ErasureCodeBench {
-  int in_size;
-  int max_iterations;
-  string plugin;
-  int erasures;
-  string workload;
-  map<string,string> parameters;
-public:
-  int setup(int argc, char** argv);
-  int run();
-  int decode();
-  int encode();
-};
-
-#endif