From: Yehuda Sadeh Date: Thu, 26 Apr 2012 21:35:39 +0000 (-0700) Subject: obj_bencher: use better round robin for completion slot scan X-Git-Tag: v0.47~23^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76a5c8993d517acaaf17b9fb8b5bf72feadbdf59;p=ceph.git obj_bencher: use better round robin for completion slot scan Start where left last time, don't start from zero. Signed-off-by: Yehuda Sadeh --- diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 2fce89cfdefb..1af651a28dae 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -241,17 +241,24 @@ 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(); + bool found = false; while (1) { - for (slot = 0; slot < concurrentios; ++slot) { + int old_slot = slot; + do { if (completion_is_done(slot)) { + found = true; break; } - } - if (slot < concurrentios) { - break; - } + slot++; + if (slot == concurrentios) { + slot = 0; + } + } while (slot != old_slot); + if (found) + break; lc.cond.Wait(lock); } lock.Unlock(); @@ -417,16 +424,24 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre char* newName; bufferlist *cur_contents; + slot = 0; while (seconds_to_run && (ceph_clock_now(g_ceph_context) < finish_time) && num_objects > data.started) { lock.Lock(); + int old_slot = slot; + bool found = false; while (1) { - for (slot = 0; slot < concurrentios; ++slot) { + do { if (completion_is_done(slot)) { + found = true; break; } - } - if (slot < concurrentios) { + slot++; + if (slot == concurrentios) { + slot = 0; + } + } while (slot != old_slot); + if (found) { break; } lc.cond.Wait(lock);