return NULL;
}
-int ObjBencher::aio_bench(int operation, int secondsToRun, int concurrentios, int op_size, bool cleanup) {
+int ObjBencher::aio_bench(
+ int operation, int secondsToRun,
+ int maxObjectsToCreate,
+ int concurrentios, int op_size, bool cleanup) {
int object_size = op_size;
int num_objects = 0;
char* contentsChars = new char[op_size];
sanitize_object_contents(&data, data.object_size);
if (OP_WRITE == operation) {
- r = write_bench(secondsToRun, concurrentios);
+ r = write_bench(secondsToRun, maxObjectsToCreate, concurrentios);
if (r != 0) goto out;
}
else if (OP_SEQ_READ == operation) {
return 0;
}
-int ObjBencher::write_bench(int secondsToRun, int concurrentios) {
+int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate,
+ int concurrentios) {
+ if (maxObjectsToCreate > 0 && concurrentios > maxObjectsToCreate)
+ concurrentios = maxObjectsToCreate;
out(cout) << "Maintaining " << concurrentios << " concurrent writes of "
- << data.object_size << " bytes for at least "
- << secondsToRun << " seconds." << std::endl;
+ << data.object_size << " bytes for up to "
+ << secondsToRun << " seconds or "
+ << maxObjectsToCreate << " objects"
+ << std::endl;
bufferlist* newContents = 0;
std::string prefix = generate_object_prefix();
runtime.set_from_double(secondsToRun);
stopTime = data.start_time + runtime;
slot = 0;
- while( ceph_clock_now(g_ceph_context) < stopTime ) {
- lock.Lock();
+ lock.Lock();
+ while( ceph_clock_now(g_ceph_context) < stopTime &&
+ (!maxObjectsToCreate || data.started < maxObjectsToCreate)) {
bool found = false;
while (1) {
int old_slot = slot;
if (r < 0) {//naughty; doesn't clean up heap space.
goto ERR;
}
- lock.Lock();
- ++data.started;
- ++data.in_flight;
- lock.Unlock();
delete contents[slot];
name[slot] = newName;
contents[slot] = newContents;
newContents = 0;
+ lock.Lock();
+ ++data.started;
+ ++data.in_flight;
}
+ lock.Unlock();
while (data.finished < data.started) {
slot = data.finished % concurrentios;
int fetch_bench_metadata(const std::string& metadata_file, int* object_size, int* num_objects, int* prevPid);
- int write_bench(int secondsToRun, int concurrentios);
+ int write_bench(int secondsToRun, int maxObjects, int concurrentios);
int seq_read_bench(int secondsToRun, int concurrentios, int num_objects, int writePid);
int clean_up(int num_objects, int prevPid, int concurrentios);
public:
ObjBencher() : show_time(false), lock("ObjBencher::lock") {}
virtual ~ObjBencher() {}
- int aio_bench(int operation, int secondsToRun, int concurrentios, int op_size, bool cleanup);
+ int aio_bench(
+ int operation, int secondsToRun, int maxObjectsToCreate,
+ int concurrentios, int op_size, bool cleanup);
int clean_up(const std::string& prefix, int concurrentios);
void set_show_time(bool dt) {
usage_exit();
RadosBencher bencher(rados, io_ctx);
bencher.set_show_time(show_time);
- ret = bencher.aio_bench(operation, seconds, concurrent_ios, op_size, cleanup);
+ ret = bencher.aio_bench(operation, seconds, num_objs,
+ concurrent_ios, op_size, cleanup);
if (ret != 0)
cerr << "error during benchmark: " << ret << std::endl;
}
if (ret != 0)
cerr << "error during cleanup: " << ret << std::endl;
} else {
- ret = bencher.aio_bench(operation, seconds, concurrent_ios, op_size, cleanup);
+ ret = bencher.aio_bench(operation, seconds, 0,
+ concurrent_ios, op_size, cleanup);
if (ret != 0) {
cerr << "error during benchmark: " << ret << std::endl;
}