Optimize away IOBuf clones on hot path
authorJon Maltiel Swenson <jmswen@fb.com>
Wed, 27 Apr 2016 01:12:20 +0000 (18:12 -0700)
committerFacebook Github Bot 5 <facebook-github-bot-5-bot@fb.com>
Wed, 27 Apr 2016 01:20:24 +0000 (18:20 -0700)
Summary:
'get' is the most frequent memcached operation. On a get reply, we should go to heap
as little as possible.  This diff optimizes for this scenario, where replies
have only one IOBuf field.

Reviewed By: pavlo-fb

Differential Revision: D3226592

fb-gh-sync-id: 92e1a1fac5735bd268691cf11990a96ae6fa8309
fbshipit-source-id: 92e1a1fac5735bd268691cf11990a96ae6fa8309

folly/io/Cursor.h

index 3cf369e9ece27298ffa7eb2bf35a225bc83152a8..a13092394a557781a9e420bc152ff3c592a64fd1 100644 (file)
@@ -913,6 +913,10 @@ class QueueAppender : public detail::Writable<QueueAppender> {
     }
   }
 
+  void insert(const folly::IOBuf& buf) {
+    insert(buf.clone());
+  }
+
  private:
   folly::IOBufQueue* queue_;
   size_t growth_;