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: https://github.com/nodejs/node/pull/16445 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
98eab4a461
commit
3690a72347
@ -824,7 +824,7 @@ int Http2Session::DoWrite(WriteWrap* req_wrap,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Http2Session::AllocateSend(size_t recommended, uv_buf_t* buf) {
|
void Http2Session::AllocateSend(uv_buf_t* buf) {
|
||||||
buf->base = stream_alloc();
|
buf->base = stream_alloc();
|
||||||
buf->len = kAllocBufferSize;
|
buf->len = kAllocBufferSize;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,8 @@ class Http2Options {
|
|||||||
padding_strategy_type padding_strategy_ = PADDING_STRATEGY_NONE;
|
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,
|
typedef uint32_t(*get_setting)(nghttp2_session* session,
|
||||||
nghttp2_settings_id id);
|
nghttp2_settings_id id);
|
||||||
@ -414,7 +415,7 @@ class Http2Session : public AsyncWrap,
|
|||||||
void OnFrameError(int32_t id, uint8_t type, int error_code) override;
|
void OnFrameError(int32_t id, uint8_t type, int error_code) override;
|
||||||
void OnTrailers(Nghttp2Stream* stream,
|
void OnTrailers(Nghttp2Stream* stream,
|
||||||
const SubmitTrailers& submit_trailers) override;
|
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,
|
int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
|
||||||
uv_stream_t* send_handle) override;
|
uv_stream_t* send_handle) override;
|
||||||
|
@ -490,7 +490,7 @@ inline void Nghttp2Session::SendPendingData() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
uv_buf_t dest;
|
uv_buf_t dest;
|
||||||
AllocateSend(SEND_BUFFER_RECOMMENDED_SIZE, &dest);
|
AllocateSend(&dest);
|
||||||
size_t destLength = 0; // amount of data stored in dest
|
size_t destLength = 0; // amount of data stored in dest
|
||||||
size_t destRemaining = dest.len; // amount space remaining in dest
|
size_t destRemaining = dest.len; // amount space remaining in dest
|
||||||
size_t destOffset = 0; // current write offset of dest
|
size_t destOffset = 0; // current write offset of dest
|
||||||
|
@ -42,7 +42,6 @@ class Nghttp2Stream;
|
|||||||
struct nghttp2_stream_write_t;
|
struct nghttp2_stream_write_t;
|
||||||
|
|
||||||
#define MAX_BUFFER_COUNT 16
|
#define MAX_BUFFER_COUNT 16
|
||||||
#define SEND_BUFFER_RECOMMENDED_SIZE 4096
|
|
||||||
|
|
||||||
enum nghttp2_session_type {
|
enum nghttp2_session_type {
|
||||||
NGHTTP2_SESSION_SERVER,
|
NGHTTP2_SESSION_SERVER,
|
||||||
@ -178,7 +177,7 @@ class Nghttp2Session {
|
|||||||
virtual ssize_t GetPadding(size_t frameLength,
|
virtual ssize_t GetPadding(size_t frameLength,
|
||||||
size_t maxFrameLength) { return 0; }
|
size_t maxFrameLength) { return 0; }
|
||||||
virtual void OnFreeSession() {}
|
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; }
|
virtual bool HasGetPaddingCallback() { return false; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user