Skip to content

Commit

Permalink
src: make edge names in BaseObjects more descriptive in heap snapshots
Browse files Browse the repository at this point in the history
Previously these were named "wrapper" and "wrapped", which can be
somewhat difficult to understand. This patch renames them to
"javascript_to_native" and "native_to_javascript".

PR-URL: #46492
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
joyeecheung authored and danielleadams committed Apr 3, 2023
1 parent 5efb829 commit 9445a0a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/memory_tracker-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ MemoryRetainerNode* MemoryTracker::AddNode(const MemoryRetainer* retainer,
if (CurrentNode() != nullptr) graph_->AddEdge(CurrentNode(), n, edge_name);

if (n->JSWrapperNode() != nullptr) {
graph_->AddEdge(n, n->JSWrapperNode(), "wrapped");
graph_->AddEdge(n->JSWrapperNode(), n, "wrapper");
graph_->AddEdge(n, n->JSWrapperNode(), "native_to_javascript");
graph_->AddEdge(n->JSWrapperNode(), n, "javascript_to_native");
}

return n;
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-heapdump-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ validateSnapshotNodes('Node / ChannelWrap', [
children: [
{ node_name: 'Node / NodeAresTask::List', edge_name: 'task_list' },
// `Node / ChannelWrap` (C++) -> `ChannelWrap` (JS)
{ node_name: 'ChannelWrap', edge_name: 'wrapped' },
{ node_name: 'ChannelWrap', edge_name: 'native_to_javascript' },
],
detachedness: 2
},
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-heapdump-fs-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fs.stat(__filename);
validateSnapshotNodes('Node / FSReqPromise', [
{
children: [
{ node_name: 'FSReqPromise', edge_name: 'wrapped' },
{ node_name: 'FSReqPromise', edge_name: 'native_to_javascript' },
{ node_name: 'Float64Array', edge_name: 'stats_field_array' },
]
},
Expand Down
12 changes: 6 additions & 6 deletions test/pummel/test-heapdump-http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ server.listen(0, () => {
{
children: [
// current_headers and/or queue could be empty
{ node_name: 'Http2Stream', edge_name: 'wrapped' },
{ node_name: 'Http2Stream', edge_name: 'native_to_javascript' },
]
},
], { loose: true });
Expand All @@ -37,38 +37,38 @@ server.listen(0, () => {
state.validateSnapshotNodes('Node / FileHandle', [
{
children: [
{ node_name: 'FileHandle', edge_name: 'wrapped' },
{ node_name: 'FileHandle', edge_name: 'native_to_javascript' },
// current_headers could be empty
]
},
], { loose: true });
state.validateSnapshotNodes('Node / TCPSocketWrap', [
{
children: [
{ node_name: 'TCP', edge_name: 'wrapped' },
{ node_name: 'TCP', edge_name: 'native_to_javascript' },
]
},
], { loose: true });
state.validateSnapshotNodes('Node / TCPServerWrap', [
{
children: [
{ node_name: 'TCP', edge_name: 'wrapped' },
{ node_name: 'TCP', edge_name: 'native_to_javascript' },
]
},
], { loose: true });
// `Node / StreamPipe` (C++) -> StreamPipe (JS)
state.validateSnapshotNodes('Node / StreamPipe', [
{
children: [
{ node_name: 'StreamPipe', edge_name: 'wrapped' },
{ node_name: 'StreamPipe', edge_name: 'native_to_javascript' },
]
},
]);
// `Node / Http2Session` (C++) -> Http2Session (JS)
state.validateSnapshotNodes('Node / Http2Session', [
{
children: [
{ node_name: 'Http2Session', edge_name: 'wrapped' },
{ node_name: 'Http2Session', edge_name: 'native_to_javascript' },
{ node_name: 'Node / nghttp2_memory', edge_name: 'nghttp2_memory' },
{
node_name: 'Node / streams', edge_name: 'streams'
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-heapdump-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const snapshotNode = {
{
children: [
{ node_name: 'Node / InspectorSession', edge_name: 'session' },
{ node_name: 'Connection', edge_name: 'wrapped' },
{ node_name: 'Connection', edge_name: 'native_to_javascript' },
(edge) => edge.name === 'callback' &&
(edge.to.type === undefined || // embedded graph
edge.to.type === 'closure'), // snapshot
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-heapdump-tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const server = net.createServer(common.mustCall((c) => {
{ node_name: 'Node / NodeBIO', edge_name: 'enc_out' },
{ node_name: 'Node / NodeBIO', edge_name: 'enc_in' },
// `Node / TLSWrap` (C++) -> `TLSWrap` (JS)
{ node_name: 'TLSWrap', edge_name: 'wrapped' },
{ node_name: 'TLSWrap', edge_name: 'native_to_javascript' },
// pending_cleartext_input could be empty
]
},
Expand Down
4 changes: 2 additions & 2 deletions test/pummel/test-heapdump-zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const gzip = zlib.createGzip();
validateSnapshotNodes('Node / ZlibStream', [
{
children: [
{ node_name: 'Zlib', edge_name: 'wrapped' },
{ node_name: 'Zlib', edge_name: 'native_to_javascript' },
// No entry for memory because zlib memory is initialized lazily.
]
},
Expand All @@ -20,7 +20,7 @@ gzip.write('hello world', common.mustCall(() => {
validateSnapshotNodes('Node / ZlibStream', [
{
children: [
{ node_name: 'Zlib', edge_name: 'wrapped' },
{ node_name: 'Zlib', edge_name: 'native_to_javascript' },
{ node_name: 'Node / zlib_memory', edge_name: 'zlib_memory' },
]
},
Expand Down

0 comments on commit 9445a0a

Please sign in to comment.