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

runtime: deprecate SetCPUProfileRate and replace body with panic #40094

Open
rsc opened this issue Jul 7, 2020 · 2 comments
Open

runtime: deprecate SetCPUProfileRate and replace body with panic #40094

rsc opened this issue Jul 7, 2020 · 2 comments
Labels
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Jul 7, 2020

Long ago we had runtime.SetCPUProfileRate and runtime.CPUProfile as the interface to profiling. And runtime/pprof was layered on top of them. At some point we realized that this was not a good enough interface, and we made the runtime export hooks directly to runtime/pprof.

We marked CPUProfile deprecated and replaced the body with a panic.

But we forgot to do the same to SetCPUProfileRate. The result is that today this function is documented as if it is useful, when in fact it is not. We should mark it deprecated and replace the body with a panic, same as CPUProfile, leaving a back-door hook for runtime/pprof.

@rsc rsc added the NeedsFix label Jul 7, 2020
@rsc rsc added this to the Go1.16 milestone Jul 7, 2020
@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Jul 7, 2020

I think SetCPUProfileRate is, albeit confusing, still functioning. It needs to be called in the right order with StartCPUProfile. Last time I looked (~a month ago), it probably prints some warnings, but it does change the rate.

The pprof package doesn't seem to have a way to set the profiling rate. Not sure if this is really a useful feature.

@rhysh
Copy link
Contributor

@rhysh rhysh commented Jul 26, 2020

The pprof package doesn't seem to have a way to set the profiling rate. Not sure if this is really a useful feature.

I have an unfortunate example of it being useful: Go's CPU profiling gives inaccurate results if the profiling rate is "too high". On the Linux machines I use, that's "more than 250 samples per second across the entire process". I've used SetCPUProfileRate to work around #35057, though only for the purpose of filing that bug report. It's the only practical workaround I know for that issue, and the warning it prints ("runtime: cannot set cpu profile rate until previous profile has finished." as of go1.13.3) is the main indication I see that it's not suitable for production use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.