Skip to content

Commit

Permalink
fair_queue: track the total capacity of queued requests
Browse files Browse the repository at this point in the history
Adds a member variable which tracks the summed capacity of
all requests waiting in the queue.
This is a piece of data which might be valuable to the IO scheduler.
We make use of it in later patches in the series.
  • Loading branch information
michoecho committed Jan 21, 2025
1 parent 1e597cd commit 7781c4c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/seastar/core/fair_queue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ private:
};

std::optional<pending> _pending;
// Total capacity of all requests waiting in the queue.
capacity_t _queued_capacity = 0;

void push_priority_class(priority_class_data& pc) noexcept;
void push_priority_class_from_idle(priority_class_data& pc) noexcept;
Expand Down
3 changes: 3 additions & 0 deletions src/core/fair_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,14 @@ void fair_queue::queue(class_id id, fair_queue_entry& ent) noexcept {
push_priority_class_from_idle(pc);
}
pc._queue.push_back(ent);
_queued_capacity += ent.capacity();
}

void fair_queue::notify_request_finished(fair_queue_entry::capacity_t cap) noexcept {
}

void fair_queue::notify_request_cancelled(fair_queue_entry& ent) noexcept {
_queued_capacity -= ent._capacity;
ent._capacity = 0;
}

Expand Down Expand Up @@ -375,6 +377,7 @@ void fair_queue::dispatch_requests(std::function<void(fair_queue_entry&)> cb) {
h._accumulated += req_cost;
h._pure_accumulated += req_cap;
dispatched += req_cap;
_queued_capacity -= req_cap;

cb(req);

Expand Down

0 comments on commit 7781c4c

Please sign in to comment.