Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http/pprof: Doubts regarding implementation of CPU Profile vs Mutex/Block profile #35016

Closed
nidhi-ag opened this issue Oct 20, 2019 · 1 comment

Comments

@nidhi-ag
Copy link

nidhi-ag commented Oct 20, 2019

For CPU profiling, the rate of profiling is being set internally at start of the call and reset at the end of the call. So it goes like this

CPUProfiling() {
StartCPUProfile() // internally calls SetCPUProfileRate(100)
sleep(seconds)
StopCPUProfile () // internally calls SetCPUProfileRate(0)
}

On the other hand for mutex and block profiling, it expects us to set the block/fraction rate in our program before calling profiling.

My doubt is why mutex and block profiling have different behaviour ?
If we can set the rate any time then similar to cpu profiling, block/mutex profiling can also be implemented like
go tool pprof http://localhost:6060/debug/pprof/block?seconds=30&rate=1
Where internally we can call SetBlockProfileRate/SetMutexProfileFraction before starting profile and after profile interval (eg. 30 seconds) when profiling finishes then we can reset it to 0.

This different implementation made me question why is there a difference in the profiling technique, is it expected from us to set profile rate at the start of the program, if not then why is it not implemented similar to the cpu.

@agnivade
Copy link
Contributor

Hello @nidhi-ag, I see that you have raised this question in golang-nuts. I think that is the right place to discuss this.

Unlike other projects, we do not use the issue tracker for questions such as these. It is only used for bugs and feature proposals. I will close this issue, but please feel free to ask it in any of these forums below:

Thanks

@golang golang locked and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants