Skip to content

Commit

Permalink
Add option to configure TCP execution context (#4458)
Browse files Browse the repository at this point in the history
* add option to configure TCP execution context

* delete dummy files

* both should default to lowlat

* client inherits exec profile / configuration from cmd line

* update error message
  • Loading branch information
ProjectsByJackHe committed Aug 15, 2024
1 parent 512ed02 commit 52898aa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/perf/lib/PerfClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ PerfClient::Init(
nullptr,
PerfClientConnection::TcpConnectCallback,
PerfClientConnection::TcpReceiveCallback,
PerfClientConnection::TcpSendCompleteCallback));
PerfClientConnection::TcpSendCompleteCallback,
TcpDefaultExecutionProfile)); // Client defaults to using LowLatency profile
} else {
if (UseSendBuffering || !UsePacing) { // Update settings if non-default
MsQuicSettings Settings;
Expand Down
2 changes: 1 addition & 1 deletion src/perf/lib/PerfServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class PerfServer {
public:
PerfServer(const QUIC_CREDENTIAL_CONFIG* CredConfig) :
Engine(TcpAcceptCallback, TcpConnectCallback, TcpReceiveCallback, TcpSendCompleteCallback),
Engine(TcpAcceptCallback, TcpConnectCallback, TcpReceiveCallback, TcpSendCompleteCallback, TcpDefaultExecutionProfile),
Server(&Engine, CredConfig, this) {
CxPlatZeroMemory(&LocalAddr, sizeof(LocalAddr));
QuicAddrSetFamily(&LocalAddr, QUIC_ADDRESS_FAMILY_UNSPEC);
Expand Down
6 changes: 6 additions & 0 deletions src/perf/lib/SecNetPerf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
#define PERF_MAX_THREAD_COUNT 128
#define PERF_MAX_REQUESTS_PER_SECOND 2000000 // best guess - must increase if we can do better

typedef enum TCP_EXECUTION_PROFILE {
TCP_EXECUTION_PROFILE_LOW_LATENCY,
TCP_EXECUTION_PROFILE_MAX_THROUGHPUT,
} TCP_EXECUTION_PROFILE;

extern QUIC_EXECUTION_PROFILE PerfDefaultExecutionProfile;
extern TCP_EXECUTION_PROFILE TcpDefaultExecutionProfile;
extern QUIC_CONGESTION_CONTROL_ALGORITHM PerfDefaultCongestionControl;
extern uint8_t PerfDefaultEcnEnabled;
extern uint8_t PerfDefaultQeoAllowed;
Expand Down
5 changes: 4 additions & 1 deletion src/perf/lib/SecNetPerfMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ PerfClient* Client;

uint32_t MaxRuntime = 0;
QUIC_EXECUTION_PROFILE PerfDefaultExecutionProfile = QUIC_EXECUTION_PROFILE_LOW_LATENCY;
TCP_EXECUTION_PROFILE TcpDefaultExecutionProfile = TCP_EXECUTION_PROFILE_LOW_LATENCY;
QUIC_CONGESTION_CONTROL_ALGORITHM PerfDefaultCongestionControl = QUIC_CONGESTION_CONTROL_ALGORITHM_CUBIC;
uint8_t PerfDefaultEcnEnabled = false;
uint8_t PerfDefaultQeoAllowed = false;
Expand Down Expand Up @@ -193,14 +194,16 @@ QuicMainStart(
if (ExecStr != nullptr) {
if (IsValue(ExecStr, "lowlat")) {
PerfDefaultExecutionProfile = QUIC_EXECUTION_PROFILE_LOW_LATENCY;
TcpDefaultExecutionProfile = TCP_EXECUTION_PROFILE_LOW_LATENCY;
} else if (IsValue(ExecStr, "maxtput")) {
PerfDefaultExecutionProfile = QUIC_EXECUTION_PROFILE_TYPE_MAX_THROUGHPUT;
TcpDefaultExecutionProfile = TCP_EXECUTION_PROFILE_MAX_THROUGHPUT;
} else if (IsValue(ExecStr, "scavenger")) {
PerfDefaultExecutionProfile = QUIC_EXECUTION_PROFILE_TYPE_SCAVENGER;
} else if (IsValue(ExecStr, "realtime")) {
PerfDefaultExecutionProfile = QUIC_EXECUTION_PROFILE_TYPE_REAL_TIME;
} else {
WriteOutput("Failed to parse execution profile[%s], use lowlat as default\n", ExecStr);
WriteOutput("Failed to parse execution profile[%s], use lowlat as default for QUIC, lowlat as default for TCP.\n", ExecStr);
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/perf/lib/Tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ TcpEngine::TcpEngine(
TcpAcceptHandler AcceptHandler,
TcpConnectHandler ConnectHandler,
TcpReceiveHandler ReceiveHandler,
TcpSendCompleteHandler SendCompleteHandler) noexcept :
TcpSendCompleteHandler SendCompleteHandler,
TCP_EXECUTION_PROFILE TcpExecutionProfile) noexcept :
ProcCount((uint16_t)CxPlatProcCount()), Workers(new(std::nothrow) TcpWorker[ProcCount]),
AcceptHandler(AcceptHandler), ConnectHandler(ConnectHandler),
ReceiveHandler(ReceiveHandler), SendCompleteHandler(SendCompleteHandler)
ReceiveHandler(ReceiveHandler), SendCompleteHandler(SendCompleteHandler),
TcpExecutionProfile(TcpExecutionProfile)
{
CxPlatListInitializeHead(&Connections);
for (uint16_t i = 0; i < ProcCount; ++i) {
Expand All @@ -117,6 +119,12 @@ TcpEngine::TcpEngine(
}
}
Initialized = true;
if (TcpExecutionProfile == TCP_EXECUTION_PROFILE_LOW_LATENCY) {
WriteOutput("Initialized TCP Engine with Low Latency mode!\n");
}
if (TcpExecutionProfile == TCP_EXECUTION_PROFILE_MAX_THROUGHPUT) {
WriteOutput("Initialized TCP Engine with Max Throughput mode!\n");
}
}

TcpEngine::~TcpEngine() noexcept
Expand Down
4 changes: 3 additions & 1 deletion src/perf/lib/Tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ class TcpEngine {
const TcpConnectHandler ConnectHandler;
const TcpReceiveHandler ReceiveHandler;
const TcpSendCompleteHandler SendCompleteHandler;
const TCP_EXECUTION_PROFILE TcpExecutionProfile;
public:
TcpEngine(
TcpAcceptHandler AcceptHandler,
TcpConnectHandler ConnectHandler,
TcpReceiveHandler ReceiveHandler,
TcpSendCompleteHandler SendCompleteHandler) noexcept;
TcpSendCompleteHandler SendCompleteHandler,
TCP_EXECUTION_PROFILE TcpExecutionProfile) noexcept;
~TcpEngine() noexcept;
bool IsInitialized() const { return Initialized; }
bool AddConnection(TcpConnection* Connection, uint16_t PartitionIndex);
Expand Down

0 comments on commit 52898aa

Please sign in to comment.