]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueStore: avoid iterating to get ios/cost in _kv_sync_thread.
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 26 May 2017 10:13:15 +0000 (18:13 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Fri, 26 May 2017 10:15:06 +0000 (18:15 +0800)
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 68f6a277d1ca7f427adf853f64503a668b7d81fa..72016d2317a9b757fe835bff9290de70756a06f4 100644 (file)
@@ -7516,6 +7516,9 @@ void BlueStore::_txc_state_proc(TransContext *txc)
          kv_queue_unsubmitted.push_back(txc);
          ++txc->osr->kv_committing_serially;
        }
+       if (txc->had_ios)
+         kv_ios++;
+       kv_throttle_costs += txc->cost;
       }
       return;
     case TransContext::STATE_KV_SUBMITTED:
@@ -7962,6 +7965,8 @@ void BlueStore::_kv_sync_thread()
     } else {
       deque<TransContext*> kv_submitting;
       deque<DeferredBatch*> deferred_done, deferred_stable;
+      uint64_t aios = 0, costs = 0;
+
       dout(20) << __func__ << " committing " << kv_queue.size()
               << " submitting " << kv_queue_unsubmitted.size()
               << " deferred done " << deferred_done_queue.size()
@@ -7971,6 +7976,10 @@ void BlueStore::_kv_sync_thread()
       kv_submitting.swap(kv_queue_unsubmitted);
       deferred_done.swap(deferred_done_queue);
       deferred_stable.swap(deferred_stable_queue);
+      aios = kv_ios;
+      costs = kv_throttle_costs;
+      kv_ios = 0;
+      kv_throttle_costs = 0;
       utime_t start = ceph_clock_now();
       l.unlock();
 
@@ -7979,22 +7988,13 @@ void BlueStore::_kv_sync_thread()
       dout(30) << __func__ << " deferred_done " << deferred_done << dendl;
       dout(30) << __func__ << " deferred_stable " << deferred_stable << dendl;
 
-      int num_aios = 0;
-      uint64_t total_cost = 0;
-      for (auto txc : kv_committing) {
-       if (txc->had_ios) {
-         ++num_aios;
-       }
-       total_cost += txc->cost;
-      }
-
       bool force_flush = false;
       // if bluefs is sharing the same device as data (only), then we
       // can rely on the bluefs commit to flush the device and make
       // deferred aios stable.  that means that if we do have done deferred
       // txcs AND we are not on a single device, we need to force a flush.
       if (bluefs_single_shared_device && bluefs) {
-       if (num_aios) {
+       if (aios) {
          force_flush = true;
        } else if (kv_committing.empty() && kv_submitting.empty() &&
                   deferred_stable.empty()) {
@@ -8006,7 +8006,7 @@ void BlueStore::_kv_sync_thread()
        force_flush = true;
 
       if (force_flush) {
-       dout(20) << __func__ << " num_aios=" << num_aios
+       dout(20) << __func__ << " num_aios=" << aios
                 << " force_flush=" << (int)force_flush
                 << ", flushing, deferred done->stable" << dendl;
        // flush/barrier on block device
@@ -8073,7 +8073,7 @@ void BlueStore::_kv_sync_thread()
       // iteration there will already be ops awake.  otherwise, we
       // end up going to sleep, and then wake up when the very first
       // transaction is ready for commit.
-      throttle_bytes.put(total_cost);
+      throttle_bytes.put(costs);
 
       PExtentVector bluefs_gift_extents;
       if (bluefs &&
index b2cc7996fd567bb1fc5bc3c814284f8ae5b73f93..f37c0b1a6756f224272a246e749bb81a1a50f364 100644 (file)
@@ -1863,6 +1863,9 @@ private:
 
   std::atomic<uint64_t> max_blob_size = {0};  ///< maximum blob size
 
+  uint64_t kv_ios = 0;
+  uint64_t kv_throttle_costs = 0;
+
   // cache trim control
 
   // note that these update in a racy way, but we don't *really* care if