diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index c58321ce6e..44d0552276 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -444,7 +444,7 @@ struct Peer : NonCopyable { loop { lastWriteTime = now(); - int sent = conn->write(self->unsent.getUnsent(), 200 * 1024); // avoid sending large packet + int sent = conn->write(self->unsent.getUnsent(), /* limit= */ FLOW_KNOBS->MAX_PACKET_SEND_BYTES); if (sent) { self->transport->bytesSent += sent; self->unsent.sent(sent); @@ -735,14 +735,15 @@ static void scanPackets(TransportData* transport, uint8_t*& unprocessed_begin, c static int getNewBufferSize(uint8_t* begin, uint8_t* end, const NetworkAddress& peerAddress) { const int len = end - begin; if (len < sizeof(uint32_t)) { - return std::max(65536, len * 2); + return std::max(FLOW_KNOBS->DEFAULT_PACKET_BUFFER_BYTES, len * 2); } const uint32_t packetLen = *(uint32_t*)begin; if (packetLen > FLOW_KNOBS->PACKET_LIMIT) { TraceEvent(SevError, "Net2_PacketLimitExceeded").detail("FromPeer", peerAddress.toString()).detail("Length", (int)packetLen); throw platform_error(); } - return std::max(4096, packetLen + sizeof(uint32_t) * (peerAddress.isTLS() ? 1 : 2)); + return std::max(FLOW_KNOBS->MIN_PACKET_BUFFER_BYTES, + packetLen + sizeof(uint32_t) * (peerAddress.isTLS() ? 1 : 2)); } ACTOR static Future connectionReader( diff --git a/flow/Knobs.cpp b/flow/Knobs.cpp index c8acae874f..ed1323aba3 100644 --- a/flow/Knobs.cpp +++ b/flow/Knobs.cpp @@ -109,6 +109,9 @@ FlowKnobs::FlowKnobs(bool randomize, bool isSimulated) { init( PACKET_LIMIT, 100LL<<20 ); init( PACKET_WARNING, 2LL<<20 ); // 2MB packet warning quietly allows for 1MB system messages init( TIME_OFFSET_LOGGING_INTERVAL, 60.0 ); + init( MAX_PACKET_SEND_BYTES, 256 * 1024 ); + init( DEFAULT_PACKET_BUFFER_BYTES, 64 * 1024 ); + init( MIN_PACKET_BUFFER_BYTES, 4 * 1024 ); //Sim2 init( MIN_OPEN_TIME, 0.0002 ); diff --git a/flow/Knobs.h b/flow/Knobs.h index 6633cda75a..0a46363d2c 100644 --- a/flow/Knobs.h +++ b/flow/Knobs.h @@ -128,6 +128,9 @@ public: int64_t PACKET_LIMIT; int64_t PACKET_WARNING; // 2MB packet warning quietly allows for 1MB system messages double TIME_OFFSET_LOGGING_INTERVAL; + int MAX_PACKET_SEND_BYTES; + int DEFAULT_PACKET_BUFFER_BYTES; + int MIN_PACKET_BUFFER_BYTES; //Sim2 //FIMXE: more parameters could be factored out