-
Notifications
You must be signed in to change notification settings - Fork 391
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
Convert Luau heap dumps to Chrome heap snapshots #1554
Convert Luau heap dumps to Chrome heap snapshots #1554
Conversation
tools/heapsnapshot.py
Outdated
def getUniqueId(address): | ||
# Addresses are hexadecimal strings | ||
return int(address, 16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach breaks the "reveal in summary" button (and potentially other small features). I suspect it's due to storing the id as an int within chrome's C++ layer and it overflows. I can resolve his by incrementing a counter instead to generate ids, but then the diff view would be broken as that relies on stable ids across snapshots. Maybe there's a hash function I can use here? I'm open to ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a todo for this as well. I'll follow-up with a PR if I find a nice hash function
if "metatable" in obj: | ||
edgeCount += 1 | ||
addEdge([edgeTypeToMetaIndex["internal"], getStringSnapshotIndex(f'metatable ({obj["metatable"]})'), getNodeSnapshotIndex(obj["metatable"])]) | ||
addNode([nodeTypeToMetaIndex["object"], getStringSnapshotIndex(name), getUniqueId(address), obj["size"], edgeCount, 0, 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit lazy here wrt detecting "arrays" vs "objects" and just called them all objects. I'm not sure if there's much value in distinguishing them, but I'm open to reworking this to accommodate that if we want to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a todo for now
This is awesome ⭐ ⭐ ⭐ ⭐ ⭐ |
Adds a script for (approximately) converting Luau heap dumps to Chrome heap snapshots. Useful for visually inspecting a heap dump within Chrome's UI.