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

Debugging: Stabilize hidden classes for improved heap snapshots #8912

Closed
Raynos opened this issue Oct 3, 2016 · 11 comments
Closed

Debugging: Stabilize hidden classes for improved heap snapshots #8912

Raynos opened this issue Oct 3, 2016 · 11 comments
Labels
good first issue Issues that are suitable for first-time contributors. http Issues or PRs related to the http subsystem.

Comments

@Raynos
Copy link
Contributor

Raynos commented Oct 3, 2016

  • Version: 4.4.7
  • Platform: linux
  • Subsystem: http

Currently the http client does not have stable hidden classes so it's hard to debug it.

For example:

These are two different fields that do not exist in the constructor ( https://github.com/nodejs/node/blob/master/lib/_http_client.js#L18-L202 ).

We need to add self.res = null; self.aborted = 0;

Without a stable hidden class for the ClientRequest ( one that doesn't change at runtime ) it's very hard to debug the state of a heap using a heapsnapshot

image

This heapsnapshot is missing the res and aborted fields. Having these fields available would make it a lot easier to reason about the state of the ClientRequest ( I have a memory leak where I am leaking outbound ClientRequest instances ).

I'm sure that this problem exists for a lot of other internal classes within the code.

@MylesBorins
Copy link
Contributor

@Raynos is this problem in v6 as well? Would the solution be simply adding those fields in the constructor?

@Raynos
Copy link
Contributor Author

Raynos commented Oct 3, 2016

This applies to 4.x & master. I did not check 6.x, I assume 6.x and master are the same.

@MylesBorins
Copy link
Contributor

/cc @nodejs/http

@MylesBorins MylesBorins added the http Issues or PRs related to the http subsystem. label Oct 3, 2016
@cjihrig cjihrig added the good first issue Issues that are suitable for first-time contributors. label Oct 3, 2016
@cjihrig
Copy link
Contributor

cjihrig commented Oct 3, 2016

Adding the good first contribution label.

@mscdex mscdex removed the v4.x label Oct 3, 2016
@shmuga
Copy link
Contributor

shmuga commented Oct 3, 2016

Can take this one.
But what should we do with static variable listed in _http_client?
I tried to remove it locally and run tests and they passed. But is that right decision?

@Raynos
Copy link
Contributor Author

Raynos commented Oct 3, 2016

Personally, having variables defined on the prototype is more messy then defining them in the constructor.

@AnnaMag
Copy link
Member

AnnaMag commented Oct 6, 2016

@shmuga are you working on this?

@benjamingr
Copy link
Member

It's also slower to define them on the prototype. It's a good idea to always define properties used statically - even as null.

@Fishrock123
Copy link
Contributor

Doing this would probably also help performance.

vitkarpov added a commit to vitkarpov/node that referenced this issue Jan 10, 2017
res and abort fields are now defined in the constructor and not suddenly appear during the runtime. This makes hidden class stable and the heap snapshot more verbose.

Ref: nodejs#8912
PR-URL: nodejs#9116
mscdex pushed a commit that referenced this issue Jan 10, 2017
Adding all used properties in the constructor makes the hidden class
stable and heap snapshots more verbose.

Refs: #8912
PR-URL: #9116
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@thefourtheye
Copy link
Contributor

a2ea134 addresses this in the master.

@mscdex
Copy link
Contributor

mscdex commented Jan 10, 2017

Closing this for now, as the commit @thefourtheye mentioned should take care of this.

@mscdex mscdex closed this as completed Jan 10, 2017
italoacasas pushed a commit to italoacasas/node that referenced this issue Jan 18, 2017
Adding all used properties in the constructor makes the hidden class
stable and heap snapshots more verbose.

Refs: nodejs#8912
PR-URL: nodejs#9116
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this issue Jan 23, 2017
Adding all used properties in the constructor makes the hidden class
stable and heap snapshots more verbose.

Refs: nodejs#8912
PR-URL: nodejs#9116
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this issue Jan 25, 2017
Adding all used properties in the constructor makes the hidden class
stable and heap snapshots more verbose.

Refs: nodejs#8912
PR-URL: nodejs#9116
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this issue Jan 27, 2017
Adding all used properties in the constructor makes the hidden class
stable and heap snapshots more verbose.

Refs: nodejs#8912
PR-URL: nodejs#9116
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

9 participants