Documentation
¶
Overview ¶
Package profiling writes the runtime profiles one grafo run was asked for.
Every profile is opt-in and absent by default, because each one costs something: the CPU and trace profiles install a sampler for the whole run, and the block and mutex profiles make the runtime record contention events it otherwise ignores. A run that asks for none pays nothing and takes no different path than before.
The profiles are the standard ones `go tool pprof` and `go tool trace` read, at the rates the Go toolchain's own flags use, so a reader who knows `go test -cpuprofile` already knows what these contain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
CPUPath string
MemoryPath string
BlockPath string
MutexPath string
TracePath string
}
Options names the file each profile is written to. An empty path leaves that profile off, which is what every run that did not ask for one passes.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns the files a started profiling run writes and the runtime state it changed. Stop returns both to where they were.
func Start ¶
Start opens every requested profile's file and installs the samplers that have to run for the whole command.
Opening the files first is deliberate: a profile is asked for precisely when the run is expensive, and discovering an unwritable path after a cold index has finished wastes the only run the caller cared about. A failure here leaves nothing installed and no file open.
func (*Session) Stop ¶
Stop writes the snapshot profiles, uninstalls the samplers, and closes every file. It attempts all of them and joins their errors, so one unwritable profile does not cost the others: a caller that asked for several has already paid for the run that produced them.
A nil session stops nothing, which is what a run that requested no profile holds.