mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-27 03:41:14 +03:00
Write stream frame header and data separately.
Summary: Prior to this diff we would clone out an entire flow control's worth of data from the writebuffer and then clone out a smaller portion of that to write into the packet builder. This is extremely wasteful when we have a large flow control window. Additionally we would always write the stream data length field even when we are going to fill the remainder of the packet with the current stream frame. By first calculating the amount of data that needs to can be written and writing the header, we can now omit the data length field when we can fill the whole packet. Reviewed By: yangchi Differential Revision: D15769514 fbshipit-source-id: 95ac74eebcde87dd06de54405d7f69c42362e29c
This commit is contained in:
committed by
Facebook Github Bot
parent
e725395662
commit
049b512646
@@ -71,18 +71,23 @@ folly::Optional<PacketEvent> PacketRebuilder::rebuildFromPacket(
|
||||
[&](const WriteStreamFrame& streamFrame) {
|
||||
auto stream = conn_.streamManager->getStream(streamFrame.streamId);
|
||||
if (stream && retransmittable(*stream)) {
|
||||
StreamFrameMetaData meta(
|
||||
auto streamData = cloneRetransmissionBuffer(streamFrame, stream);
|
||||
auto bufferLen =
|
||||
streamData ? streamData->computeChainDataLength() : 0;
|
||||
auto dataLen = writeStreamFrameHeader(
|
||||
builder_,
|
||||
streamFrame.streamId,
|
||||
streamFrame.offset,
|
||||
streamFrame.fin,
|
||||
cloneRetransmissionBuffer(streamFrame, stream),
|
||||
true);
|
||||
auto streamWriteResult = writeStreamFrame(meta, builder_);
|
||||
bool ret = streamWriteResult.hasValue() &&
|
||||
streamWriteResult->bytesWritten == streamFrame.len &&
|
||||
streamWriteResult->finWritten == streamFrame.fin;
|
||||
notPureAck |= ret;
|
||||
return ret;
|
||||
bufferLen,
|
||||
bufferLen,
|
||||
streamFrame.fin);
|
||||
bool ret = dataLen.hasValue() && *dataLen == streamFrame.len;
|
||||
if (ret) {
|
||||
writeStreamFrameData(builder_, std::move(streamData), *dataLen);
|
||||
notPureAck = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// If a stream is already Closed, we should not clone and resend this
|
||||
// stream data. But should we abort the cloning of this packet and
|
||||
|
||||
Reference in New Issue
Block a user