From 0d1bbcd3414c66f75004c9f4b7ca3cffc293aa8a Mon Sep 17 00:00:00 2001 From: Vlad Lazar Date: Mon, 8 Aug 2022 13:30:22 +0100 Subject: [PATCH] scheduling_group: expose usage statistics This commit extends the public interface of scheduling_group to expose usage statistics (e.g. runtime). --- include/seastar/core/scheduling.hh | 7 +++++++ src/core/reactor.cc | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/seastar/core/scheduling.hh b/include/seastar/core/scheduling.hh index 0405b9ba992..96a5fcfc06a 100644 --- a/include/seastar/core/scheduling.hh +++ b/include/seastar/core/scheduling.hh @@ -293,6 +293,13 @@ public: friend unsigned internal::scheduling_group_index(scheduling_group sg) noexcept; friend scheduling_group internal::scheduling_group_from_index(unsigned index) noexcept; + struct stats { + sched_clock::duration runtime; + sched_clock::duration waittime; + sched_clock::duration starvetime; + }; + stats get_stats() const noexcept; + template SEASTAR_CONCEPT( requires requires(SpecificValType specific_val, Mapper mapper, Reducer reducer, Initial initial) { {reducer(initial, mapper(specific_val))} -> std::convertible_to; diff --git a/src/core/reactor.cc b/src/core/reactor.cc index 49ed5d7d4dd..f807bdca7f3 100644 --- a/src/core/reactor.cc +++ b/src/core/reactor.cc @@ -4512,6 +4512,17 @@ scheduling_group::set_shares(float shares) noexcept { engine()._task_queues[_id]->set_shares(shares); } +scheduling_group::stats +scheduling_group::get_stats() const noexcept { + const auto * const tq = engine()._task_queues[_id].get(); + return { + .runtime = tq->_runtime, + .waittime = tq->_waittime, + .starvetime = tq->_starvetime + }; +} + + future create_scheduling_group(sstring name, float shares) noexcept { auto aid = allocate_scheduling_group_id();