How to understand the ProfileView output

Hello Everyone,

Similar as this topic, i want to understand the profileview output. The test code is as Following:


init() = begin
    n = 250
    a1 = Vector{Vector{Float64}}(undef, n)
    for i in 1:n 
        a1[i] = [rand(), rand()]
    end
    a1
end

# without multithreading
round_serial(a1) = begin
    n = length(a1)
    a2 = Vector{Vector{Float64}}(undef, n)
    for i in 1:n 
        a2[i] = [round(x, digits=5) for x in a1[i]]
    end
    a2
end

# with multithreading
round_parallel(a1) = begin
    n = length(a1)
    a3 = Vector{Vector{Float64}}(undef, n)
    Threads.@threads for i in 1:n 
        a3[i] = [round(x, digits=5) for x in a1[i]]
    end
    a3
end

a1 = init()
a2 = @elapsed @profview round_serial(a1)
a3 = @elapsed @profview round_parallel(a1)

Profile plot for round_serial(a1) looks like:


Profile plot for round_parallel(a1) looks like:

The Base funcstions are not that I’m familiar with. I have read topic and I have not @profile in my code, so I dont know, how to eliminate the white spaces. And i want to know, what is the crucial message of those both plots, which i should extract with my brain. Because i m not sure, which base function corresponds to which line of code. If there is any documentation about understanding profile plot, I would be happy to read it.

I would have imagined you might have found it already, but GitHub - timholy/ProfileView.jl: Visualization of Julia profiling data, but describes how to interpret the bars. It’s worth running that specific example interactively while reading the documentation.

With regards to your threaded implementation, there have been significant enhancements in profiling threads in Julia 1.8. I highly recommend downloading the current 1.8-beta and trying that.

1 Like

Sorry for my late reply and thanks for your answer! I have roughly read this page https://github.com/timholy/ProfileView.jl and I want to ask for a better understanding, are the white spaces of the 2. plot the load time for the macro threads?

White space indicates that no Julia code is running. By default, ProfileView suppresses bars that come from C code, but you can show them with ProfieView.view(; C=true). But it could also be that the process is sleeping. For deeper investigation of why, you really shouldn’t waste your time with anything earlier than Julia-1.8.