Skip to content

Commit 24e7f23

Browse files
afrindmeta-codesync[bot]
authored andcommitted
Add UDP socket buffer size options to HQServerParams
Summary: Add udpSendBufferSize and udpRecvBufferSize parameters to HQServerParams to allow configuring SO_SNDBUF and SO_RCVBUF socket options on the underlying QUIC server sockets. This enables tuning buffer sizes for high-throughput scenarios without requiring custom socket factory implementations. Reviewed By: kvtsoy Differential Revision: D91237656 fbshipit-source-id: 9287e5367778c974bd9c08652fb65767350b6350
1 parent ef12920 commit 24e7f23

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

proxygen/httpserver/samples/hq/HQParams.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ struct HQServerParams : public HQBaseParams {
8282
size_t serverThreads{0};
8383
std::string ccpConfig;
8484
folly::Optional<int64_t> rateLimitPerThread;
85+
// UDP socket buffer sizes (0 = use system default)
86+
size_t udpSendBufferSize{0};
87+
size_t udpRecvBufferSize{0};
8588
};
8689

8790
struct HQClientParams : public HQBaseParams {

proxygen/httpserver/samples/hq/HQServer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <ostream>
1212

13+
#include <folly/io/SocketOptionMap.h>
1314
#include <quic/common/udpsocket/FollyQuicAsyncUDPSocket.h>
1415
#include <string>
1516
#include <vector>
@@ -285,6 +286,22 @@ HQServer::HQServer(
285286
server_->setSupportedVersion(params_.quicVersions);
286287
server_->setFizzContext(std::move(fizzCtx));
287288

289+
// Apply UDP socket buffer size options if specified
290+
folly::SocketOptionMap socketOptions;
291+
if (params_.udpRecvBufferSize > 0) {
292+
socketOptions[{
293+
SOL_SOCKET, SO_RCVBUF, folly::SocketOptionKey::ApplyPos::POST_BIND}] =
294+
static_cast<int>(params_.udpRecvBufferSize);
295+
}
296+
if (params_.udpSendBufferSize > 0) {
297+
socketOptions[{
298+
SOL_SOCKET, SO_SNDBUF, folly::SocketOptionKey::ApplyPos::POST_BIND}] =
299+
static_cast<int>(params_.udpSendBufferSize);
300+
}
301+
if (!socketOptions.empty()) {
302+
server_->setSocketOptions(socketOptions);
303+
}
304+
288305
if (params_.rateLimitPerThread) {
289306
server_->setRateLimit(
290307
[rateLimitPerThread = params_.rateLimitPerThread.value()]() {

0 commit comments

Comments
 (0)