]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async: avoid put message within write_lock 20731/head
authorHaomai Wang <haomai@xsky.com>
Tue, 6 Mar 2018 03:28:54 +0000 (11:28 +0800)
committerHaomai Wang <haomai@xsky.com>
Fri, 16 Mar 2018 14:36:16 +0000 (22:36 +0800)
message deconstruct under busy env isn't a very short period, because cpu may
stuck into tcmalloc library to do gc.

from a rough bench(3k iops), reduce send_message latency from 54us to 37.5us. in
real env(higher iops), it should be much more better.

Signed-off-by: Haomai Wang <haomai@xsky.com>
src/msg/async/AsyncConnection.cc

index 8927201587a3764673d1404e951e429170792103..b919702c2a61bd2a8e68d08cd2aa94dee79f262f 100644 (file)
@@ -2299,15 +2299,21 @@ void AsyncConnection::handle_ack(uint64_t seq)
 {
   ldout(async_msgr->cct, 15) << __func__ << " got ack seq " << seq << dendl;
   // trim sent list
-  std::lock_guard<std::mutex> l(write_lock);
-  while (!sent.empty() && sent.front()->get_seq() <= seq) {
+  static const int max_pending = 128;
+  int i = 0;
+  Message *pending[max_pending];
+  write_lock.lock();
+  while (!sent.empty() && sent.front()->get_seq() <= seq && i < max_pending) {
     Message* m = sent.front();
     sent.pop_front();
+    pending[i++] = m;
     ldout(async_msgr->cct, 10) << __func__ << " got ack seq "
                                << seq << " >= " << m->get_seq() << " on "
                                << m << " " << *m << dendl;
-    m->put();
   }
+  write_lock.unlock();
+  for (int k = 0; k < i; k++)
+    pending[k]->put();
 }
 
 void AsyncConnection::DelayedDelivery::do_request(uint64_t id)