Namespace: go.std.net.http.pprof
v1.0Contents
Summary
Provides a low-level interface to the net/http/pprof package.
Package pprof serves via its HTTP server runtime profiling data
in the format expected by the pprof visualization tool.
The package is typically only imported for the side effect of
registering its HTTP handlers.
The handled paths all begin with /debug/pprof/.
To use pprof, link this package into your program:
import _ "net/http/pprof"
If your application is not already running an http server, you
need to start one. Add "net/http" and "log" to your imports and
the following code to your main function:
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
If you are not using DefaultServeMux, you will have to register handlers
with the mux you are using.
Then use the pprof tool to look at the heap profile:
go tool pprof http://localhost:6060/debug/pprof/heap
Or to look at a 30-second CPU profile:
go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
Or to look at the goroutine blocking profile, after calling
runtime.SetBlockProfileRate in your program:
go tool pprof http://localhost:6060/debug/pprof/block
Or to look at the holders of contended mutexes, after calling
runtime.SetMutexProfileFraction in your program:
go tool pprof http://localhost:6060/debug/pprof/mutex
The package also exports a handler that serves execution trace data
for the "go tool trace" command. To collect a 5-second execution trace:
curl -o trace.out http://localhost:6060/debug/pprof/trace?seconds=5
go tool trace trace.out
To view all available profiles, open http://localhost:6060/debug/pprof/
in your browser.
For a study of the facility in action, visit
https://blog.golang.org/2011/06/profiling-go-programs.html
Index
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
Cmdline
Function v1.0(Cmdline w r)
Cmdline responds with the running program's
command line, with arguments separated by NUL bytes.
The package initialization registers it as /debug/pprof/cmdline.
Go input arguments: (w net/http.ResponseWriter, r *net/http.Request)
Joker input arguments: [^go.std.net.http/ResponseWriter w, ^go.std.net.http/*Request r] -
Handler
Function v1.0(Handler name)
Handler returns an HTTP handler that serves the named profile.
Go input arguments: (name string)
Go returns: net/http.Handler
Joker input arguments: [^String name]
Joker returns: ^go.std.net.http/Handler -
Index
Function v1.0(Index w r)
Index responds with the pprof-formatted profile named by the request.
For example, "/debug/pprof/heap" serves the "heap" profile.
Index responds to a request for "/debug/pprof/" with an HTML page
listing the available profiles.
Go input arguments: (w net/http.ResponseWriter, r *net/http.Request)
Joker input arguments: [^go.std.net.http/ResponseWriter w, ^go.std.net.http/*Request r] -
Profile
Function v1.0(Profile w r)
Profile responds with the pprof-formatted cpu profile.
Profiling lasts for duration specified in seconds GET parameter, or for 30 seconds if not specified.
The package initialization registers it as /debug/pprof/profile.
Go input arguments: (w net/http.ResponseWriter, r *net/http.Request)
Joker input arguments: [^go.std.net.http/ResponseWriter w, ^go.std.net.http/*Request r] -
Symbol
Function v1.0(Symbol w r)
Symbol looks up the program counters listed in the request,
responding with a table mapping program counters to function names.
The package initialization registers it as /debug/pprof/symbol.
Go input arguments: (w net/http.ResponseWriter, r *net/http.Request)
Joker input arguments: [^go.std.net.http/ResponseWriter w, ^go.std.net.http/*Request r] -
Trace
Function v1.0(Trace w r)
Trace responds with the execution trace in binary form.
Tracing lasts for duration specified in seconds GET parameter, or for 1 second if not specified.
The package initialization registers it as /debug/pprof/trace.
Go input arguments: (w net/http.ResponseWriter, r *net/http.Request)
Joker input arguments: [^go.std.net.http/ResponseWriter w, ^go.std.net.http/*Request r]
Types
-
(None.)