-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Comments
@Raynos is this problem in v6 as well? Would the solution be simply adding those fields in the constructor? |
This applies to 4.x & master. I did not check 6.x, I assume 6.x and master are the same. |
/cc @nodejs/http |
Adding the good first contribution label. |
Can take this one. |
Personally, having variables defined on the prototype is more messy then defining them in the constructor. |
@shmuga are you working on this? |
It's also slower to define them on the prototype. It's a good idea to always define properties used statically - even as null. |
Doing this would probably also help performance. |
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
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>
a2ea134 addresses this in the master. |
Closing this for now, as the commit @thefourtheye mentioned should take care of this. |
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>
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>
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>
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>
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 heapsnapshotThis heapsnapshot is missing the
res
andaborted
fields. Having these fields available would make it a lot easier to reason about the state of theClientRequest
( 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.
The text was updated successfully, but these errors were encountered: