if (concurrentios <= 0)
return -EINVAL;
+ int num_ops = 0;
int num_objects = 0;
int r = 0;
int prev_pid = 0;
if (operation != OP_WRITE || reuse_bench) {
uint64_t prev_op_size, prev_object_size;
r = fetch_bench_metadata(run_name_meta, &prev_op_size, &prev_object_size,
- &num_objects, &prev_pid);
+ &num_ops, &num_objects, &prev_pid);
if (r < 0) {
if (r == -ENOENT) {
if (reuse_bench)
if (r != 0) goto out;
}
else if (OP_SEQ_READ == operation) {
- r = seq_read_bench(secondsToRun, num_objects, concurrentios, prev_pid, no_verify);
+ r = seq_read_bench(secondsToRun, num_ops, num_objects, concurrentios, prev_pid, no_verify);
if (r != 0) goto out;
}
else if (OP_RAND_READ == operation) {
- r = rand_read_bench(secondsToRun, num_objects, concurrentios, prev_pid, no_verify);
+ r = rand_read_bench(secondsToRun, num_ops, num_objects, concurrentios, prev_pid, no_verify);
if (r != 0) goto out;
}
if (OP_WRITE == operation && cleanup) {
r = fetch_bench_metadata(run_name_meta, &op_size, &object_size,
- &num_objects, &prev_pid);
+ &num_ops, &num_objects, &prev_pid);
if (r < 0) {
if (r == -ENOENT)
cerr << "Should never happen: bench metadata missing for current run!" << std::endl;
int ObjBencher::fetch_bench_metadata(const std::string& metadata_file,
uint64_t *op_size, uint64_t* object_size,
- int* num_objects, int* prevPid) {
+ int* num_ops, int* num_objects, int* prevPid) {
int r = 0;
bufferlist object_data;
}
auto p = object_data.cbegin();
decode(*object_size, p);
- decode(*num_objects, p);
+ decode(*num_ops, p);
decode(*prevPid, p);
if (!p.end()) {
decode(*op_size, p);
} else {
*op_size = *object_size;
}
+ unsigned ops_per_object = 1;
+ // make sure *op_size value is reasonable
+ if (*op_size > 0 && *object_size > *op_size) {
+ ops_per_object = *object_size / *op_size;
+ }
+ *num_objects = (*num_ops + ops_per_object - 1) / ops_per_object;
return 0;
}
//keep on adding new writes as old ones complete until we've passed minimum time
int slot;
- int num_objects;
//don't need locking for reads because other thread doesn't write
}
//write object size/number data for read benchmarks
encode(data.object_size, b_write);
- num_objects = (data.finished + writes_per_object - 1) / writes_per_object;
- encode(num_objects, b_write);
+ encode(data.finished, b_write);
encode(prev_pid ? prev_pid : getpid(), b_write);
encode(data.op_size, b_write);
return r;
}
-int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid, bool no_verify) {
+int ObjBencher::seq_read_bench(
+ int seconds_to_run, int num_ops, int num_objects,
+ int concurrentios, int pid, bool no_verify) {
+
lock_cond lc(&lock);
if (concurrentios <= 0)
slot = 0;
while ((seconds_to_run && mono_clock::now() < finish_time) &&
- num_objects > data.started) {
+ num_ops > data.started) {
locker.lock();
int old_slot = slot;
bool found = false;
return r;
}
-int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid, bool no_verify)
-{
+int ObjBencher::rand_read_bench(
+ int seconds_to_run, int num_ops, int num_objects,
+ int concurrentios, int pid, bool no_verify) {
+
lock_cond lc(&lock);
if (concurrentios <= 0)
}
}
- rand_id = rand() % num_objects;
+ rand_id = rand() % num_ops;
newName = generate_object_name_fast(rand_id / reads_per_object, pid);
index[slot] = rand_id;
release_completion(slot);
int ObjBencher::clean_up(const std::string& orig_prefix, int concurrentios, const std::string& run_name) {
int r = 0;
uint64_t op_size, object_size;
- int num_objects;
+ int num_ops, num_objects;
int prevPid;
// default meta object if user does not specify one
continue;
}
- r = fetch_bench_metadata(run_name_meta, &op_size, &object_size, &num_objects, &prevPid);
+ r = fetch_bench_metadata(run_name_meta, &op_size, &object_size, &num_ops, &num_objects, &prevPid);
if (r < 0) {
return r;
}
struct bench_data data;
int fetch_bench_metadata(const std::string& metadata_file, uint64_t* op_size,
- uint64_t* object_size, int* num_objects, int* prev_pid);
+ uint64_t* object_size, int* num_ops, int* num_objects, int* prev_pid);
int write_bench(int secondsToRun, int concurrentios, const string& run_name_meta, unsigned max_objects, int prev_pid);
- 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 seq_read_bench(int secondsToRun, int num_ops, int num_objects, int concurrentios, int writePid, bool no_verify=false);
+ int rand_read_bench(int secondsToRun, int num_ops, int num_objects, int concurrentios, int writePid, bool no_verify=false);
int clean_up(int num_objects, int prevPid, int concurrentios);
bool more_objects_matching_prefix(const std::string& prefix, std::list<Object>* name);