Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduling_group: expose usage statistics #31

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 10 additions & 0 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4512,6 +4512,16 @@ 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