From 60a83242c9fd9c0fa59894e11d6773865255dec4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 23 Nov 2016 18:16:56 -0500 Subject: [PATCH] rados: add hints to rados bench 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 --- src/common/obj_bencher.cc | 4 +++- src/common/obj_bencher.h | 3 ++- src/tools/rados/rados.cc | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 28520fc11c8..0b0df3a8ddb 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -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; diff --git a/src/common/obj_bencher.h b/src/common/obj_bencher.h index fdc1994d4ee..11909e51d0a 100644 --- a/src/common/obj_bencher.h +++ b/src/common/obj_bencher.h @@ -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) { diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 99a55ba82e2..162f1e35ccb 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -101,7 +101,7 @@ void usage(ostream& out) " rollback roll back object to snap \n" "\n" " listsnaps list the snapshots of this object\n" -" bench write|seq|rand [-t concurrent_operations] [--no-cleanup] [--run-name run_name]\n" +" bench 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)) { -- 2.39.5