in mcrouter/lib/carbon/CarbonQueueAppender.h [36:78]
void append(const folly::IOBuf& buf) {
// IOBuf copy is a very expensive procedure (64 bytes object + atomic
// operation), avoid incuring that cost for small buffers.
if (!buf.empty() && !buf.isChained() && buf.length() <= kInlineIOBufLen &&
storageIdx_ + buf.length() <= sizeOfStorage()) {
push(buf.data(), buf.length());
return;
}
finalizeLastIovec();
if (nIovsUsed_ == kMaxIovecs) {
coalesce();
}
assert(nIovsUsed_ < kMaxIovecs);
struct iovec* nextIov = iovs_.data() + nIovsUsed_;
const auto nFilled =
buf.fillIov(nextIov, kMaxIovecs - nIovsUsed_).numIovecs;
if (tcpZeroCopyThreshold_ && !applyZeroCopy_ &&
buf.capacity() >= tcpZeroCopyThreshold_) {
applyZeroCopy_ = true;
}
if (nFilled > 0) {
nIovsUsed_ += nFilled;
if (!head_) {
head_ = buf;
} else {
head_->prependChain(buf.clone());
}
} else {
if (buf.empty()) {
return;
}
appendSlow(buf);
}
// If a push() comes after, it should not use the iovec we just filled in
canUsePreviousIov_ = false;
}