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

Convert Luau heap dumps to Chrome heap snapshots #1554

Merged

Conversation

jkelaty-rbx
Copy link
Contributor

@jkelaty-rbx jkelaty-rbx commented Dec 4, 2024

Adds a script for (approximately) converting Luau heap dumps to Chrome heap snapshots. Useful for visually inspecting a heap dump within Chrome's UI.

@jkelaty-rbx jkelaty-rbx marked this pull request as ready for review December 4, 2024 09:35
Comment on lines 76 to 78
def getUniqueId(address):
# Addresses are hexadecimal strings
return int(address, 16)
Copy link
Contributor Author

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.

Copy link
Contributor Author

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])
Copy link
Contributor Author

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

Copy link
Contributor Author

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

@pturner-roblox
Copy link

This is awesome ⭐ ⭐ ⭐ ⭐ ⭐

@vegorov-rbx vegorov-rbx merged commit 8b8118b into luau-lang:master Dec 6, 2024
7 checks passed
@jkelaty-rbx jkelaty-rbx deleted the chrome-heap-snapshot-converter branch December 6, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants