]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rados: add hints to rados bench
authorSage Weil <sage@redhat.com>
Wed, 23 Nov 2016 23:16:56 +0000 (18:16 -0500)
committerSage Weil <sage@redhat.com>
Mon, 28 Nov 2016 14:09:04 +0000 (09:09 -0500)
By default, hint with the rados bench IO size and with sequential read
and write flags.  Unless the --no-hints option is passed.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/obj_bencher.cc
src/common/obj_bencher.h
src/tools/rados/rados.cc

index 28520fc11c8832e13af8ec7191aae1aa3408e8ec..0b0df3a8ddb1869be0c3a1859b56f7eb71fd7a3f 100644 (file)
@@ -221,7 +221,8 @@ int ObjBencher::aio_bench(
   int concurrentios,
   uint64_t op_size, uint64_t object_size,
   unsigned max_objects,
-  bool cleanup, const std::string& run_name, bool no_verify) {
+  bool cleanup, bool hints,
+  const std::string& run_name, bool no_verify) {
 
   if (concurrentios <= 0)
     return -EINVAL;
@@ -251,6 +252,7 @@ int ObjBencher::aio_bench(
   char* contentsChars = new char[op_size];
   lock.Lock();
   data.done = false;
+  data.hints = hints;
   data.object_size = object_size;
   data.op_size = op_size;
   data.in_flight = 0;
index fdc1994d4eebddfcda419b8de2a00b2e97fc2268..11909e51d0ae1e5d4954357b6ac25f7f3fa9938c 100644 (file)
@@ -38,6 +38,7 @@ struct bench_data {
   bool done; //is the benchmark is done
   uint64_t object_size; //the size of the objects
   uint64_t op_size;     // the size of the read/write ops
+  bool hints;
   // same as object_size for write tests
   int in_flight; //number of reads/writes being waited on
   int started;
@@ -110,7 +111,7 @@ public:
   int aio_bench(
     int operation, int secondsToRun,
     int concurrentios, uint64_t op_size, uint64_t object_size, unsigned max_objects,
-    bool cleanup, const std::string& run_name, bool no_verify=false);
+    bool cleanup, bool hints, const std::string& run_name, bool no_verify=false);
   int clean_up(const std::string& prefix, int concurrentios, const std::string& run_name);
 
   void set_show_time(bool dt) {
index 99a55ba82e26a22fd706fd6523dc906c81d45f5b..162f1e35ccbf3334fcb939dc8f6daec3ea349aeb 100644 (file)
@@ -101,7 +101,7 @@ void usage(ostream& out)
 "   rollback <obj-name> <snap-name>  roll back object to snap <snap-name>\n"
 "\n"
 "   listsnaps <obj-name>             list the snapshots of this object\n"
-"   bench <seconds> write|seq|rand [-t concurrent_operations] [--no-cleanup] [--run-name run_name]\n"
+"   bench <seconds> write|seq|rand [-t concurrent_operations] [--no-cleanup] [--run-name run_name] [--no-hints]\n"
 "                                    default is 16 concurrent IOs and 4 MB ops\n"
 "                                    default is to clean up after write benchmark\n"
 "                                    default run-name is 'benchmark_last_metadata'\n"
@@ -924,6 +924,12 @@ protected:
     librados::ObjectWriteOperation op;
 
     if (write_destination & OP_WRITE_DEST_OBJ) {
+      if (data.hints)
+       op.set_alloc_hint2(data.object_size, data.op_size,
+                          ALLOC_HINT_FLAG_SEQUENTIAL_WRITE |
+                          ALLOC_HINT_FLAG_SEQUENTIAL_READ |
+                          ALLOC_HINT_FLAG_APPEND_ONLY |
+                          ALLOC_HINT_FLAG_IMMUTABLE);
       op.write(offset, bl);
     }
 
@@ -1615,6 +1621,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   bool block_size_specified = false;
   int bench_write_dest = 0;
   bool cleanup = true;
+  bool hints = true; // for rados bench
   bool no_verify = false;
   bool use_striper = false;
   bool with_clones = false;
@@ -1788,6 +1795,10 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   if (i != opts.end()) {
     cleanup = false;
   }
+  i = opts.find("no-hints");
+  if (i != opts.end()) {
+    hints = false;
+  }
   i = opts.find("pretty-format");
   if (i != opts.end()) {
     pretty_format = true;
@@ -2999,9 +3010,10 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       object_size = op_size;
     else if (object_size < op_size)
       op_size = object_size;
+    cout << "hints = " << (int)hints << std::endl;
     ret = bencher.aio_bench(operation, seconds,
                            concurrent_ios, op_size, object_size,
-                           max_objects, cleanup, run_name, no_verify);
+                           max_objects, cleanup, hints, run_name, no_verify);
     if (ret != 0)
       cerr << "error during benchmark: " << ret << std::endl;
     if (formatter && output)
@@ -3573,6 +3585,8 @@ int main(int argc, const char **argv)
       opts["show-time"] = "true";
     } else if (ceph_argparse_flag(args, i, "--no-cleanup", (char*)NULL)) {
       opts["no-cleanup"] = "true";
+    } else if (ceph_argparse_flag(args, i, "--no-hints", (char*)NULL)) {
+      opts["no-hints"] = "true";
     } else if (ceph_argparse_flag(args, i, "--no-verify", (char*)NULL)) {
       opts["no-verify"] = "true";
     } else if (ceph_argparse_witharg(args, i, &val, "--run-name", (char*)NULL)) {