Skip to content

Commit

Permalink
Merge pull request ceph#58631 from cbodley/wip-66336
Browse files Browse the repository at this point in the history
msg: insert PriorityDispatchers in sorted position

Reviewed-by: Venky Shankar <[email protected]>
Reviewed-by: Patrick Donnelly <[email protected]>
  • Loading branch information
yuriw authored Aug 1, 2024
2 parents a2c6016 + 063d100 commit 60cd2bc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/msg/Messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ class Messenger {

ZTracer::Endpoint trace_endpoint;

static void insert_head(std::vector<PriorityDispatcher>& v,
PriorityDispatcher d)
{
v.insert(std::lower_bound(v.begin(), v.end(), d), d);
}
static void insert_tail(std::vector<PriorityDispatcher>& v,
PriorityDispatcher d)
{
v.insert(std::upper_bound(v.begin(), v.end(), d), d);
}

protected:
void set_endpoint_addr(const entity_addr_t& a,
const entity_name_t &name);
Expand Down Expand Up @@ -401,11 +412,10 @@ class Messenger {
*/
void add_dispatcher_head(Dispatcher *d, PriorityDispatcher::priority_t priority=Dispatcher::PRIORITY_DEFAULT) {
bool first = dispatchers.empty();
dispatchers.insert(dispatchers.begin(), PriorityDispatcher{priority, d});
std::stable_sort(dispatchers.begin(), dispatchers.end());
const PriorityDispatcher entry{priority, d};
insert_head(dispatchers, entry);
if (d->ms_can_fast_dispatch_any()) {
fast_dispatchers.insert(fast_dispatchers.begin(), PriorityDispatcher{priority, d});
std::stable_sort(fast_dispatchers.begin(), fast_dispatchers.end());
insert_head(fast_dispatchers, entry);
}
if (first)
ready();
Expand All @@ -419,11 +429,10 @@ class Messenger {
*/
void add_dispatcher_tail(Dispatcher *d, PriorityDispatcher::priority_t priority=Dispatcher::PRIORITY_DEFAULT) {
bool first = dispatchers.empty();
dispatchers.push_back(PriorityDispatcher{priority, d});
std::stable_sort(dispatchers.begin(), dispatchers.end());
const PriorityDispatcher entry{priority, d};
insert_tail(dispatchers, entry);
if (d->ms_can_fast_dispatch_any()) {
fast_dispatchers.push_back(PriorityDispatcher{priority, d});
std::stable_sort(fast_dispatchers.begin(), fast_dispatchers.end());
insert_tail(fast_dispatchers, entry);
}
if (first)
ready();
Expand Down

0 comments on commit 60cd2bc

Please sign in to comment.