Skip to content

Commit 24fd8ff

Browse files
apapirovskigibfahn
authored andcommitted
http2: adjust stream buffer size
Adjust stream buffer size to allow full 4 default-sized frames including their frame headers to allow more efficient sending of data to the socket. PR-URL: #16445 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent ea32d0e commit 24fd8ff

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/node_http2.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ int Http2Session::DoWrite(WriteWrap* req_wrap,
824824
return 0;
825825
}
826826

827-
void Http2Session::AllocateSend(size_t recommended, uv_buf_t* buf) {
827+
void Http2Session::AllocateSend(uv_buf_t* buf) {
828828
buf->base = stream_alloc();
829829
buf->len = kAllocBufferSize;
830830
}

src/node_http2.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ class Http2Options {
331331
padding_strategy_type padding_strategy_ = PADDING_STRATEGY_NONE;
332332
};
333333

334-
static const size_t kAllocBufferSize = 64 * 1024;
334+
// This allows for 4 default-sized frames with their frame headers
335+
static const size_t kAllocBufferSize = 4 * (16384 + 9);
335336

336337
typedef uint32_t(*get_setting)(nghttp2_session* session,
337338
nghttp2_settings_id id);
@@ -414,7 +415,7 @@ class Http2Session : public AsyncWrap,
414415
void OnFrameError(int32_t id, uint8_t type, int error_code) override;
415416
void OnTrailers(Nghttp2Stream* stream,
416417
const SubmitTrailers& submit_trailers) override;
417-
void AllocateSend(size_t recommended, uv_buf_t* buf) override;
418+
void AllocateSend(uv_buf_t* buf) override;
418419

419420
int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
420421
uv_stream_t* send_handle) override;

src/node_http2_core-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ inline void Nghttp2Session::SendPendingData() {
490490
return;
491491

492492
uv_buf_t dest;
493-
AllocateSend(SEND_BUFFER_RECOMMENDED_SIZE, &dest);
493+
AllocateSend(&dest);
494494
size_t destLength = 0; // amount of data stored in dest
495495
size_t destRemaining = dest.len; // amount space remaining in dest
496496
size_t destOffset = 0; // current write offset of dest

src/node_http2_core.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Nghttp2Stream;
4242
struct nghttp2_stream_write_t;
4343

4444
#define MAX_BUFFER_COUNT 16
45-
#define SEND_BUFFER_RECOMMENDED_SIZE 4096
4645

4746
enum nghttp2_session_type {
4847
NGHTTP2_SESSION_SERVER,
@@ -178,7 +177,7 @@ class Nghttp2Session {
178177
virtual ssize_t GetPadding(size_t frameLength,
179178
size_t maxFrameLength) { return 0; }
180179
virtual void OnFreeSession() {}
181-
virtual void AllocateSend(size_t suggested_size, uv_buf_t* buf) = 0;
180+
virtual void AllocateSend(uv_buf_t* buf) = 0;
182181

183182
virtual bool HasGetPaddingCallback() { return false; }
184183

0 commit comments

Comments
 (0)