1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-07-30 14:43:05 +03:00

Use new priority queue implementation

Summary:
This adds the new priority queue implementation and a TransportSetting that controls whether it should be used or not.  The default is still the old priority queue, so this diff should not introduce any functional changes in production code.

One key difference is that with the new queue, streams with new data that become connection flow control blocked are *removed* from the queue, and added back once more flow control comes.  I think this will make the scheduler slightly more efficient at writing low-priority loss streams when there's high-pri data and no connection flow control, since it doesn't need to skip over those streams when building the packet.

If this diff regresses build size, D72476484 should get it back.

Reviewed By: mjoras

Differential Revision: D72476486

fbshipit-source-id: 9665cf3f66dcdbfd57d2199d5c832529a68cfac0
This commit is contained in:
Alan Frindell
2025-04-17 08:43:19 -07:00
committed by Facebook GitHub Bot
parent 47da181ae8
commit 1e1c7defef
15 changed files with 696 additions and 177 deletions

View File

@ -719,7 +719,10 @@ folly::Expected<folly::Unit, QuicError> updateConnection(
conn.streamManager->addTx(writeStreamFrame.streamId);
newStreamBytesSent += writeStreamFrame.len;
}
conn.streamManager->updateWritableStreams(*stream);
// This call could take an argument whether the packet scheduler already
// removed stream from writeQueue
conn.streamManager->updateWritableStreams(
*stream, getSendConnFlowControlBytesWire(conn) > 0);
streamBytesSent += writeStreamFrame.len;
detailsPerStream.addFrame(writeStreamFrame, newStreamDataWritten);
break;
@ -1693,6 +1696,12 @@ folly::Expected<WriteQuicDataResult, QuicError> writeConnectionDataToSocket(
writableBytes -= cipherOverhead;
}
auto writeQueueTransaction =
connection.streamManager->writeQueue().beginTransaction();
auto guard = folly::makeGuard([&] {
connection.streamManager->writeQueue().rollbackTransaction(
std::move(writeQueueTransaction));
});
const auto& dataPlaneFunc =
connection.transportSettings.dataPathType == DataPathType::ChainedMemory
? iobufChainBasedBuildScheduleEncrypt
@ -1732,6 +1741,10 @@ folly::Expected<WriteQuicDataResult, QuicError> writeConnectionDataToSocket(
}
auto& result = ret->result;
// This call to updateConnection will attempt to erase streams from the
// write queue that have already been removed in QuicPacketScheduler.
// Removing non-existent streams can be O(N), consider passing the
// transaction set to skip this step
auto updateConnResult = updateConnection(
connection,
std::move(result->clonedPacketIdentifier),
@ -1743,6 +1756,9 @@ folly::Expected<WriteQuicDataResult, QuicError> writeConnectionDataToSocket(
if (updateConnResult.hasError()) {
return folly::makeUnexpected(updateConnResult.error());
}
guard.dismiss();
connection.streamManager->writeQueue().commitTransaction(
std::move(writeQueueTransaction));
// if ioBufBatch.write returns false
// it is because a flush() call failed