1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2026-01-06 03:41:10 +03:00

Limit write loop time by a fraction of RTT

Summary:
Before we have pacing, we limit write function to loop at most 5
times. Then pacing came in, and pacing burst is used as the limit when pacing
is enabled. Then pacing token was introduced to increase send rate when pacing
is enabled. Then when cwnd is large enough, pacing burst size can be really
large, that means this write function can loop for long time. When use loopback
as network interface, for example, the write function can loop more than 1 RTT,
which delays receive time when peer packets already arrived, which leads to
both wrong RTT estimation and wrong BBR bandwidth estimation.

This diff limits the write to a fraction of RTT as well, and current default
value will be 1/25 SRTT.

Reviewed By: mjoras

Differential Revision: D18864699

fbshipit-source-id: 0b57ee4138e4788d132152a4aa363959065f6f7f
This commit is contained in:
Yang Chi
2019-12-30 15:10:33 -08:00
committed by Facebook Github Bot
parent b8bac00147
commit 68e0a1add2
4 changed files with 52 additions and 1 deletions

View File

@@ -927,7 +927,22 @@ uint64_t writeConnectionDataToSocket(
connection.debugState.noWriteReason = NoWriteReason::EMPTY_SCHEDULER;
}
}
while (scheduler.hasData() && ioBufBatch.getPktSent() < packetLimit) {
auto writeLoopBeginTime = Clock::now();
// helper functor to check if we have been write in a loop for longer than the
// RTT fraction that we are allowed to write. Only kicks in if we have write
// one batch in batching write mode.
auto timeLimitHelper = [&]() -> bool {
auto batchSize = connection.transportSettings.batchingMode ==
quic::QuicBatchingMode::BATCHING_MODE_NONE
? connection.transportSettings.writeConnectionDataPacketsLimit
: connection.transportSettings.maxBatchSize;
return ioBufBatch.getPktSent() < batchSize ||
connection.lossState.srtt == 0us ||
Clock::now() - writeLoopBeginTime < connection.lossState.srtt /
connection.transportSettings.writeLimitRttFraction;
};
while (scheduler.hasData() && ioBufBatch.getPktSent() < packetLimit &&
timeLimitHelper()) {
auto packetNum = getNextPacketNum(connection, pnSpace);
auto header = builder(srcConnId, dstConnId, packetNum, version, token);
uint32_t writableBytes = folly::to<uint32_t>(std::min<uint64_t>(