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

Heapsnapshot has some unrooted objects #52432

Closed
NHDaly opened this issue Dec 6, 2023 · 8 comments · Fixed by #52618
Closed

Heapsnapshot has some unrooted objects #52432

NHDaly opened this issue Dec 6, 2023 · 8 comments · Fixed by #52618
Labels
bug Indicates an unexpected problem or unintended behavior profiler

Comments

@NHDaly
Copy link
Member

NHDaly commented Dec 6, 2023

The heapsnapshots seem to be missing either some edges or maybe some roots, or maybe both, but somehow many objects end up not retained by any roots, which is of course nonsense, since they couldn't have been exported if they're not reachable from a root (since unrooted things are garbage).

You can see that in this simple repro:

julia> using Profile

julia> Profile.take_heap_snapshot("1.11.0-DEV.638.heapsnapshot")
"1.11.0-DEV.638.heapsnapshot"

1.11.0-DEV.638.heapsnapshot.zip

You can see in the screenshot that the roots are only retaining 87% of the heap snapshot. (in another attempt, i got only 5,000 bytes out of 120 MB!)
Screenshot 2023-12-06 at 3 25 50 PM

And you can see here that one random object has retainers that don't terminate in a root:

Screenshot 2023-12-06 at 3 27 57 PM

From randomly clicking around so far, it seems to often be Arrays that aren't parented, and so i wonder if we're missing some edge somewhere for arrays?

@NHDaly NHDaly added bug Indicates an unexpected problem or unintended behavior profiler labels Dec 6, 2023
@NHDaly
Copy link
Member Author

NHDaly commented Dec 6, 2023

(@JianFangAtRai from RAI is going to look into this this month.)

@IanButterworth
Copy link
Member

IanButterworth commented Dec 8, 2023

vscode just added a built-in .heapsnapshot viewer which looks to have an interesting graph viewer. However trying to open a julia-generated .heapsnapshot file just spins without any indication why (I found that chrome generated ones load immediately).

Perhaps this issue is related?

@JianFangAtRai
Copy link
Contributor

vscode just added a built-in .heapsnapshot viewer which looks to have an interesting graph viewer. However trying to open a julia-generated .heapsnapshot file just spins without any indication why (I found that chrome generated ones load immediately).

Perhaps this issue is related?

Are the sizes of the two files equal or close? Could the file size be an issue here?

@IanButterworth
Copy link
Member

IanButterworth commented Dec 31, 2023

#52618 didn't fix the vscode viewer hang unfortnately

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)


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
    },

@NHDaly
Copy link
Member Author

NHDaly commented Dec 31, 2023 via email

@IanButterworth
Copy link
Member

Will do. So #52618 should have closed this issue?

@NHDaly
Copy link
Member Author

NHDaly commented Jan 3, 2024

I think so, yeah! 👍 Lemme add that to the PR description.

@NHDaly
Copy link
Member Author

NHDaly commented Jan 3, 2024

Ah, @JianFangAtRai even already had it in PR description already:

This PR is to fix the issue: #52432

I think it just didn't get picked up by GitHub's automations. Closing this ticket now. Thanks again Jian!

@NHDaly NHDaly closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior profiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants