runtime/pprof: Remove SIGPROF if the last event is stopped.#3
Open
WangLeonard wants to merge 1 commit intouber-research:release-branch.go1.16_pmu_pproffrom
Open
runtime/pprof: Remove SIGPROF if the last event is stopped.#3WangLeonard wants to merge 1 commit intouber-research:release-branch.go1.16_pmu_pproffrom
WangLeonard wants to merge 1 commit intouber-research:release-branch.go1.16_pmu_pproffrom
Conversation
|
|
Author
|
Hi, I added the following print and did an experiment diff --git a/src/net/http/pprof/pprof.go b/src/net/http/pprof/pprof.go
index 89d5151c1f..c5dfe375d3 100644
--- a/src/net/http/pprof/pprof.go
+++ b/src/net/http/pprof/pprof.go
@@ -151,6 +151,7 @@ func Profile(w http.ResponseWriter, r *http.Request) {
case "timer":
err = pprof.StartCPUProfile(w)
case "cycles":
+ println("StartCPUProfileWithConfig")
err = pprof.StartCPUProfileWithConfig(pprof.CPUCycles(w, period))
case "instructions":
err = pprof.StartCPUProfileWithConfig(pprof.CPUInstructions(w, period))
@@ -182,6 +183,7 @@ func Profile(w http.ResponseWriter, r *http.Request) {
}
sleep(r, time.Duration(sec)*time.Second)
+ println("StopCPUProfile")
pprof.StopCPUProfile()
}
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index f7a57d75cc..0f25566238 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -4644,10 +4644,12 @@ func setcpuprofileconfig(eventId cpuEvent, profConfig *cpuProfileConfig) {
for i := _CPUPROF_FIRST_EVENT; i < _CPUPROF_EVENTS_MAX; i++ {
if prof[i].config != nil {
eventsRunning = true
+ println("eventsRunning = true")
break
}
}
if eventsRunning == false {
+ println("setProcessCPUProfiler(nil)")
setProcessCPUProfiler(nil)
}
} else {
when I run net/http/pprof/examples/goroutine.go and curl for a cycles event profile It will print: go run goroutine.go
StartCPUProfileWithConfig
StopCPUProfile
eventsRunning = trueNote, I only create one event, and when it is done, call pprof.StopCPUProfile(). It will set Is this as expected? Does it need to be fixed? Thank you! |
Author
|
friendly ping... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.
Please ensure you adhere to every item in this list.
More info can be found at https://github.com/golang/go/wiki/CommitMessage
net/http: frob the quux before blarfing"This change modifies Go to ___________"
really needed (ASCII art, table, or long link)
Fixes #1234orUpdates #1234(the latter if this is not a complete fix) to this comment
golang/goyou can use theowner/repo#issue_numbersyntax:Fixes golang/tools#1234Our Gerrit server & GitHub bots enforce CLA compliance instead.