From: Xuehan Xu Date: Mon, 20 Feb 2023 08:44:29 +0000 (+0000) Subject: crimson/os/seastore: count transactions pending on seastore's throttler X-Git-Tag: v18.1.0~305^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F50176%2Fhead;p=ceph.git crimson/os/seastore: count transactions pending on seastore's throttler Signed-off-by: Xuehan Xu --- diff --git a/src/crimson/common/throttle.cc b/src/crimson/common/throttle.cc index 8aeaa1fdd7d9..88d1859f32f5 100644 --- a/src/crimson/common/throttle.cc +++ b/src/crimson/common/throttle.cc @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- +// vim: ts=8 sw=2 smarttab + #include "throttle.h" namespace crimson::common { @@ -29,9 +32,11 @@ seastar::future<> Throttle::get(size_t c) if (max == 0u) { return seastar::make_ready_future<>(); } + pending++; return on_free_slots.wait([this, c] { return !_should_wait(c); }).then([this, c] { + pending--; count += c; return seastar::make_ready_future<>(); }); diff --git a/src/crimson/common/throttle.h b/src/crimson/common/throttle.h index fea471c8d61f..2998cb5f8431 100644 --- a/src/crimson/common/throttle.h +++ b/src/crimson/common/throttle.h @@ -15,6 +15,7 @@ namespace crimson::common { class Throttle final : public ThrottleInterface { size_t max = 0; size_t count = 0; + size_t pending = 0; // we cannot change the "count" of seastar::semaphore after it is created, // so use condition_variable instead. seastar::condition_variable on_free_slots; @@ -31,6 +32,9 @@ public: size_t get_max() const { return max; } + size_t get_pending() const { + return pending; + } void reset_max(size_t m); private: bool _should_wait(size_t c) const; diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index 6680f52a80a6..04522f1e7ad7 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -173,6 +173,14 @@ void SeaStore::register_metrics() return throttler.get_current(); }, sm::description("transactions that are running inside seastore") + ), + sm::make_gauge( + "pending_transactions", + [this] { + return throttler.get_pending(); + }, + sm::description("transactions waiting to get " + "through seastore's throttler") ) } );