int ObjBencher::aio_bench(
int operation, int secondsToRun,
int concurrentios, size_t op_size, size_t object_size,
+ unsigned max_objects,
bool cleanup, const std::string& run_name, bool no_verify) {
- if (concurrentios <= 0)
+ if (concurrentios <= 0)
return -EINVAL;
int num_objects = 0;
//get data from previous write run, if available
if (operation != OP_WRITE) {
- r = fetch_bench_metadata(run_name_meta, &op_size, &object_size, &num_objects, &prevPid);
+ size_t prev_op_size, prev_object_size;
+ r = fetch_bench_metadata(run_name_meta, &prev_op_size, &prev_object_size,
+ &num_objects, &prevPid);
if (r < 0) {
if (r == -ENOENT)
cerr << "Must write data before running a read benchmark!" << std::endl;
formatter->open_object_section("bench");
if (OP_WRITE == operation) {
- r = write_bench(secondsToRun, concurrentios, run_name_meta);
+ r = write_bench(secondsToRun, concurrentios, run_name_meta, max_objects);
if (r != 0) goto out;
}
else if (OP_SEQ_READ == operation) {
}
int ObjBencher::write_bench(int secondsToRun,
- int concurrentios, const string& run_name_meta) {
+ int concurrentios, const string& run_name_meta,
+ unsigned max_objects) {
if (concurrentios <= 0)
return -EINVAL;
out(cout) << "Maintaining " << concurrentios << " concurrent writes of "
<< data.op_size << " bytes to objects of size "
<< data.object_size << " for up to "
- << secondsToRun << " seconds"
+ << secondsToRun << " seconds or "
+ << max_objects << " objects"
<< std::endl;
} else {
formatter->dump_format("concurrent_ios", "%d", concurrentios);
formatter->dump_format("object_size", "%d", data.object_size);
formatter->dump_format("op_size", "%d", data.op_size);
formatter->dump_format("seconds_to_run", "%d", secondsToRun);
+ formatter->dump_format("max_objects", "%d", max_objects);
}
bufferlist* newContents = 0;
stopTime = data.start_time + runtime;
slot = 0;
lock.Lock();
- while(ceph_clock_now(cct) < stopTime) {
+ while (!secondsToRun || ceph_clock_now(cct) < stopTime) {
bool found = false;
while (1) {
int old_slot = slot;
lock.Lock();
++data.started;
++data.in_flight;
+ if (max_objects &&
+ data.started > (data.object_size * max_objects + data.op_size - 1) /
+ data.op_size)
+ break;
}
lock.Unlock();
bufferlist *cur_contents;
slot = 0;
- while (seconds_to_run && (ceph_clock_now(cct) < finish_time) &&
- num_objects > data.started) {
+ while ((!seconds_to_run || ceph_clock_now(cct) < finish_time) &&
+ num_objects > data.started) {
lock.Lock();
int old_slot = slot;
bool found = false;
int rand_id;
slot = 0;
- while (seconds_to_run && (ceph_clock_now(g_ceph_context) < finish_time)) {
+ while ((!seconds_to_run || ceph_clock_now(g_ceph_context) < finish_time)) {
lock.Lock();
int old_slot = slot;
bool found = false;
int fetch_bench_metadata(const std::string& metadata_file, size_t* op_size,
size_t* object_size, int* num_objects, int* prevPid);
- int write_bench(int secondsToRun, int concurrentios, const string& run_name_meta);
+ int write_bench(int secondsToRun, int concurrentios, const string& run_name_meta, unsigned max_objects);
int seq_read_bench(int secondsToRun, int num_objects, int concurrentios, int writePid, bool no_verify=false);
int rand_read_bench(int secondsToRun, int num_objects, int concurrentios, int writePid, bool no_verify=false);
virtual ~ObjBencher() {}
int aio_bench(
int operation, int secondsToRun,
- int concurrentios, size_t op_size, size_t object_size,
+ int concurrentios, size_t op_size, size_t object_size, unsigned max_objects,
bool cleanup, const std::string& run_name, bool no_verify=false);
int clean_up(const std::string& prefix, int concurrentios, const std::string& run_name);
" set the block size for put/get ops and for write benchmarking\n"
" -o object_size\n"
" set the object size for put/get ops and for write benchmarking\n"
+" --max-objects\n"
+" set the max number of objects for write benchmarking\n"
" -s name\n"
" --snap name\n"
" select given snap name for (read) IO\n"
int concurrent_ios = 16;
unsigned op_size = default_op_size;
unsigned object_size = 0;
+ unsigned max_objects = 0;
bool block_size_specified = false;
int bench_write_dest = 0;
bool cleanup = true;
}
block_size_specified = true;
}
+ i = opts.find("max-objects");
+ if (i != opts.end()) {
+ if (rados_sistrtoll(i, &max_objects)) {
+ return -EINVAL;
+ }
+ }
i = opts.find("snap");
if (i != opts.end()) {
snapname = i->second.c_str();
object_size = op_size;
ret = bencher.aio_bench(operation, seconds,
concurrent_ios, op_size, object_size,
- cleanup, run_name, no_verify);
+ max_objects, cleanup, run_name, no_verify);
if (ret != 0)
cerr << "error during benchmark: " << ret << std::endl;
if (formatter && output)
opts["block-size"] = val;
} else if (ceph_argparse_witharg(args, i, &val, "--object-size", (char*)NULL)) {
opts["object-size"] = val;
+ } else if (ceph_argparse_witharg(args, i, &val, "--max-objects", (char*)NULL)) {
+ opts["max-objects"] = val;
} else if (ceph_argparse_witharg(args, i, &val, "-o", (char*)NULL)) {
opts["object-size"] = val;
} else if (ceph_argparse_witharg(args, i, &val, "-s", "--snap", (char*)NULL)) {