Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add --no-verify option to rados bench #4728

Merged
merged 1 commit into from
May 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 42 additions & 25 deletions src/common/obj_bencher.cc
Expand Up @@ -169,7 +169,7 @@ void *ObjBencher::status_printer(void *_bencher) {

int ObjBencher::aio_bench(
int operation, int secondsToRun,
int concurrentios, int object_size, bool cleanup, const char* run_name) {
int concurrentios, int object_size, bool cleanup, const char* run_name, bool no_verify) {

if (concurrentios <= 0)
return -EINVAL;
Expand Down Expand Up @@ -214,11 +214,11 @@ int ObjBencher::aio_bench(
if (r != 0) goto out;
}
else if (OP_SEQ_READ == operation) {
r = seq_read_bench(secondsToRun, num_objects, concurrentios, prevPid);
r = seq_read_bench(secondsToRun, num_objects, concurrentios, prevPid, no_verify);
if (r != 0) goto out;
}
else if (OP_RAND_READ == operation) {
r = rand_read_bench(secondsToRun, num_objects, concurrentios, prevPid);
r = rand_read_bench(secondsToRun, num_objects, concurrentios, prevPid, no_verify);
if (r != 0) goto out;
}

Expand Down Expand Up @@ -501,7 +501,7 @@ int ObjBencher::write_bench(int secondsToRun,
return r;
}

int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid) {
int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid, bool no_verify) {
lock_cond lc(&lock);

if (concurrentios <= 0)
Expand Down Expand Up @@ -617,12 +617,17 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
lock.Lock();
++data.started;
++data.in_flight;
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", current_index);
lock.Unlock();
if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
if (!no_verify) {
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", current_index);
lock.Unlock();
if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
}
} else {
lock.Unlock();
}

name[slot] = newName;
delete cur_contents;
}
Expand All @@ -646,11 +651,15 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
data.avg_latency = total_latency / data.finished;
--data.in_flight;
release_completion(slot);
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", index[slot]);
lock.Unlock();
if (memcmp(data.object_contents, contents[slot]->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
if (!no_verify) {
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", index[slot]);
lock.Unlock();
if (memcmp(data.object_contents, contents[slot]->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
}
} else {
lock.Unlock();
}
delete contents[slot];
}
Expand Down Expand Up @@ -690,7 +699,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
return r;
}

int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid)
int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid, bool no_verify)
{
lock_cond lc(&lock);

Expand Down Expand Up @@ -810,11 +819,15 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
lock.Lock();
++data.started;
++data.in_flight;
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", current_index);
lock.Unlock();
if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
if (!no_verify) {
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", current_index);
lock.Unlock();
if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
}
} else {
lock.Unlock();
}
name[slot] = newName;
delete cur_contents;
Expand All @@ -839,11 +852,15 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
data.avg_latency = total_latency / data.finished;
--data.in_flight;
release_completion(slot);
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", index[slot]);
lock.Unlock();
if (memcmp(data.object_contents, contents[slot]->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
if (!no_verify) {
snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", index[slot]);
lock.Unlock();
if (memcmp(data.object_contents, contents[slot]->c_str(), data.object_size) != 0) {
cerr << name[slot] << " is not correct!" << std::endl;
++errors;
}
} else {
lock.Unlock();
}
delete contents[slot];
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/obj_bencher.h
Expand Up @@ -67,8 +67,8 @@ class ObjBencher {
int fetch_bench_metadata(const std::string& metadata_file, int* object_size, int* num_objects, int* prevPid);

int write_bench(int secondsToRun, int concurrentios, const string& run_name_meta);
int seq_read_bench(int secondsToRun, int num_objects, int concurrentios, int writePid);
int rand_read_bench(int secondsToRun, int num_objects, int concurrentios, int writePid);
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);

int clean_up(int num_objects, int prevPid, int concurrentios);
int clean_up_slow(const std::string& prefix, int concurrentios);
Expand Down Expand Up @@ -100,7 +100,7 @@ class ObjBencher {
virtual ~ObjBencher() {}
int aio_bench(
int operation, int secondsToRun,
int concurrentios, int op_size, bool cleanup, const char* run_name);
int concurrentios, int op_size, bool cleanup, const char* run_name, bool no_verify=false);
int clean_up(const char* prefix, int concurrentios, const char* run_name);

void set_show_time(bool dt) {
Expand Down
11 changes: 10 additions & 1 deletion src/tools/rados/rados.cc
Expand Up @@ -185,6 +185,8 @@ void usage(ostream& out)
" Set number of concurrent I/O operations\n"
" --show-time\n"
" prefix output with date/time\n"
" --no-verify\n"
" do not verify contents of read objects\n"
"\n"
"LOAD GEN OPTIONS:\n"
" --num-objects total number of objects\n"
Expand Down Expand Up @@ -1144,6 +1146,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
unsigned op_size = default_op_size;
bool block_size_specified = false;
bool cleanup = true;
bool no_verify = false;
const char *snapname = NULL;
snap_t snapid = CEPH_NOSNAP;
std::map<std::string, std::string>::const_iterator i;
Expand Down Expand Up @@ -1314,6 +1317,10 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
if (i != opts.end()) {
nspace = i->second;
}
i = opts.find("no-verify");
if (i != opts.end()) {
no_verify = true;
}


// open rados
Expand Down Expand Up @@ -2281,7 +2288,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
RadosBencher bencher(g_ceph_context, rados, io_ctx);
bencher.set_show_time(show_time);
ret = bencher.aio_bench(operation, seconds,
concurrent_ios, op_size, cleanup, run_name);
concurrent_ios, op_size, cleanup, run_name, no_verify);
if (ret != 0)
cerr << "error during benchmark: " << ret << std::endl;
}
Expand Down Expand Up @@ -2660,6 +2667,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-verify", (char*)NULL)) {
opts["no-verify"] = "true";
} else if (ceph_argparse_witharg(args, i, &val, "--run-name", (char*)NULL)) {
opts["run-name"] = val;
} else if (ceph_argparse_witharg(args, i, &val, "--prefix", (char*)NULL)) {
Expand Down