Skip to content

Add a HeapSnapshotAnalysis pass #7486

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tlively
Copy link
Member

@tlively tlively commented Apr 11, 2025

Chrome and Edge DevTools can capture heap snapshots, which are JSON
representations of the entire object graph at a moment in time. Add a
pass that can parse such a snapshot and report statistics about how much
of the heap is occupied by Wasm objects and what the top types are by
cumulative heap size and allocation count.

Chrome and Edge DevTools can capture heap snapshots, which are JSON
representations of the entire object graph at a moment in time. Add a
pass that can parse such a snapshot and report statistics about how much
of the heap is occupied by Wasm objects and what the top types are by
cumulative heap size and allocation count.
@tlively tlively requested a review from kripken April 11, 2025 01:43
@tlively
Copy link
Member Author

tlively commented Apr 11, 2025

I'll add a test for this before we land it. I'm also open to suggestions of interesting analyses to run. I don't have a heap snapshot of a module with a name section, but eventually I would like to support printing details of the type definitions when I can match up names in the snapshot to names in the module.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Please add a test (unless this is not meant for landing).

#include "support/file.h"
#include "support/json.h"
#include "wasm.h"

Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment explaining the pass.

@@ -220,6 +220,10 @@ void PassRegistry::registerPasses() {
createTypeRefiningGUFAPass);
registerPass(
"heap2local", "replace GC allocations with locals", createHeap2LocalPass);
registerPass("heap-snapshot-analysis",
"Ingest a Chrome DevTools heap snapshot and analysize the "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Ingest a Chrome DevTools heap snapshot and analysize the "
"ingest a Chrome DevTools heap snapshot and analyze the "

Copy link
Member Author

Choose a reason for hiding this comment

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

lol "analysize" 😂

@@ -426,6 +437,16 @@ struct Value {
return obj->count(x) > 0;
}

Ref maybeGet(IString x) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this doing JS-like property access on an object? Please add a comment. And, should the if below be an assert perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants