]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Reduce unnecessary wakeups. 29130/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 19 Jul 2019 13:20:19 +0000 (21:20 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Mon, 22 Jul 2019 13:41:48 +0000 (21:41 +0800)
Add bool kv_sync_in_progress to indicate thread kv_sync_thread
is running or waiting. Only wake up if thread waiting.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 10742c7dd60a4808b1a406c7d40db7a1ef403517..4dac4bff8c4f3dcb3141908c53c159bd6f3934c3 100644 (file)
@@ -9912,7 +9912,10 @@ void BlueStore::_txc_state_proc(TransContext *txc)
       {
        std::lock_guard l(kv_lock);
        kv_queue.push_back(txc);
-       kv_cond.notify_one();
+       if (!kv_sync_in_progress) {
+         kv_sync_in_progress = true;
+         kv_cond.notify_one();
+       }
        if (txc->state != TransContext::STATE_KV_SUBMITTED) {
          kv_queue_unsubmitted.push_back(txc);
          ++txc->osr->kv_committing_serially;
@@ -10294,7 +10297,10 @@ void BlueStore::_osr_drain_preceding(TransContext *txc)
   {
     // wake up any previously finished deferred events
     std::lock_guard l(kv_lock);
-    kv_cond.notify_one();
+    if (!kv_sync_in_progress) {
+      kv_sync_in_progress = true;
+      kv_cond.notify_one();
+    }
   }
   osr->drain_preceding(txc);
   --deferred_aggressive;
@@ -10317,7 +10323,10 @@ void BlueStore::_osr_drain(OpSequencer *osr)
   {
     // wake up any previously finished deferred events
     std::lock_guard l(kv_lock);
-    kv_cond.notify_one();
+    if (!kv_sync_in_progress) {
+      kv_sync_in_progress = true;
+      kv_cond.notify_one();
+    }
   }
   osr->drain();
   --deferred_aggressive;
@@ -10450,6 +10459,7 @@ void BlueStore::_kv_sync_thread()
       if (kv_stop)
        break;
       dout(20) << __func__ << " sleep" << dendl;
+      kv_sync_in_progress = false;
       kv_cond.wait(l);
       dout(20) << __func__ << " wake" << dendl;
     } else {
@@ -10930,7 +10940,10 @@ void BlueStore::_deferred_aio_finish(OpSequencer *osr)
   // catch us on the next commit anyway.
   if (deferred_aggressive) {
     std::lock_guard l(kv_lock);
-    kv_cond.notify_one();
+    if (!kv_sync_in_progress) {
+      kv_sync_in_progress = true;
+      kv_cond.notify_one();
+    }
   }
 }
 
@@ -11048,7 +11061,10 @@ int BlueStore::queue_transactions(
       {
        // wake up any previously finished deferred events
        std::lock_guard l(kv_lock);
-       kv_cond.notify_one();
+       if (!kv_sync_in_progress) {
+         kv_sync_in_progress = true;
+         kv_cond.notify_one();
+       }
       }
       throttle_deferred_bytes.get(txc->cost);
       --deferred_aggressive;
index 52b2d701b14f076d8d83bfad2c521c18d53ef825..d3ed51e86018118dff452896098c3e26c86b8791 100644 (file)
@@ -1951,6 +1951,7 @@ private:
   deque<TransContext*> kv_queue_unsubmitted; ///< ready, need submit by kv thread
   deque<TransContext*> kv_committing;        ///< currently syncing
   deque<DeferredBatch*> deferred_done_queue;   ///< deferred ios done
+  bool kv_sync_in_progress = false;
 
   KVFinalizeThread kv_finalize_thread;
   ceph::mutex kv_finalize_lock = ceph::make_mutex("BlueStore::kv_finalize_lock");