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: track memory allocated by nghttp2 #21374

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

Refs: #21373
Refs: #21336

[blocked by both of these fixes]

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

@addaleax addaleax added blocked PRs that are blocked by other issues or PRs. http2 Issues or PRs related to the http2 subsystem. labels Jun 16, 2018
@addaleax addaleax force-pushed the track-memory-http2 branch from f8aa056 to 922f2ec Compare June 16, 2018 22:09
@jasnell
Copy link
Member

jasnell commented Jun 17, 2018

Woo!

@trivikr trivikr added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 17, 2018
src/node_http2.h Outdated
// Tell our custom memory allocator that this rcbuf is independent of
// this session now, and may outlive it.
void StopTrackingRcbuf(nghttp2_rcbuf* buf);

// Returns the current session memory including the current size of both
// the inflate and deflate hpack headers, the current outbound storage
Copy link
Member

Choose a reason for hiding this comment

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

Might want to change the hpack headers part, as it is no longer visible in code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, done!

@addaleax addaleax force-pushed the track-memory-http2 branch from 922f2ec to 50a9d42 Compare June 20, 2018 20:54
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

Refs: nodejs#21373
Refs: nodejs#21336
@addaleax addaleax force-pushed the track-memory-http2 branch from 50a9d42 to fa8d967 Compare June 20, 2018 20:54
@addaleax addaleax removed the blocked PRs that are blocked by other issues or PRs. label Jun 20, 2018
@addaleax
Copy link
Member Author

Rebased, this should no longer be blocked

CI: https://ci.nodejs.org/job/node-test-pull-request/15544/

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 20, 2018
Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

Still LGTM.

if (mem != nullptr) {
// Adjust the memory info counter.
session->current_nghttp2_memory_ += size - previous_size;
*reinterpret_cast<size_t*>(mem) = size;
Copy link
Member

Choose a reason for hiding this comment

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

It took me a while to realize how this would behave for a size of 0: our UncheckedRealloc implementation will return nullptr in that case, to fill in an implementation-defined gap in the system realloc(). It might be helpful to clarify that.

@ChALkeR ChALkeR added the memory Issues and PRs related to the memory management or memory footprint. label Jun 22, 2018
@apapirovski
Copy link
Member

Landed in 15c627f

apapirovski pushed a commit that referenced this pull request Jun 25, 2018
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

PR-URL: #21374
Refs: #21373
Refs: #21336
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
targos pushed a commit that referenced this pull request Jun 25, 2018
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

PR-URL: #21374
Refs: #21373
Refs: #21336
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@targos targos mentioned this pull request Jul 3, 2018
kjin pushed a commit to kjin/node that referenced this pull request Aug 23, 2018
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

PR-URL: nodejs#21374
Refs: nodejs#21373
Refs: nodejs#21336
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Sep 25, 2018
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

PR-URL: nodejs#21374
Refs: nodejs#21373
Refs: nodejs#21336
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

PR-URL: nodejs#21374
Refs: nodejs#21373
Refs: nodejs#21336
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.

This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.

It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.

Backport-PR-URL: #22850
PR-URL: #21374
Refs: #21373
Refs: #21336
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. memory Issues and PRs related to the memory management or memory footprint.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants