A couple questions on profiling

I am trying to profile a piece of code that runs for about 15 minutes.

If I use the default settings in Profile.init(), the profile buffer fills up when Julia is still compiling my code, so I don’t get any useful information.

  1. I guess I should use Profile.init(n=...) with a higher n than the default. But what is the default? And how much memory should I budget? (i.e., how much would the buffer approximately consume if I set n=100_000?)

  2. Is it possible to save the profiling buffer in a file for later inspection?

Thanks for any help!

1 Like

Just found the answer to my last question here: Julia Profiling Cheat Sheet - Thirld Word Blog (look for section " Trick: Saving profile results to disk")

The other thing I would suggest is finding a similar input on which your coffee only takes about a minute. Even if it’s not fully representative, the increased iteration speed will make improving things faster.

2 Likes

It’s not documented, but see the code. Specifically,

julia> Int(ccall(:jl_profile_maxlen_data, Csize_t, ()))
1000000

It would be great to

  1. have this documented (possibly by factoring out this code and $(...)ing it into the docstring, or defining a constant),
  2. improve the interface by adding a higher-level argument the user can provide. frequently what one wants is not a buffer for n samples, but “just large enough for this much runtime”, and then the API could figure it out.

Please open an issue.

1 Like