Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
+// -*- 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 {
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<>();
});
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;
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;
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")
)
}
);