Skip to content

http2: adjust stream buffer size #16445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ int Http2Session::DoWrite(WriteWrap* req_wrap,
return 0;
}

void Http2Session::AllocateSend(size_t recommended, uv_buf_t* buf) {
void Http2Session::AllocateSend(uv_buf_t* buf) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with removing this. Just fwiw, I included this to follow a pattern used elsewhere (tho slightly differently)
e.g. https://github.com./nodejs/node/blob/master/src/tls_wrap.cc#L675

buf->base = stream_alloc();
buf->len = kAllocBufferSize;
}
Expand Down
5 changes: 3 additions & 2 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ class Http2Options {
padding_strategy_type padding_strategy_ = PADDING_STRATEGY_NONE;
};

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

typedef uint32_t(*get_setting)(nghttp2_session* session,
nghttp2_settings_id id);
Expand Down Expand Up @@ -414,7 +415,7 @@ class Http2Session : public AsyncWrap,
void OnFrameError(int32_t id, uint8_t type, int error_code) override;
void OnTrailers(Nghttp2Stream* stream,
const SubmitTrailers& submit_trailers) override;
void AllocateSend(size_t recommended, uv_buf_t* buf) override;
void AllocateSend(uv_buf_t* buf) override;

int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
uv_stream_t* send_handle) override;
Expand Down
2 changes: 1 addition & 1 deletion src/node_http2_core-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ inline void Nghttp2Session::SendPendingData() {
return;

uv_buf_t dest;
AllocateSend(SEND_BUFFER_RECOMMENDED_SIZE, &dest);
AllocateSend(&dest);
size_t destLength = 0; // amount of data stored in dest
size_t destRemaining = dest.len; // amount space remaining in dest
size_t destOffset = 0; // current write offset of dest
Expand Down
3 changes: 1 addition & 2 deletions src/node_http2_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Nghttp2Stream;
struct nghttp2_stream_write_t;

#define MAX_BUFFER_COUNT 16
#define SEND_BUFFER_RECOMMENDED_SIZE 4096

enum nghttp2_session_type {
NGHTTP2_SESSION_SERVER,
Expand Down Expand Up @@ -178,7 +177,7 @@ class Nghttp2Session {
virtual ssize_t GetPadding(size_t frameLength,
size_t maxFrameLength) { return 0; }
virtual void OnFreeSession() {}
virtual void AllocateSend(size_t suggested_size, uv_buf_t* buf) = 0;
virtual void AllocateSend(uv_buf_t* buf) = 0;

virtual bool HasGetPaddingCallback() { return false; }

Expand Down