From: Igor Fedotov Date: Wed, 25 Sep 2024 18:59:34 +0000 (+0300) Subject: os/bluestore: log max throttle cost and txc count on slow op. X-Git-Tag: v20.0.0~712^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=719fd98952379df2f564911686fa5e68f33cf56b;p=ceph.git os/bluestore: log max throttle cost and txc count on slow op. Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index efd7968e9c71..f8d2c282a2ba 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -14087,6 +14087,7 @@ void BlueStore::_txc_state_proc(TransContext *txc) if (txc->had_ios) kv_ios++; kv_throttle_costs += txc->cost; + ++kv_throttle_txcs; } return; case TransContext::STATE_KV_SUBMITTED: @@ -14339,7 +14340,11 @@ void BlueStore::_txc_committed_kv(TransContext *txc) ", txc cost = " + stringify(txc->cost) + ", txc onodes = " + stringify(txc->onodes.size()) + ", DB updates = " + stringify(txc->t->get_count()) + - ", DB bytes = " + stringify(txc->t->get_size_bytes()) + ", DB bytes = " + stringify(txc->t->get_size_bytes()) + + ", cost max = " + stringify(throttle.bytes_observed_max) + + " on " + stringify(throttle.bytes_max_ts) + + ", txc max = " + stringify(throttle.transactions_observed_max) + + " on " + stringify(throttle.transactions_max_ts) ; }, l_bluestore_slow_committed_kv_count @@ -14690,7 +14695,7 @@ void BlueStore::_kv_sync_thread() } else { deque kv_submitting; deque deferred_done, deferred_stable; - uint64_t aios = 0, costs = 0; + uint64_t aios = 0, costs = 0, txcs = 0; dout(20) << __func__ << " committing " << kv_queue.size() << " submitting " << kv_queue_unsubmitted.size() @@ -14703,8 +14708,10 @@ void BlueStore::_kv_sync_thread() deferred_stable.swap(deferred_stable_queue); aios = kv_ios; costs = kv_throttle_costs; + txcs = kv_throttle_txcs; kv_ios = 0; kv_throttle_costs = 0; + kv_throttle_txcs = 0; l.unlock(); dout(30) << __func__ << " committing " << kv_committing << dendl; @@ -14800,7 +14807,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.release_kv_throttle(costs); + throttle.release_kv_throttle(costs, txcs); // cleanup sync deferred keys for (auto b : deferred_stable) { @@ -18602,6 +18609,20 @@ bool BlueStore::BlueStoreThrottle::try_start_transaction( TransContext &txc, mono_clock::time_point start_throttle_acquire) { + { + std::lock_guard l(lock); + auto cost0 = throttle_bytes.get_current(); + if (cost0 + txc.cost > bytes_observed_max) { + bytes_observed_max = cost0 + txc.cost; + bytes_max_ts = ceph_clock_now(); + } + auto txcs = ++transactions; + if (txcs > transactions_observed_max) { + transactions_observed_max = txcs; + transactions_max_ts = ceph_clock_now(); + } + } + throttle_bytes.get(txc.cost); if (!txc.deferred_txn || throttle_deferred_bytes.get_or_fail(txc.cost)) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 4fd40eee38ec..1b9cb14e1d93 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2095,6 +2095,20 @@ public: Throttle throttle_bytes; ///< submit to commit Throttle throttle_deferred_bytes; ///< submit to deferred complete + public: + ceph::mutex lock = ceph::make_mutex("BlueStoreThrottle::max_lock"); + + std::atomic transactions = 0; + + int64_t bytes_observed_max = 0; + utime_t bytes_max_ts; + uint64_t transactions_observed_max = 0; + utime_t transactions_max_ts; + + uint64_t get_current() { + return throttle_bytes.get_current(); + } + public: BlueStoreThrottle(CephContext *cct) : throttle_bytes(cct, "bluestore_throttle_bytes", 0), @@ -2121,8 +2135,9 @@ public: KeyValueDB &db, TransContext &txc, ceph::mono_clock::time_point); - void release_kv_throttle(uint64_t cost) { + void release_kv_throttle(uint64_t cost, uint64_t txcs) { throttle_bytes.put(cost); + transactions -= txcs; } void release_deferred_throttle(uint64_t cost) { throttle_deferred_bytes.put(cost); @@ -2485,6 +2500,7 @@ private: uint64_t kv_ios = 0; uint64_t kv_throttle_costs = 0; + uint64_t kv_throttle_txcs = 0; // cache trim control uint64_t cache_size = 0; ///< total cache size