From 76a5c8993d517acaaf17b9fb8b5bf72feadbdf59 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 26 Apr 2012 14:35:39 -0700 Subject: [PATCH] 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 --- src/common/obj_bencher.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 2fce89cfdefb9..1af651a28dae4 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); -- 2.39.5