[ANN] ProfileCanvas.jl

ProfileCanvas.jl

ProfileCanvas.jl is a drop-in replacement for ProfileView.jl and ProfileSVG.jl.

It exposes the HTML canvas based profile viewer UI used by the Julia extension for VS Code in the REPL and environments that can display HTML (like Pluto notebooks). Performance should be significantly better than SVG-based solutions, especially for very large traces.

Usage

using ProfileCanvas
function profile_test(n)
    for i = 1:n
        A = randn(100,100,20)
        m = maximum(A)
        Am = mapslices(sum, A; dims=2)
        B = A[:,:,5]
        Bsort = mapslices(sort, B; dims=1)
        b = rand(100)
        C = B.*b
    end
end

@profview profile_test(1)  # run once to trigger compilation (ignore this one)
@profview profile_test(10)

results in


being opened in your browser when run from the REPL and

in a Pluto notebook.

45 Likes

and environments that can display HTML (like Pluto notebooks)

IJulia/Jupyter as well then, I guess?

Probably, but I didn’t test that :slight_smile:

Looks great, thank you!

How much scope is there for reactive interaction/control from Pluto? I can imagine that would be really useful.

What were you thinking of? Integrating the click handler to open referenced files is something I’d definitely like to do, but not too much else came to mind.

That would be very nice! Even Pluto doesn’t have that (AFAIK).

I was thinking about if it was possible to modify the ProfView object before drawing, so that you could perform arbitrary logic on it and then render.

You could then write your own filtering names of functions, restricting the time window, limiting depth. If the user has access to the raw profile, they can write any type of clever tools on top of this view.

Julia 1.8’s new allocation profiler is now supported via the @profview_alloc macro:

28 Likes

AWESOME! Well done

4 Likes