]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
messages/MOSDPing: optimize encode and decode of dummy payload 16059/head
authorPiotr Dałek <piotr.dalek@corp.ovh.com>
Fri, 16 Jun 2017 11:34:19 +0000 (13:34 +0200)
committerVikhyat Umrao <vumrao@redhat.com>
Tue, 18 Jul 2017 20:36:41 +0000 (16:36 -0400)
The dummy payload doesn't need to be processed, we can just skip over
it when decoding and we can use a single bufferptr instead of entire
bufferlist to encode it.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
(cherry picked from commit 15ce0772841f913d1eef1daebad0834e5f862383)

src/messages/MOSDPing.h

index 8a02001eaedfd31fad7157b6e844c63beda9c6f9..f759d83b71738a7d516b499078134683b58e60b3 100644 (file)
@@ -86,10 +86,11 @@ public:
     ::decode(peer_stat, p);
     ::decode(stamp, p);
     if (header.version >= 3) {
-      bufferlist size_bl;
       int payload_mid_length = p.get_off();
-      ::decode(size_bl, p);
-      min_message_size = size_bl.length() + payload_mid_length;
+      uint32_t size;
+      ::decode(size, p);
+      p.advance(size);
+      min_message_size = size + payload_mid_length;
     }
   }
   void encode_payload(uint64_t features) {
@@ -105,20 +106,18 @@ public:
       s = min_message_size - payload.length();
     ::encode((uint32_t)s, payload);
     if (s) {
-      bufferlist pad;
       // this should be big enough for normal min_message padding sizes. since
       // we are targetting jumbo ethernet frames around 9000 bytes, 16k should
       // be more than sufficient!  the compiler will statically zero this so
       // that at runtime we are only adding a bufferptr reference to it.
       static char zeros[16384] = {};
       while (s > sizeof(zeros)) {
-       pad.append(buffer::create_static(sizeof(zeros), zeros));
+       payload.append(buffer::create_static(sizeof(zeros), zeros));
        s -= sizeof(zeros);
       }
       if (s) {
-       pad.append(buffer::create_static(s, zeros));
+       payload.append(buffer::create_static(s, zeros));
       }
-      ::encode(pad, payload);
     }
   }