About PProf

Dear there,
I’ve a quick question about PProf. I’m using Julia 1.8.4, and I’m learning the new profile tool. So I follow a simple example as below. I first define a function:

function myfunc()
       A = rand(200, 200, 400)
       maximum(A)
end

Then run @time Profile.Allocs.@profile sample_rate=1 myfunc(). Then PProf.Allocs.pprof(from_c = false). And it creats “alloc-profile.pb.gz” as expect, and a web link http://localhost:62261. But the problem is I can’t open this link in any browsers (I’ve tried safari, google chrome and firefox). Do you happen to know how to solve this?

Thank you so much and happy new year!!

Hi, Kristin! Do you work in Julia’s REPL? Last time I used PProf, it seemed that a user has to stay in the REPL, because PProf creates a temporary server for viewing the “alloc-profile.pg.gz”. Exiting the REPL shutdowns the server.

Another option is to examine pprof data using pprof utility.

1 Like

Thanks for your reply! Yes I’m in Julia’s REPL. I run julia on a cluster, and I got the following web link, then I copy and paste to a browsers but can’t open it…
Screen Shot 2023-01-24 at 4.37.16 PM

And I just install pprof, but when I run pprof -web [main_binary] ./alloc-profile.pb.gz, I got error message:
[main_binary]: open [main_binary]: no such file or directory
Fetched 1 source profiles out of 2
Main binary filename not available.
pprof: exec: “sensible-browser”: executable file not found in $PATH

I feel it’s because I’m running this on a remote shell so I don’t have a browser there, but I’m not sure how to solve this…Could you give me some suggestion? Thank you!!

Can’t you run the same thing locally? Otherwise you need a proper Web server setup, with support from the firewall, router, etc.

I see, because the real code I want to check profile is quite computationaly expansive which I need run on a cluster, so I’m trying to get the profile feature work there.

But I just try to run the same thing locally, and got an error messgae:
zsh: no matches found: [main_binary]
Does this mean I need install main_binary? Thank you!

Sorry, I don’t use the zsh shell, and I’ve no idea what main_binary is in your setup.

If you have a remote shell, just set up a port redirect with ssh -L 62261:localhost:62261

2 Likes

If you want to work locally, my suggestion is

  1. Download profile file alloc-profile.pb.gz from the cluster
  2. Install pprof locally (or see P.S.)
  3. Run pprof -http=localhost:57599 -relative_percentages profile.pb.gz, you should see this
% pprof -http=localhost:57599 -relative_percentages profile.pb.gz
Main binary filename not available.
Serving web UI on http://localhost:57599

Notice that you need -http option, not -web. PProf.jl executes identical command itself (see this).

  • After the command, the default browser should be opened at localhost:57599, if not, you may enter the address manually in the browser.
  • Also, do not shut down your terminal.
  • I don’t know what “Main binary” warning means, perhaps for Julia code it may be ignored.

If you want to work remotely, see @jameson’s answer. Also, I don’t know, if my suggestion is reproducible on Windows. In case of Windows, I would setup all remotely.

P.S. I’ve found that PProf.jl uses a wrapper around binary pprof, so it’s shipped with PProf.jl. For me, pprof was located in .julia/artifacts/a-long-hash-code/bin/pprof.

1 Like

You need to port forward from your server, if you use VS code remote SSH to get in, you can open ports mid-session.

See docs - Developing on Remote Machines using SSH and Visual Studio Code

1 Like