summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@ionos.com>2024-10-08 12:48:03 +0200
committerMax Kellermann <max.kellermann@ionos.com>2024-10-09 23:15:15 +0200
commit342a25b9df13319ff6cd661eab1c546229ce0e14 (patch)
treeb57743988a2a6ad92276b0c4f90dbca48d2caf3a /src
parentmsg/async/ProtocolV[12]: use `auto` (diff)
downloadceph-342a25b9df13319ff6cd661eab1c546229ce0e14.tar.xz
ceph-342a25b9df13319ff6cd661eab1c546229ce0e14.zip
msg/async/ProtocolV[12]: reverse the std::map sort order
This allows eliminating one lookup in `_get_next_outgoing()` because we can pass the iterator instead of the key to `erase()`. Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Diffstat (limited to 'src')
-rw-r--r--src/msg/async/ProtocolV1.cc4
-rw-r--r--src/msg/async/ProtocolV1.h7
-rw-r--r--src/msg/async/ProtocolV2.cc4
-rw-r--r--src/msg/async/ProtocolV2.h7
4 files changed, 16 insertions, 6 deletions
diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc
index fe8f7eb43ca..1a6a2e6e688 100644
--- a/src/msg/async/ProtocolV1.cc
+++ b/src/msg/async/ProtocolV1.cc
@@ -1326,12 +1326,12 @@ void ProtocolV1::reset_recv_state()
ProtocolV1::out_q_entry_t ProtocolV1::_get_next_outgoing() {
out_q_entry_t out_entry;
if (!out_q.empty()) {
- const auto it = out_q.rbegin();
+ const auto it = out_q.begin();
ceph_assert(!it->second.empty());
const auto p = it->second.begin();
out_entry = *p;
it->second.erase(p);
- if (it->second.empty()) out_q.erase(it->first);
+ if (it->second.empty()) out_q.erase(it);
}
return out_entry;
}
diff --git a/src/msg/async/ProtocolV1.h b/src/msg/async/ProtocolV1.h
index 1b7c1d2b5f8..63bc1cd0946 100644
--- a/src/msg/async/ProtocolV1.h
+++ b/src/msg/async/ProtocolV1.h
@@ -112,7 +112,12 @@ protected:
bool is_prepared {false};
};
// priority queue for outbound msgs
- std::map<int, std::list<out_q_entry_t>> out_q;
+
+ /**
+ * A queue for each priority value, highest priority first.
+ */
+ std::map<int, std::list<out_q_entry_t>, std::greater<int>> out_q;
+
bool keepalive;
bool write_in_progress = false;
diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc
index 7e6e2ec0d87..463b9b84191 100644
--- a/src/msg/async/ProtocolV2.cc
+++ b/src/msg/async/ProtocolV2.cc
@@ -508,13 +508,13 @@ ProtocolV2::out_queue_entry_t ProtocolV2::_get_next_outgoing() {
out_queue_entry_t out_entry;
if (!out_queue.empty()) {
- auto it = out_queue.rbegin();
+ auto it = out_queue.begin();
auto& entries = it->second;
ceph_assert(!entries.empty());
out_entry = entries.front();
entries.pop_front();
if (entries.empty()) {
- out_queue.erase(it->first);
+ out_queue.erase(it);
}
}
return out_entry;
diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h
index 6441866fea4..78e3c49436b 100644
--- a/src/msg/async/ProtocolV2.h
+++ b/src/msg/async/ProtocolV2.h
@@ -93,7 +93,12 @@ private:
bool is_prepared {false};
Message* m {nullptr};
};
- std::map<int, std::list<out_queue_entry_t>> out_queue;
+
+ /**
+ * A queue for each priority value, highest priority first.
+ */
+ std::map<int, std::list<out_queue_entry_t>, std::greater<int>> out_queue;
+
std::list<Message *> sent;
std::atomic<uint64_t> out_seq{0};
std::atomic<uint64_t> in_seq{0};