From f1d69ca021021b6192882a86274cb7f7d69748cb Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Mon, 20 Feb 2023 08:44:29 +0000 Subject: [PATCH] crimson/os/seastore: count transactions pending on seastore's throttler Signed-off-by: Xuehan Xu --- src/crimson/common/throttle.cc | 5 +++++ src/crimson/common/throttle.h | 4 ++++ src/crimson/os/seastore/seastore.cc | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/crimson/common/throttle.cc b/src/crimson/common/throttle.cc index 8aeaa1fdd7d..88d1859f32f 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 fea471c8d61..2998cb5f843 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 6680f52a80a..04522f1e7ad 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") ) } ); -- 2.39.5