julia icon indicating copy to clipboard operation
julia copied to clipboard

Improve documentation for new allocation profiler

Open gdalle opened this issue 3 years ago • 12 comments

Hi, and thank you for the awesome new allocation profiler!

I feel like it is not obvious from the documentation (manual page and API reference) how to retrieve and visualize the results from Profile.Allocs.@profile.

PProf.jl is mentioned, but not the specific function we need to call (PProf.Allocs.pprof). I think it would make sense to describe an example workflow in the manual (see below).

In addition, I guess users would be interested to know if there is any visualization (eg. @profview) or pretty-printing (eg. Profile.print()) method that works directly in the REPL / VSCode / Pluto.

julia> using Profile, PProf

julia> Profile.Allocs.clear()

julia> peakflops(); Profile.Allocs.@profile sample_rate=1 peakflops()
6.474132101420371e10

julia> results = Profile.Allocs.fetch();

julia> PProf.Allocs.pprof(results; from_c=false)
Analyzing 11 allocation samples... 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:00
Main binary filename not available.
Serving web UI on http://localhost:62261
"alloc-profile.pb.gz"

gdalle avatar May 10 '22 21:05 gdalle

Related discussions:

  • Julia allocation profiler PR (https://github.com/JuliaLang/julia/pull/42768)
  • PProf support PR (https://github.com/JuliaPerf/PProf.jl/pull/46)
  • ProfileView issue (https://github.com/timholy/ProfileView.jl/issues/166)
  • FlameGraphs issue (https://github.com/timholy/FlameGraphs.jl/issues/52)

gdalle avatar May 10 '22 22:05 gdalle

I am using Julia v1.7.3. Why I have no function Profile.Allocs.@profile?

kongdd avatar Jun 27 '22 15:06 kongdd

It's 1.8 and up only unfortunately

gbaraldi avatar Jun 27 '22 16:06 gbaraldi

cc: @vilterp @NHDaly

vchuravy avatar Jun 27 '22 21:06 vchuravy

👍 . Was trying to use this today and the docs are quite underwhelming in describing how it should be used.

KristofferC avatar Jul 04 '22 18:07 KristofferC

Pinging @pfitzseb since the easiest visualization tool might soon be the VSCode extension

gdalle avatar Jul 04 '22 19:07 gdalle

The allocation profile viewer should already be in the latest release of the extension (if I didn't mess up while writing the changelog). Should be as simple as a @profview_allocs (but of course we don't have any real documentation either).

pfitzseb avatar Jul 04 '22 21:07 pfitzseb

There are a few things that I would like to see added to the documentation:

  • there are multiple visualization tools now (just like with CPU profiles), including:
    • PProf
    • VSCode profile viewer
    • viewing the results directly in the REPL
    • ... others?
  • the sample_rate has to be considered carefully (just like with CPU profiling)

Is there anything else that people feel is missing?

NHDaly avatar Aug 16 '22 21:08 NHDaly

cc: @bergel

NHDaly avatar Aug 16 '22 21:08 NHDaly

Just a bump because of confusion in the wild https://discourse.julialang.org/t/what-is-wrong-with-this-code/86695

IanButterworth avatar Sep 02 '22 18:09 IanButterworth

Just a note that the docs should mention clearly shortcomings related to https://github.com/JuliaLang/julia/issues/43688

IanButterworth avatar Sep 13 '22 15:09 IanButterworth

I wrote some code that users can load into Profile.Allocs which works to complete the API with a builtin print function mostly identical to Profile.print, which doesn't need an external tool to be available (though is less interactive than those tools already mentioned here) and can convert from Allocs-format to flat or tree format (including support for most configuration flags): https://gist.github.com/vtjnash/c6aa4db9dafccb0fd28a65f87d6b1adb

vtjnash avatar Sep 20 '22 21:09 vtjnash

@fingolfin helped with https://github.com/JuliaLang/julia/pull/47144

IanButterworth avatar Oct 13 '22 21:10 IanButterworth

Maybe we could add the JuliaCon talk by @NHDaly and @vilterp to the docs? e.g. include it at https://docs.julialang.org/en/v1/manual/profile/#Allocation-Profiler

nickrobinson251 avatar Nov 02 '22 14:11 nickrobinson251

👍 . Was trying to use this today and the docs are quite underwhelming in describing how it should be used.

This section of the docs is still very underwhelming. Some example code is needed.

ojwoodford avatar Jun 01 '23 13:06 ojwoodford

HOKAY - i'm finally taking a stab at improving this, while I'm editing the docs in #50337.

Can you all please take a look and see what else you'd like to add? Thank you! https://github.com/JuliaLang/julia/pull/50337/files#diff-5daf211b5059d9eebb3cea99608a874dfd552ea395cfde31a229141b7720ea90

NHDaly avatar Jul 07 '23 18:07 NHDaly

Here's the current Profiling docs page as of that PR: Profiling docs page.zip

NHDaly avatar Jul 07 '23 18:07 NHDaly