Skip to content

Commit

Permalink
scheduling_group: expose usage statistics
Browse files Browse the repository at this point in the history
This commit extends the public interface of scheduling_group to expose
usage statistics (e.g. runtime).
  • Loading branch information
Vlad Lazar committed Aug 10, 2022
1 parent 1de7c99 commit 0d1bbcd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/seastar/core/scheduling.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename SpecificValType, typename Mapper, typename Reducer, typename Initial>
SEASTAR_CONCEPT( requires requires(SpecificValType specific_val, Mapper mapper, Reducer reducer, Initial initial) {
{reducer(initial, mapper(specific_val))} -> std::convertible_to<Initial>;
Expand Down
11 changes: 11 additions & 0 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<scheduling_group>
create_scheduling_group(sstring name, float shares) noexcept {
auto aid = allocate_scheduling_group_id();
Expand Down

0 comments on commit 0d1bbcd

Please sign in to comment.