diff options
author | Samuel Just <sam.just@inktank.com> | 2013-06-05 12:27:56 -0700 |
---|---|---|
committer | Samuel Just <sam.just@inktank.com> | 2013-06-06 11:51:04 -0700 |
commit | 02154a24101eeb9bbcb76e6bb17034bb587021ac (patch) | |
tree | 3431bf90675cd5de8438a7e6a8f30d6e60e0704b /src/common/obj_bencher.cc | |
parent | 6f78b6e039ddd475b0317f121a3e0cac407333df (diff) | |
download | ceph-wip_bench_num.tar.gz |
rados: --num-objects will now cause bench to stop after that many objectswip_bench_num
Signed-off-by: Samuel Just <sam.just@inktank.com>
Diffstat (limited to 'src/common/obj_bencher.cc')
-rw-r--r-- | src/common/obj_bencher.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 7444d687c8e..6490b4f5932 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -164,7 +164,10 @@ void *ObjBencher::status_printer(void *_bencher) { 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]; @@ -203,7 +206,7 @@ int ObjBencher::aio_bench(int operation, int secondsToRun, int concurrentios, in 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) { @@ -296,10 +299,15 @@ int ObjBencher::fetch_bench_metadata(const std::string& metadata_file, int* obje 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(); @@ -356,8 +364,9 @@ int ObjBencher::write_bench(int secondsToRun, int concurrentios) { 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; @@ -410,15 +419,15 @@ int ObjBencher::write_bench(int secondsToRun, int concurrentios) { 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; |