-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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: improve perf of passing headers to JS #14808
Conversation
Original commit message: lib: add nghttp2_rcbuf_is_static() Add a `nghttp2_rcbuf_is_static()` method to tell whether a rcbuf is statically allocated. This can be useful for language bindings that wish to avoid creating duplicate strings for these buffers; concretely, I am planning to use this in the Node HTTP/2 module that is being introduced. Ref: nghttp2/nghttp2@eb306f4
- Make `ExternalString::New` return a `MaybeLocal`. Failing is left up to the caller. - Allow creating internalized strings for short header names to reduce memory consumption and increase performance. - Use persistent storage for statically allocated header names.
|
||
if (str.IsEmpty()) { | ||
ExternalHeader* h_str = new ExternalHeader(buf); | ||
MaybeLocal<String> str = String::NewExternalOneByte(env->isolate(), h_str); |
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.
Is the AdjustAmountOfExternalAllocatedMemory
call deliberately removed?
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.
Yes, because we did not inform V8 about the reverse situation in which we freed the corresponding memory. We either need to do both calls or none of them.
It was a bogus measure anyway, the buffers are reference counted and often can be the same. A much better thing to do would be to provide custom malloc functions to nghttp2, so we can actually watch allocations happen and report them to V8, but that’s a different story.
Nice :) side note: just in case you hadn't seen it yet, we can give nghttp2 a custom allocator. |
@jasnell Yes, but … so many things to do ;) |
Rather than cherry picking an upstream commit, we may as well update the entire library at this point. |
@jasnell Idk, I would be completely fine with that but don’t we usually wait for releases to do full upstream updates? |
Yeah, we're currently on 1.22 but the current is 1.24 I think. |
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
CI: https://ci.nodejs.org/job/node-test-commit/11865/ This should be ready. |
Original commit message: lib: add nghttp2_rcbuf_is_static() Add a `nghttp2_rcbuf_is_static()` method to tell whether a rcbuf is statically allocated. This can be useful for language bindings that wish to avoid creating duplicate strings for these buffers; concretely, I am planning to use this in the Node HTTP/2 module that is being introduced. Ref: nghttp2/nghttp2@eb306f4 PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
- Make `ExternalString::New` return a `MaybeLocal`. Failing is left up to the caller. - Allow creating internalized strings for short header names to reduce memory consumption and increase performance. - Use persistent storage for statically allocated header names. PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
Original commit message: lib: add nghttp2_rcbuf_is_static() Add a `nghttp2_rcbuf_is_static()` method to tell whether a rcbuf is statically allocated. This can be useful for language bindings that wish to avoid creating duplicate strings for these buffers; concretely, I am planning to use this in the Node HTTP/2 module that is being introduced. Ref: nghttp2/nghttp2@eb306f4 PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
- Make `ExternalString::New` return a `MaybeLocal`. Failing is left up to the caller. - Allow creating internalized strings for short header names to reduce memory consumption and increase performance. - Use persistent storage for statically allocated header names. PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
Original commit message: lib: add nghttp2_rcbuf_is_static() Add a `nghttp2_rcbuf_is_static()` method to tell whether a rcbuf is statically allocated. This can be useful for language bindings that wish to avoid creating duplicate strings for these buffers; concretely, I am planning to use this in the Node HTTP/2 module that is being introduced. Ref: nghttp2/nghttp2@eb306f4 PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
- Make `ExternalString::New` return a `MaybeLocal`. Failing is left up to the caller. - Allow creating internalized strings for short header names to reduce memory consumption and increase performance. - Use persistent storage for statically allocated header names. PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
ExternalString::New
return aMaybeLocal
. Failing is left up to the caller.Each of the latter two gives about 2.5 % perf in the benchmark (which, again, does a lot more than just reading headers from the stream.)
This does not yet include any work regarding never-indexed header fields, but it should be sufficiently independent from that anyway.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
@nodejs/http2