mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-07 22:46:22 +03:00
Summary: The existing batch writers do not handle failed writes to the AsyncUDPSocket. A packet that fails to be written is detected as a packet loss later when feedback is received from the peer. This negatively impacts the congestion controller because of the fake loss signal, and artificially inflates the number of retransmitted packets/bytes. This change adds a new batch writer (SinglePacketBackpressuretBatchWriter) that retains the buffers when a write fails. For subsequent writes, the writer retries the same buffer. No new packets are scheduled until the retried buffer succeeds. Notes: - To make sure that retry writes are scheduled, the write callback is installed on the socket when a buffer needs to be retried. - The retries are for an already scheduled packet. The connection state reflects the timing of the first attempt. This could still have an impact on rtt samples, etc. but it this is a milder impact compared to fake losses/retranmissions. - Any changes outside of the batch writer only impact the new batch writer. Existing batch writers do not use the fields and are not affected by the changes in this diff. Reviewed By: kvtsoy Differential Revision: D57597576 fbshipit-source-id: 9476d71ce52e383c5946466f64bb5eecd4f5d549
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <quic/api/QuicBatchWriter.h>
|
|
#include <quic/api/QuicGsoBatchWriters.h>
|
|
|
|
namespace quic {
|
|
|
|
BatchWriterPtr makeGsoBatchWriter(uint32_t batchSize);
|
|
BatchWriterPtr makeGsoInPlaceBatchWriter(
|
|
uint32_t batchSize,
|
|
QuicConnectionStateBase& conn);
|
|
BatchWriterPtr makeSendmmsgGsoBatchWriter(uint32_t batchSize);
|
|
|
|
class BatchWriterFactory {
|
|
public:
|
|
static BatchWriterPtr makeBatchWriter(
|
|
const quic::QuicBatchingMode& batchingMode,
|
|
uint32_t batchSize,
|
|
bool enableBackpressure,
|
|
DataPathType dataPathType,
|
|
QuicConnectionStateBase& conn,
|
|
bool gsoSupported);
|
|
|
|
private:
|
|
static BatchWriterPtr makeBatchWriterHelper(
|
|
const quic::QuicBatchingMode& batchingMode,
|
|
uint32_t batchSize,
|
|
bool enableBackpressure,
|
|
DataPathType dataPathType,
|
|
QuicConnectionStateBase& conn,
|
|
bool gsoSupported) {
|
|
switch (batchingMode) {
|
|
case quic::QuicBatchingMode::BATCHING_MODE_NONE:
|
|
if (enableBackpressure && dataPathType == DataPathType::ChainedMemory &&
|
|
conn.transportSettings.useSockWritableEvents) {
|
|
return BatchWriterPtr(new SinglePacketBackpressureBatchWriter(conn));
|
|
} else if (useSinglePacketInplaceBatchWriter(batchSize, dataPathType)) {
|
|
return BatchWriterPtr(new SinglePacketInplaceBatchWriter(conn));
|
|
}
|
|
return BatchWriterPtr(new SinglePacketBatchWriter());
|
|
case quic::QuicBatchingMode::BATCHING_MODE_GSO: {
|
|
if (gsoSupported) {
|
|
if (dataPathType == DataPathType::ChainedMemory) {
|
|
return makeGsoBatchWriter(batchSize);
|
|
}
|
|
return makeGsoInPlaceBatchWriter(batchSize, conn);
|
|
}
|
|
// Fall through to Sendmmsg batching if gso is not supported.
|
|
}
|
|
[[fallthrough]];
|
|
case quic::QuicBatchingMode::BATCHING_MODE_SENDMMSG:
|
|
return BatchWriterPtr(new SendmmsgPacketBatchWriter(batchSize));
|
|
case quic::QuicBatchingMode::BATCHING_MODE_SENDMMSG_GSO: {
|
|
if (gsoSupported) {
|
|
return makeSendmmsgGsoBatchWriter(batchSize);
|
|
}
|
|
|
|
return BatchWriterPtr(new SendmmsgPacketBatchWriter(batchSize));
|
|
}
|
|
// no default so we can catch missing case at compile time
|
|
}
|
|
folly::assume_unreachable();
|
|
}
|
|
};
|
|
|
|
} // namespace quic
|