forked from golang/go
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime/pprof: introduce hardware performance counters for CPU profil…
…ing. The feature is available on Linux-based systems on 386, amd64, and arm64 architectures. The checkin introduces a new API: 'pprof.StartCPUProfileWithConfig(opt ProfilingOption, moreOpts ...ProfilingOption) error' to the runtime/pprof package. ProfilingOption can be one of the following: func OSTimer(w io.Writer) ProfilingOption func CPUCycles(w io.Writer, period uint64) ProfilingOption func CPUInstructions(w io.Writer, period uint64) ProfilingOption func CPUCacheReferences(w io.Writer, period uint64) ProfilingOption func CPUCacheMisses(w io.Writer, period uint64) ProfilingOption func CPUBranchInstructions(w io.Writer, period uint64) ProfilingOption func CPUBranchMisses(w io.Writer, period uint64) ProfilingOption func CPURawEvent(w io.Writer, period uint64, hex uint64) ProfilingOption All of them consume an io.Writer. The OSTimer accepts no other argument. A period accepted by all PMU events specifies the number of events that must elapse between two consecutive interrupts. A larger value means lower granularity (the opposite of Hz). Passing a zero value will result in using a preset period. CPURawEvent is special; it accepts any user-provided hexadecimal PMU event code. Each event requires an io.Writer since different profile types cannot be serialized into the same pprof protocol buffer. Multiple sampling agents can be on at the same time, which is useful in profiling, say, CPU cache hit vs. misses in a single run. SIGPROF signal handler distinguishes whether the sample was delivered from OS timer or performance monitoring unit (PMU) and takes the appropriate action. A new runtime API runtime_pprof_setCPUProfileConfig(eventId int, profConfig *CPUProfileConfig), exposed only to pprof, is used to setup different PMU events such as CPUPROF_HW_CPU_CYCLES, CPUPROF_HW_INSTRUCTIONS etc. along with their sampling period. runtime/pprof: added tests to exercise PMU-based profiling. Tests check if they are running on a supported platform (Linux, amd64, 386, arm64, no VM) and run each test with PMU cycles profiling event in addition to OS timer-based CPU profiling.
- Loading branch information
1 parent
dd93d6a
commit 334f83e
Showing
24 changed files
with
939 additions
and
263 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ const ( | |
_SIG_SETMASK = 3 | ||
_NSIG = 33 | ||
_SI_USER = 0 | ||
_POLL_IN = 1 | ||
) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.