Hello!
I know its a bit early, but with 1.9 out and the ability to view heap snapshots with Chromium, I’m wondering if there are any plans to integrate the ability to view the snapshots in VSCode via the Julia extension?
1 Like
I just saw that VSCode has added the ability to view heap snapshots natively . It is presented in the context of a JS debugger though.
Is there any possibility to leverage this to view Julia generated heap snapshots within VSCode?
I just tried but I get an error when trying to open the .heapsnapshot
file that says Error: invalid profile JSON
.
2 Likes
@davidanthoff @pfitzseb any news on this front?
nsajko
September 11, 2024, 9:21pm
5
FTR this works nowadays:
JuliaLang:master
← IanButterworth:ib/heap_vscode
opened 03:45AM - 24 Mar 24 UTC
- Fixes https://github.com/JuliaLang/julia/issues/52680
- Tidies up streamed fi… les when not explicitly using streamed mode
Tested against https://github.com/microsoft/vscode-v8-heap-tools/tree/main/v8-heap-parser by copying a julia heapsnapshot into the `test` dir as `basic.heapsnapshot` and running `cargo test`
Update: This is working, except for the graph view, which appears to be an upstream issue https://github.com/microsoft/vscode-js-profile-visualizer/issues/175
---
Original issues
With these changes, it still fails, but because of the middle line here
```
"codelocs",
"�\u0003",
"<generic memory - malloc>",
```
with
```
failures:
---- decoder::tests::test_basic_heapsnapshot stdout ----
thread 'decoder::tests::test_basic_heapsnapshot' panicked at v8-heap-parser/src/decoder.rs:574:33:
expect no errors: Error("invalid unicode code point", line: 6020770, column: 9)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- graph::tests::test_retained_sizes stdout ----
thread 'graph::tests::test_retained_sizes' panicked at v8-heap-parser/src/graph.rs:719:45:
expect no errors: Error("invalid unicode code point", line: 6020770, column: 9)
failures:
decoder::tests::test_basic_heapsnapshot
graph::tests::test_retained_sizes
```
If I manually empty that string the only test that fails is a content comparison against a fixed reference.
Does the string sanitizer need fixing or is this some other issue?
However.. the string-fixed file loads in neither chrome devtools, nor vscode's viewer.
I'm opening this in case you see the issue, @vilterp @NHDaly
JuliaLang:master
← IanButterworth:ib/heapsnapshot_char_fix
opened 12:56AM - 07 Apr 24 UTC
Followup to https://github.com/JuliaLang/julia/pull/53833
Fixes a failure seen … in https://github.com/JuliaLang/julia/pull/53974 (below)
I believe this is the more correct check to make?
The heapsnapshot generated from this PR is viewable in vscode.
```
2024-04-06 09:33:58 EDT From worker 7: ERROR: Base.InvalidCharError{Char}('\xc1\xae')
2024-04-06 09:33:58 EDT From worker 7: Stacktrace:
2024-04-06 09:33:58 EDT From worker 7: [1] throw_invalid_char(c::Char)
2024-04-06 09:33:58 EDT From worker 7: @ Base ./char.jl:86
2024-04-06 09:33:58 EDT From worker 7: [2] UInt32
2024-04-06 09:33:58 EDT From worker 7: @ ./char.jl:133 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [3] category_code
2024-04-06 09:33:58 EDT From worker 7: @ ./strings/unicode.jl:339 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [4] isassigned
2024-04-06 09:33:58 EDT From worker 7: @ ./strings/unicode.jl:355 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [5] isassigned
2024-04-06 09:33:58 EDT From worker 7: @ /cache/build/tester-amdci5-14/julialang/julia-master/julia-41d026beaf/share/julia/stdlib/v1.12/Unicode/src/Unicode.jl:138 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [6] print_str_escape_json(stream::IOStream, s::String)
2024-04-06 09:33:58 EDT From worker 7: @ Profile.HeapSnapshot /cache/build/tester-amdci5-14/julialang/julia-master/julia-41d026beaf/share/julia/stdlib/v1.12/Profile/src/heapsnapshot_reassemble.jl:239
2024-04-06 09:33:59 EDT From worker 7: [7] (::Profile.HeapSnapshot.var"#5#6"{IOStream})(strings_io::IOStream)
2024-04-06 09:33:59 EDT From worker 7: @ Profile.HeapSnapshot /cache/build/tester-amdci5-14/julialang/julia-master/julia-41d026beaf/share/julia/stdlib/v1.12/Profile/src/heapsnapshot_reassemble.jl:192
```
I believe the changes were also backported to v1.10.
EDIT: the heap snapshots produces by Julia are now viewable in VS Code (with the ms-vscode.vscode-js-profile-flame
extension), but not in Chromium:
opened 06:05PM - 08 May 24 UTC
kind:regression
profiler
```
julia> using Profile
julia> Profile.take_heap_snapshot("1.11.heapsnapsho… t")
"1.11.heapsnapshot"
```
Trying to load this in Chrome leads to
```
An error occurred when a call to method 'buildSnapshot' was requested
TypeError: Cannot read properties of undefined (reading '1')
at F.name (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:8216)
at F.rawName (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:38825)
at F.name (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:39038)
at F.isDocumentDOMTreesRoot (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:40431)
at b.isUserRoot (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:35720)
at b.calculateDistances (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:18912)
at b.calculateDistances (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:35160)
at b.initialize (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:14141)
at new b (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:33684)
at A.buildSnapshot (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:43578)
```
On 1.10 the same procedure works fine.