# \[ANN\] PProf.jl -- Explore profiles in style

**URL:** <https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198>\
**Category:** Package Announcements\
**Tags:** package, announcement, performance\
**Created:** [July 9, 2019, 6:36pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198 "2019-07-09T18:36:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [July 9, 2019, 6:36pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198/1 "2019-07-09T18:36:48Z")

</div>

@NHDaly and I recently put our heads together and created an export from Julia’s statistical profiler to [pprof](https://github.com/google/pprof) (a Go based analysis and visualization tool), you can export profiles – send them to a friend; get some nice and responsive flamegraphs; plot weighted callgraphs; diff two profiles, etc!

PProf.jl is registered and if you run into issues please report them over at [GitHub - JuliaPerf/PProf.jl: Export Julia profiles to the pprof format](https://github.com/vchuravy/PProf.jl)

Take a look at [Profiling Go Programs - The Go Programming Language](https://blog.golang.org/profiling-go-programs) for some examples what pprof can do.

---

<div class="post-metadata">

**Author:** ![NHDaly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhdaly/32/1413_2.png) [@NHDaly](https://discourse.julialang.org/u/NHDaly)\
**Post date:** [July 9, 2019, 7:10pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198/2 "2019-07-09T19:10:30Z")

</div>

Profiling your code? More like gofiling your code, amirite

[exits stage left]

---

<div class="post-metadata">

**Author:** ![NHDaly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhdaly/32/1413_2.png) [@NHDaly](https://discourse.julialang.org/u/NHDaly)\
**Post date:** [August 1, 2019, 1:04pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198/3 "2019-08-01T13:04:31Z")

</div>

Updated announcement:

PProf.jl now embeds the precompiled [`google/pprof`](https://github.com/google/pprof) so you can now just install PProf.jl and start profiling! _And on MacOS, Linux, and Windows!_

```julia
using Profile, PProf

# collect a profile
@profile peakflops()

# Export pprof profile and open interactive profiling web interface.
pprof()

```

This immediately (by default) launches an interactive profile viewer in your browser:

 ![05%20AM](https://global.discourse-cdn.com/julialang/original/3X/3/f/3f20de29ee7281aa24ed87d0987014e51d4d5654.png)  
 ![16%20AM](https://global.discourse-cdn.com/julialang/original/3X/3/d/3d6af48e6a116004004e68010b422b7210a59145.png)

It also exports the profile to disk under the name provided in `out = ""`, so you can share the exported profiles with friends, or even diff two profiles.

For now, we don’t provide any julia API on top of the embedded go/pprof binary, but you can access the binary via `PProf.go_pprof`, e.g.:

```julia
run(`$(PProf.go_pprof) -web -diff_base prof1 prof2`)

```

---

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [August 1, 2019, 1:47pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198/4 "2019-08-01T13:47:31Z")

</div>

pretty cool! 2 questions:

- Is it possible to run `@async pprof()` asynchronously and always have the current profile buffer displayed?
- `pprof()` always makes chrome pop up after a few seconds, is there a way to avoid this?

---

<div class="post-metadata">

**Author:** ![NHDaly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhdaly/32/1413_2.png) [@NHDaly](https://discourse.julialang.org/u/NHDaly)\
**Post date:** [August 1, 2019, 2:35pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198/5 "2019-08-01T14:35:21Z")

</div>

> [@gdkrmr](#):
>
> - `pprof()` always makes chrome pop up after a few seconds, is there a way to avoid this?

`web = false` will just export the profile to disk (named via the `out=profile.pb.gz` flag), and will not start the webserver. Currently there is no way to start the webserver and not open chrome; I think the pprof binary opens the link automatically (like jupyter).

> [@gdkrmr](#):
>
> - Is it possible to run `@async pprof()` asynchronously and always have the current profile buffer displayed?

Hmm, i just tried, and while yeah you can totally run pprof() asynchronously, it doesn’t look like pprof watches your profile file. It seems to load the data into memory and then use it, so I don’t think you can update it like that…

It probably wouldn’t be too hard to keep a global instance of `pprof` running asynchronously and restart it when you build a new profile! That would be a nice feature! (Wanna send a PR? 😛)

EDIT:  
@gdkrmr Maybe something like this:

```julia
julia> using Profile, PProf

julia> const port = 24234;

julia> function reload_pprof()
           global pp
           if @isdefined(pp)
               kill(pp)
           end
           pp = run(`$(PProf.go_pprof) -http=localhost:$port profile.pb.gz`, wait=false)
       end;

julia> reload_pprof()
Process(`/Users/nathan.daly/.julia/packages/PProf/5oWcL/deps/usr/bin/pprof -http=localhost:24234 profile.pb.gz`, ProcessRunning)

julia> @profile peakflops()
9.287877477989021e10

julia> pprof(web=false)
"profile.pb.gz"

julia> reload_pprof();
Process(`/Users/nathan.daly/.julia/packages/PProf/5oWcL/deps/usr/bin/pprof -http=localhost:24234 profile.pb.gz`, ProcessRunning)

```

---

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [August 1, 2019, 3:26pm UTC](https://discourse.julialang.org/t/ann-pprof-jl-explore-profiles-in-style/26198/6 "2019-08-01T15:26:14Z")

</div>

made a PR 🙂
