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

Heap snapshots aren't viewable in vscode viewer #52680

Closed
IanButterworth opened this issue Dec 31, 2023 · 8 comments · Fixed by #53833
Closed

Heap snapshots aren't viewable in vscode viewer #52680

IanButterworth opened this issue Dec 31, 2023 · 8 comments · Fixed by #53833
Labels

Comments

@IanButterworth
Copy link
Sponsor Member

vscode now has a built in heapsnapshot viewer that seems more powerful than the chrome devtools one.

Unfortunately julia-generated heapsnapshot files do not open and report Error: invalid profile JSON, whilst they open in devtools.

File sizes:

  • from a chrome webpage: 5 MB (renders instantly)
  • from a fresh julia session: 175 MB (hangs indefinitely and reports Error: invalid profile JSON)
2023-12-30 19:27:38.621 [info] ExtensionService#_doActivateExtension ms-vscode.vscode-js-profile-table, startup: false, activationEvent: 'onCustomEditor:jsProfileVisualizer.heapsnapshot.table'
2023-12-30 19:27:38.772 [error] UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "invalid profile JSON".

Asked upstream at microsoft/vscode#199239 (comment) with a file attached.

Both files validate in jsonlint.com

Headers:
julia's

{
    "snapshot": {
        "meta": {
            "node_fields": [
                "type",
                "name",
                "id",
                "self_size",
                "edge_count",
                "trace_node_id",
                "detachedness"
            ],
            "node_types": [
                [
                    "synthetic",
                    "jl_task_t",
                    "jl_module_t",
                    "jl_array_t",
                    "object",
                    "jl_datatype_t",
                    "String",
                    "jl_sym_t",
                    "jl_svec_t"
                ],
                "string",
                "number",
                "number",
                "number",
                "number",
                "number"
            ],
            "edge_fields": [
                "type",
                "name_or_index",
                "to_node"
            ],
            "edge_types": [
                [
                    "internal",
                    "element",
                    "hidden",
                    "property"
                ],
                "string_or_number",
                "from_node"
            ]
        },
        "node_count": 911769,
        "edge_count": 3024013
    },

Chrome's

{
    "snapshot": {
        "meta": {
            "node_fields": [
                "type",
                "name",
                "id",
                "self_size",
                "edge_count",
                "trace_node_id",
                "detachedness"
            ],
            "node_types": [
                [
                    "hidden",
                    "array",
                    "string",
                    "object",
                    "code",
                    "closure",
                    "regexp",
                    "number",
                    "native",
                    "synthetic",
                    "concatenated string",
                    "sliced string",
                    "symbol",
                    "bigint",
                    "object shape"
                ],
                "string",
                "number",
                "number",
                "number",
                "number",
                "number"
            ],
            "edge_fields": [
                "type",
                "name_or_index",
                "to_node"
            ],
            "edge_types": [
                [
                    "context",
                    "element",
                    "property",
                    "internal",
                    "hidden",
                    "shortcut",
                    "weak"
                ],
                "string_or_number",
                "node"
            ],
            "trace_function_info_fields": [
                "function_id",
                "name",
                "script_name",
                "script_id",
                "line",
                "column"
            ],
            "trace_node_fields": [
                "id",
                "function_info_index",
                "count",
                "size",
                "children"
            ],
            "sample_fields": [
                "timestamp_us",
                "last_assigned_id"
            ],
            "location_fields": [
                "object_index",
                "script_id",
                "line",
                "column"
            ]
        },
        "node_count": 58856,
        "edge_count": 245569,
        "trace_function_count": 0
    },

cc. @NHDaly

@IanButterworth
Copy link
Sponsor Member Author

@vilterp from your work, do you have any idea why this happens?

@vilterp
Copy link
Contributor

vilterp commented Feb 6, 2024

I don't immediately know 😕 Seems like we'd have to find the source of the vscode viewer and look through it til we find what it doesn't like…

@vilterp
Copy link
Contributor

vilterp commented Feb 6, 2024

Chased it over to this repo and it looks like they wrote the .heapsnapshot parser in Rust, lol: https://github.com/microsoft/vscode-v8-heap-tools/blob/main/v8-heap-parser/src/decoder.rs

It does have a test/ directory with an example heap snapshot; we could put ours alongside it and debug from there.

@IanButterworth
Copy link
Sponsor Member Author

Great. I think part of the problem may be their extension suppressing the actual error. If we can figure out how to use the rust decoder directly it might just give a better error?

@vilterp
Copy link
Contributor

vilterp commented Feb 6, 2024

Indeed, ran their tests on our file and got

'Error("missing field `trace_function_info_fields`", line: 1, column: 434)', v8-heap-parser/src/decoder.rs:574:33

Looks like we'd need to match these fields exactly for the rust parser to work as-is: https://github.com/microsoft/vscode-v8-heap-tools/blob/c5b34396392397925ecbb4ecb904a27a2754f2c1/v8-heap-parser/src/decoder.rs#L48-L50

@IanButterworth
Copy link
Sponsor Member Author

Are they easy to drop in and leave empty? I think the vscode viewer has a graph viewer that might be interesting for your other work

@vilterp
Copy link
Contributor

vilterp commented Feb 7, 2024

Yes, I think we should be able to drop them in and leave them empty.

What does the graph view look like? When I use it in my vscode I only see a table.

@IanButterworth
Copy link
Sponsor Member Author

IanButterworth commented Feb 7, 2024

Great. There's a screenshot here

https://code.visualstudio.com/updates/v1_85#_visualize-heap-snapshots

image

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

Successfully merging a pull request may close this issue.

2 participants