]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
obj_bencher: use better round robin for completion slot scan
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 26 Apr 2012 21:35:39 +0000 (14:35 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 4 May 2012 22:53:26 +0000 (15:53 -0700)
Start where left last time, don't start from zero.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
src/common/obj_bencher.cc

index 2fce89cfdefb933f7d0319973c8fb3b9dc3f5901..1af651a28dae4eb8a6db5dc69bf794e27f07c6de 100644 (file)
@@ -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);