Skip to content

Commit c1491ef

Browse files
authored
feat(native): Split HTTP2 client flow control into three separate wi… (#26502)
``` == NO RELEASE NOTE == ```
1 parent 58fd531 commit c1491ef

File tree

4 files changed

+53
-19
lines changed

4 files changed

+53
-19
lines changed

presto-native-execution/presto_cpp/main/common/Configs.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ SystemConfig::SystemConfig() {
234234
NUM_PROP(kAnnouncementMaxFrequencyMs, 30'000), // 30s
235235
NUM_PROP(kHeartbeatFrequencyMs, 0),
236236
BOOL_PROP(kHttpClientHttp2Enabled, false),
237-
NUM_PROP(kHttpClientHttp2MaxStreamsPerConnection, 1),
238-
NUM_PROP(kHttpClientHttp2FlowControlWindow, 1 << 24 /*16MB*/),
237+
NUM_PROP(kHttpClientHttp2MaxStreamsPerConnection, 8),
238+
NUM_PROP(kHttpClientHttp2InitialStreamWindow, 1 << 23 /*8MB*/),
239+
NUM_PROP(kHttpClientHttp2StreamWindow, 1 << 23 /*8MB*/),
240+
NUM_PROP(kHttpClientHttp2SessionWindow, 1 << 26 /*64MB*/),
239241
STR_PROP(kExchangeMaxErrorDuration, "3m"),
240242
STR_PROP(kExchangeRequestTimeout, "20s"),
241243
STR_PROP(kExchangeConnectTimeout, "20s"),
@@ -868,8 +870,17 @@ uint32_t SystemConfig::httpClientHttp2MaxStreamsPerConnection() const {
868870
.value();
869871
}
870872

871-
uint32_t SystemConfig::httpClientHttp2FlowControlWindow() const {
872-
return optionalProperty<uint32_t>(kHttpClientHttp2FlowControlWindow).value();
873+
uint32_t SystemConfig::httpClientHttp2InitialStreamWindow() const {
874+
return optionalProperty<uint32_t>(kHttpClientHttp2InitialStreamWindow)
875+
.value();
876+
}
877+
878+
uint32_t SystemConfig::httpClientHttp2StreamWindow() const {
879+
return optionalProperty<uint32_t>(kHttpClientHttp2StreamWindow).value();
880+
}
881+
882+
uint32_t SystemConfig::httpClientHttp2SessionWindow() const {
883+
return optionalProperty<uint32_t>(kHttpClientHttp2SessionWindow).value();
873884
}
874885

875886
std::chrono::duration<double> SystemConfig::exchangeMaxErrorDuration() const {

presto-native-execution/presto_cpp/main/common/Configs.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,17 @@ class SystemConfig : public ConfigBase {
661661
static constexpr std::string_view kHttpClientHttp2MaxStreamsPerConnection{
662662
"http-client.http2.max-streams-per-connection"};
663663

664-
/// HTTP/2 flow control window size in bytes.
665-
/// Controls the initial receive window, stream window, and session window.
666-
static constexpr std::string_view kHttpClientHttp2FlowControlWindow{
667-
"http-client.http2.flow-control-window"};
664+
/// HTTP/2 initial stream window size in bytes.
665+
static constexpr std::string_view kHttpClientHttp2InitialStreamWindow{
666+
"http-client.http2.initial-stream-window"};
667+
668+
/// HTTP/2 stream window size in bytes.
669+
static constexpr std::string_view kHttpClientHttp2StreamWindow{
670+
"http-client.http2.stream-window"};
671+
672+
/// HTTP/2 session window size in bytes.
673+
static constexpr std::string_view kHttpClientHttp2SessionWindow{
674+
"http-client.http2.session-window"};
668675

669676
static constexpr std::string_view kExchangeMaxErrorDuration{
670677
"exchange.max-error-duration"};
@@ -1058,7 +1065,11 @@ class SystemConfig : public ConfigBase {
10581065

10591066
uint32_t httpClientHttp2MaxStreamsPerConnection() const;
10601067

1061-
uint32_t httpClientHttp2FlowControlWindow() const;
1068+
uint32_t httpClientHttp2InitialStreamWindow() const;
1069+
1070+
uint32_t httpClientHttp2StreamWindow() const;
1071+
1072+
uint32_t httpClientHttp2SessionWindow() const;
10621073

10631074
std::chrono::duration<double> exchangeMaxErrorDuration() const;
10641075

presto-native-execution/presto_cpp/main/http/HttpClient.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ HttpClient::HttpClient(
4747
http2Enabled_(SystemConfig::instance()->httpClientHttp2Enabled()),
4848
maxConcurrentStreams_(
4949
SystemConfig::instance()->httpClientHttp2MaxStreamsPerConnection()),
50-
http2FlowControlWindow_(
51-
SystemConfig::instance()->httpClientHttp2FlowControlWindow()),
50+
http2InitialStreamWindow_(
51+
SystemConfig::instance()->httpClientHttp2InitialStreamWindow()),
52+
http2StreamWindow_(
53+
SystemConfig::instance()->httpClientHttp2StreamWindow()),
54+
http2SessionWindow_(
55+
SystemConfig::instance()->httpClientHttp2SessionWindow()),
5256
pool_(std::move(pool)),
5357
sslContext_(sslContext),
5458
reportOnBodyStatsFunc_(std::move(reportOnBodyStatsFunc)),
@@ -310,7 +314,9 @@ class ConnectionHandler : public proxygen::HTTPConnector::Callback {
310314
std::chrono::milliseconds connectTimeout,
311315
bool http2Enabled,
312316
uint32_t maxConcurrentStreams,
313-
uint32_t http2FlowControlWindow,
317+
uint32_t http2InitialStreamWindow,
318+
uint32_t http2StreamWindow,
319+
uint32_t http2SessionWindow,
314320
folly::EventBase* eventBase,
315321
const folly::SocketAddress& address,
316322
folly::SSLContextPtr sslContext)
@@ -320,7 +326,9 @@ class ConnectionHandler : public proxygen::HTTPConnector::Callback {
320326
connectTimeout_(connectTimeout),
321327
http2Enabled_(http2Enabled),
322328
maxConcurrentStreams_(maxConcurrentStreams),
323-
http2FlowControlWindow_(http2FlowControlWindow),
329+
http2InitialStreamWindow_(http2InitialStreamWindow),
330+
http2StreamWindow_(http2StreamWindow),
331+
http2SessionWindow_(http2SessionWindow),
324332
eventBase_(eventBase),
325333
address_(address),
326334
sslContext_(std::move(sslContext)) {}
@@ -343,9 +351,7 @@ class ConnectionHandler : public proxygen::HTTPConnector::Callback {
343351
void connectSuccess(proxygen::HTTPUpstreamSession* session) override {
344352
if (http2Enabled_) {
345353
session->setFlowControl(
346-
http2FlowControlWindow_,
347-
http2FlowControlWindow_,
348-
http2FlowControlWindow_);
354+
http2InitialStreamWindow_, http2StreamWindow_, http2SessionWindow_);
349355
session->setMaxConcurrentOutgoingStreams(maxConcurrentStreams_);
350356
}
351357
auto txn = session->newTransaction(responseHandler_.get());
@@ -372,7 +378,9 @@ class ConnectionHandler : public proxygen::HTTPConnector::Callback {
372378
const std::chrono::milliseconds connectTimeout_;
373379
const bool http2Enabled_;
374380
const uint32_t maxConcurrentStreams_;
375-
const uint32_t http2FlowControlWindow_;
381+
const uint32_t http2InitialStreamWindow_;
382+
const uint32_t http2StreamWindow_;
383+
const uint32_t http2SessionWindow_;
376384
folly::EventBase* const eventBase_;
377385
const folly::SocketAddress address_;
378386
const folly::SSLContextPtr sslContext_;
@@ -541,7 +549,9 @@ void HttpClient::sendRequest(std::shared_ptr<ResponseHandler> responseHandler) {
541549
connectTimeout_,
542550
http2Enabled_,
543551
maxConcurrentStreams_,
544-
http2FlowControlWindow_,
552+
http2InitialStreamWindow_,
553+
http2StreamWindow_,
554+
http2SessionWindow_,
545555
eventBase_,
546556
address_,
547557
sslContext_);

presto-native-execution/presto_cpp/main/http/HttpClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> {
202202
const std::chrono::milliseconds connectTimeout_;
203203
const bool http2Enabled_;
204204
const uint32_t maxConcurrentStreams_;
205-
const uint32_t http2FlowControlWindow_;
205+
const uint32_t http2InitialStreamWindow_;
206+
const uint32_t http2StreamWindow_;
207+
const uint32_t http2SessionWindow_;
206208
const std::shared_ptr<velox::memory::MemoryPool> pool_;
207209
const folly::SSLContextPtr sslContext_;
208210
const std::function<void(int)> reportOnBodyStatsFunc_;

0 commit comments

Comments
 (0)