Skip to content
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

http2: adjust stream buffer size #16445

Closed

Conversation

apapirovski
Copy link
Member

@apapirovski apapirovski commented Oct 24, 2017

So I have no idea if there was reasoning for this originally — and if there was feel free to let me know and I'll close — but the current kAllocBufferSize is just a tad too small for fully efficient writes given default window size & frame size. 64 * 1024 will be 35 bytes smaller than the full default window size due to the 4 frame headers that are included.

Obviously this all goes out the window with different frame sizes & window sizes but seems to make sense to at least sort of optimize for the default here.

Here's a log that shows what was happening before the change (note the last few lines)
Nghttp2Session server: Sending pending data
Nghttp2Session server: reading outbound data for stream 13
Nghttp2Session server: stream 13 found
Nghttp2Session server: processing outbound data chunk
Nghttp2Session server: nghttp2 has 16393 bytes to send
Nghttp2Session server: reading outbound data for stream 13
Nghttp2Session server: stream 13 found
Nghttp2Session server: processing outbound data chunk
Nghttp2Session server: nghttp2 has 16393 bytes to send
Nghttp2Session server: reading outbound data for stream 13
Nghttp2Session server: stream 13 found
Nghttp2Session server: processing outbound data chunk
Nghttp2Session server: nghttp2 has 16393 bytes to send
Nghttp2Session server: reading outbound data for stream 13
Nghttp2Session server: stream 13 found
Nghttp2Session server: processing outbound data chunk
Nghttp2Session server: nghttp2 has 16392 bytes to send
Nghttp2Session server: pushing 16357 bytes to the socket
Http2Session: Attempting to send data
Nghttp2Session server: pushing 35 bytes to the socket
Http2Session: Attempting to send data

This also removes the seemingly unused size_t recommended in AllocateSend and the constant it uses SEND_BUFFER_RECOMMENDED_SIZE. Again, let me know if this is here for some future functionality that hasn't been added yet.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

http2

@apapirovski apapirovski added c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. labels Oct 24, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Oct 24, 2017
@@ -818,7 +818,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

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Awesome.. I love it when other people cross items off my todo list :-) ... LGTM!

@apapirovski
Copy link
Member Author

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.
@apapirovski
Copy link
Member Author

Landed in 3690a72

@apapirovski apapirovski deleted the patch-http2-stream-buffer-size branch October 27, 2017 18:46
apapirovski added a commit that referenced this pull request Oct 27, 2017
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>
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
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>
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
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>
gibfahn pushed a commit that referenced this pull request Oct 31, 2017
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>
@gibfahn gibfahn mentioned this pull request Oct 31, 2017
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
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: nodejs/node#16445
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
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: nodejs/node#16445
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
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: nodejs/node#16445
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants