On Sun, Oct 20, 2019 at 12:23 AM Nidhi Agrawal <nidhi11...@gmail.com> wrote:
>
> Ok, Is it necessary to call SetBlockProfileRate at the start of application?
> If not then we can call it just before starting block profile and after block 
> profile interval (eg. 30 seconds) when profiling finishes then we can reset 
> it to 0.

As far as I know you can call SetBlockProfileRate at any time.

Why do you think that it must be called at the start of the application?

Ian


> On Sun, Oct 20, 2019 at 12:48 PM Ian Lance Taylor <i...@golang.org> wrote:
>>
>> On Sat, Oct 19, 2019 at 10:17 PM Nidhi Agrawal <nidhi11...@gmail.com> wrote:
>> >
>> >
>> > https://golang.org/src/runtime/mprof.go, 
>> > https://golang.org/pkg/net/http/pprof/ here it is mentioned that we need 
>> > to set SetBlockProfileRate to get enable block profile.
>> >
>> > In case of block profiling if I set rate just before profiling and reset 
>> > it to 0 after profiling i am not getting any data.
>> >
>> > I am doing something like:
>> > SetBlockProfileRate(1)
>> > pprof.Lookup("block").WriteTo(f, 0);
>> > SetBlockProfileRate(0)
>>
>> If that is exactly what you are doing, then that doesn't work for CPU
>> profiling either.  You need to call SetBlockProfileRate, then do some
>> work, then fetch the profile.
>>
>> Ian
>>
>>
>> > On Sun, Oct 20, 2019 at 10:24 AM Ian Lance Taylor <i...@golang.org> wrote:
>> >>
>> >> On Sat, Oct 19, 2019 at 7:34 PM Nidhi Agrawal <nidhi11...@gmail.com> 
>> >> wrote:
>> >> >
>> >> > We don't need to set MemProfileRate. It is about block and mutex 
>> >> > profiling where we need to set the rate (SetBlockProfileRate, 
>> >> > SetMutexProfileFraction) at application start. Is there any performance 
>> >> > impacts of doing that ?
>> >> >
>> >> > It is not causing any issue we want to enable block and mutex profiling 
>> >> > so i am thinking if we can do something like
>> >> >   SetBlockProfileRate(1)
>> >> >   pprof.Lookup("block").WriteTo(f, 0);
>> >> >   sleep(20)
>> >> >   SetBlockProfileRate(0)
>> >> > just like how cpu and trace profile works. But i am curious why isn't 
>> >> > it not already done in the library. What can be the reason behind this?
>> >> >
>> >> > I am curious why they are different from cpu and trace profiling, 
>> >> > trying to understand the inner working of this. It would be really 
>> >> > helpful if you can give me some pointers on where i can read about the 
>> >> > high level design of the pprof.
>> >>
>> >> Oh, sorry, I misread what you were asking.  But now I'm not sure what
>> >> you are asking.  You said
>> >>
>> >> > On the other hand for mutex and block profiling, it expects us to set 
>> >> > the rate at the start of the application and while calling profiling, 
>> >> > it just gathers the information and return.
>> >>
>> >> That's how memory profiling works.  You don't have to set the mutex
>> >> and profiling rates at the start of the application.  You can set them
>> >> when you want to start profiling, as you suggest.  Is there some
>> >> documentation that says otherwise?
>> >>
>> >> Sorry, I don't know of any documentation describing the profiling
>> >> implementation.
>> >>
>> >> Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUpViwb0zzCR%3DBRWJ-GpqYdiaOeGCwHY_McODyEUcCvAQ%40mail.gmail.com.

Reply via email to