Skip to content

Commit

Permalink
fair_queue: Export the number of times class was activated
Browse files Browse the repository at this point in the history
Activation of a class happens when it receives a request into its empty
queue. When activated, class also updates its "accumulator" that's
responsible for fair-selection of classes according to its shares. Each
activation a class may lose some accumulator point, thus losing some
portion of the disk capacity.

Knowing the activation rate is very useful, right now we only have some
side ways to get an idea of this counter.

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul authored and avikivity committed Aug 25, 2024
1 parent 3c70194 commit 83e6cdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/io_tester/io_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ class io_class_data : public class_data {
emit_one_metrics(out, "io_queue_starvation_time_sec");
emit_one_metrics(out, "io_queue_consumption");
emit_one_metrics(out, "io_queue_adjusted_consumption");
emit_one_metrics(out, "io_queue_activations");
}

public:
Expand Down
5 changes: 5 additions & 0 deletions src/core/fair_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class fair_queue::priority_class_data {
fair_queue_entry::container_list_t _queue;
bool _queued = false;
bool _plugged = true;
uint32_t _activations = 0;

public:
explicit priority_class_data(uint32_t shares) noexcept : _shares(std::max(shares, 1u)) {}
Expand Down Expand Up @@ -190,6 +191,7 @@ void fair_queue::push_priority_class_from_idle(priority_class_data& pc) noexcept
_handles.assert_enough_capacity();
_handles.push(&pc);
pc._queued = true;
pc._activations++;
}
}

Expand Down Expand Up @@ -396,6 +398,9 @@ std::vector<seastar::metrics::impl::metric_definition_impl> fair_queue::metrics(
sm::make_counter("adjusted_consumption",
[&pc] { return fair_group::capacity_tokens(pc._accumulated); },
sm::description("Consumed disk capacity units adjusted for class shares and idling preemption")),
sm::make_counter("activations",
[&pc] { return pc._activations; },
sm::description("The number of times the class was woken up from idle")),
});
}

Expand Down

0 comments on commit 83e6cdf

Please sign in to comment.