How to use @profile in Pluto? #1431
Replies: 4 comments 4 replies
-
I found a workaround that doesn't act on the profiling itself but on the generated FlameGraph. It selects the subtree of the FlameGraph where the code is actually run, and discards the time spent waiting on the designated worker. I think it may work as long as the code we profile doesn't use Pluto itself. using AbstractTrees, FlameGraphs
function select_pluto_subgraph(g)
for n in PreOrderDFS(g)
if (
endswith(string(n.data.sf.file), "PlutoRunner.jl") &&
endswith(string(n.data.sf.func), "run_inside_trycatch")
)
return n
end
end
end From there, if we want to profile a function using Profile, ProfileSVG
Profile.clear()
@profile f(args...)
ProfileSVG.view(select_pluto_subgraph(flamegraph())) @fonsp does this look right to you? Would it be interesting to wrap this in a macro, say |
Beta Was this translation helpful? Give feedback.
-
Thanks for pointing this out and for investigating the issue! Note the difference: Multiprocessing (using But they are related: We use multiprocessing to manage different notebook processing, which (I believe) spawns tasks on the notebook process to execute actions in, including code execution. We do not use multithreading in the notebook process (I think). |
Beta Was this translation helpful? Give feedback.
-
It surprises me that internal Pluto code is showing up in the profile. We use |
Beta Was this translation helpful? Give feedback.
-
When I profile my own functions in Pluto, I often end up with three external methods (
task_done_hook
,wait
andpop_task
fromtask.jl
in Base) taking most of the CPU time. See the example below, taken from my course material.From what I understand, it could be linked to multiprocessing, more precisely the fact that Pluto launches each notebook on a separate worker (see #300). Is there a workaround to get precise profiling without the multiprocessing stuff?
Beta Was this translation helpful? Give feedback.
All reactions