-
Notifications
You must be signed in to change notification settings - Fork 30k
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: set decodeStrings to false, test for createWriteReq #15140
http2: set decodeStrings to false, test for createWriteReq #15140
Conversation
1a54c36
to
0b494e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is how I would test it - but overall LGTM. Thank you for making a contribution!
@benjamingr If you have suggestions, I would be happy to implement/take into consideration for the future. Thanks! |
I am a bit lost on why the |
@mcollina it converts to Buffer before it gets to createWriteReq without |
Can you point me to this code path? |
Here's the full chain that leads to this: Lines 264 to 267 in 1403d28
Lines 339 to 347 in 1403d28
Line 387 in 1403d28
Lines 311 to 316 in d111319
I could've also used |
0b494e6
to
9a231b2
Compare
Updated the commit message and the comment in the test itself. |
It seems al of these are releated to streams, is there an http2 part of this? Otherwise, let's just write a test for streams. |
Sorry, should've been clearer. That's just the code leading up to our node/lib/internal/http2/core.js Line 1384 in 1403d28
node/lib/internal/http2/core.js Lines 1157 to 1177 in 1403d28
Usually we only hit the 'buffer' case, hence switching to objectMode or turning off decodeStrings. |
So, we should be able to receive strings straight into HTTP2. By moving them to buffers we are losing throughput. |
@mcollina Yep, I already started working on PR after this conversation. Thanks for the review! Would it make sense to just update this PR for it or would you prefer a new one? |
9a231b2
to
7598fb4
Compare
Ok, everything has been updated. I added a benchmark too. First benchmark so let me know if I should change anything. It's a substantial speed up btw. Old:
New:
The format of these tests doesn't seem compatible with the compare script but it looks like a 35% speed up even if I'm being conservative, maybe higher. |
@benjamingr @claudiorodriguez this would require a new review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@apapirovski you should follow this guide to compare two nodejs versions https://github.com/nodejs/node/blob/master/doc/guides/writing-and-running-benchmarks.md#comparing-nodejs-versions |
@mcollina Update: Got it to work. Forgot "--set"... *sigh* totally my bad. |
which command did you use in the end? |
This is what I used
I was just forgetting I got about 45% improvement across the board but didn't have time to keep running it for more than 3 runs. Might run it for longer later but I think it's safe to say this is a big improvement. |
I think it's a problem of having a timeout-based test:
Those platforms are slow :( |
@mcollina this one isn't timeout based, this one just writes strings and expects to get the right thing on the other end. Although I think it does have to do with the platform being slow. I think it closes the server before it received everything. Will adjust the test case to be less flaky. Good lesson for me re: writing tests for slower platforms, have to make less assumptions about what is finished and what isn't. |
Set writableStream decodeStrings to false to let the native layer handle converting strings to buffer.
7598fb4
to
7bd0606
Compare
@mcollina I think it should work now. Could we restart the CI? Thanks. |
1 similar comment
CI is green, this is ok to go. |
Set writableStream decodeStrings to false to let the native layer handle converting strings to buffer. PR-URL: #15140 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 2ffc8ac |
Set writableStream decodeStrings to false to let the native layer handle converting strings to buffer. PR-URL: #15140 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Set writableStream decodeStrings to false to let the native layer handle converting strings to buffer. PR-URL: #15140 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Set writableStream decodeStrings to false to let the native layer handle converting strings to buffer. PR-URL: #15140 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Set writableStream decodeStrings to false to let the native layer handle converting strings to buffer. PR-URL: nodejs#15140 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Adds a test for all the encodings in createWriteReq, including the default case. The other option was mocking all the handlers but that didn't seem any better. Also, don't think there's a way to set objectMode without digging into
_writableState
.If anyone has better ideas on how to properly test this, I'm happy to adjust. Thanks!
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
http2, test