summaryrefslogtreecommitdiff
path: root/src/net/http/pprof/pprof.go
Commit message (Collapse)AuthorAgeFilesLines
* net/http/pprof: remove html/template dependencyEgon Elbre2020-10-091-25/+35
| | | | | | | | | | | | | | | | | | | html/template indirectly uses reflect MethodByName, this causes linker to use conservative mode resulting in larger binaries. The template here is trivial and can be replaced by string manipulation. This reduces a binary using only net/http/pprof by ~2.5MB. Fixes #41569 Change-Id: I240e1daa6376182ff4961997ee3ec7b96cb07be8 Reviewed-on: https://go-review.googlesource.com/c/go/+/256900 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Hajime Hoshi <hajimehoshi@gmail.com> Trust: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/pprof: use Request.Context, not the deprecated CloseNotifierAyan George2020-10-071-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, the profiling code had a sleep() function that waits and unblocks on either time.After() or a channel provided by an http.CloseNotifier derived from a supplied http.ResponseWriter. According to the documentation, http.CloseNotifier is deprecated: Deprecated: the CloseNotifier interface predates Go's context package. New code should use Request.Context instead. This patch does just that -- sleep() now takes an *http.Request and uses http.Request.Context() to signal when a request has been cancelled. Change-Id: I98702314addf494f5743a4f99172dc607389dbb8 GitHub-Last-Rev: c1e37a03ca28417ed5833618d3eeddb2eecccd09 GitHub-Pull-Request: golang/go#41756 Reviewed-on: https://go-review.googlesource.com/c/go/+/259157 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Trust: Bryan C. Mills <bcmills@google.com> Trust: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
* net/http/pprof: document the trace endpoint is for execution traceHana (Hyang-Ah) Kim2020-05-091-4/+6
| | | | | | | | Update google/pprof#529 Change-Id: Iec3b343a487b399ada3a6f73c120b5f7ed8938be Reviewed-on: https://go-review.googlesource.com/c/go/+/230538 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* net/http/pprof: allow "seconds" parameters to most profilesHana (Hyang-Ah) Kim2020-04-221-2/+6
| | | | | | | | | | | | | | | | | | | | | golang.org/cl/147598 added the support for delta computation for mutex and block profiles. In fact, this delta computation makes sense for other types of profiles. For example, /debug/pprof/allocs?seconds=x will provide how much allocation was made during the specified period. /debug/pprof/goroutine?seconds=x will provide the changes in the list of goroutines. This also makes sense for custom profiles. Update #23401 Update google/pprof#526 Change-Id: I45e9073eb001ea5b3f3d16e5a57f635193610656 Reviewed-on: https://go-review.googlesource.com/c/go/+/229537 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* net/http/pprof: support the "seconds" param for block, mutex profilesHana Kim2020-04-171-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | When the seconds param is given, the block and mutex profile endpoints report the difference between two measurements collected the given seconds apart. Historically, the block and mutex profiles have reported the cumulative counts since the process start, and it turned out they are more useful when interpreted along with the time duration. Note: cpu profile and trace endpoints already accept the "seconds" parameter. With this CL, the block and mutex profile endpoints will accept the "seconds" parameter. Providing the "seconds" parameter to other types of profiles is an error. This change moves runtime/pprof/internal/profile to internal/profile and adds part of merge logic from github.com/google/pprof/profile/merge.go to internal/profile, in order to allow both net/http/pprof and runtime/pprof to access it. Fixes #23401 Change-Id: Ie2486f1a63eb8ff210d7d3bc2de683e9335fd5cd Reviewed-on: https://go-review.googlesource.com/c/go/+/147598 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* net/http/pprof: set content type for /debug/pprofHana (Hyang-Ah) Kim2020-02-211-0/+3
| | | | | | | | | | Fixes #37311 Change-Id: I9e1f37e991e5c203fe72061692f47584fbadfc58 Reviewed-on: https://go-review.googlesource.com/c/go/+/220324 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* net/http/pprof: explicitly mention DefaultServeMux for default handlersharsimran12019-10-211-0/+3
| | | | | | Change-Id: I224db88f3809001802e004077ce856f0e3347c67 Reviewed-on: https://go-review.googlesource.com/c/go/+/169017 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/pprof: fix typo on new index pageIngo Oeser2018-05-101-1/+1
| | | | | | | | | s/thread/thead/ as this is Table HEAD and not a thread as indicated by the closing tag an context this apears in. Change-Id: I3aa0cc95b96c9a594cb5a49713efa22d67e4990c Reviewed-on: https://go-review.googlesource.com/112675 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/pprof: update the /debug/pprof endpointAgniva De Sarker2018-05-101-8/+67
| | | | | | | | | | | | | | | | - Documented the duration parameter in Profile() to match with Trace(). - Properly handling the error from strconv.ParseInt to match with Trace(). - Updated the profiles tables to include additional handlers exposed from net/http/pprof. Added a separate section at the bottom to explain what the profiles are and how to use them. Fixes #24380 Change-Id: I8b7e100d6826a4feec81f29f918e7a7f7ccc71a0 Reviewed-on: https://go-review.googlesource.com/112495 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
* net/http/pprof: harden handler responsesAndrew Bonventre2018-03-281-23/+29
| | | | | | | | | | | | | | | | | | A very small number of old browsers consider content as HTML even when it is explicitly stated in the Content-Type header that it is not. If content served is based on user-supplied input, then an XSS is possible. Introduce three mitigations: + Don't reflect user input in error strings + Set a Content-Disposition header when requesting a resource that should never be displayed in a browser window + Set X-Content-Type-Options: nosniff on all responses Change-Id: I81c9d6736e0439ebd1db99cd7fb701cc56d24805 Reviewed-on: https://go-review.googlesource.com/102318 Run-TryBot: Andrew Bonventre <andybons@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/pprof: attach handlers using http.HandleFuncTerin Stock2017-10-301-5/+5
| | | | | | | | | | | | | Simplify how pprof attaches the handlers to the DefaultMux by using http.HandleFunc instead of manually wrapping the handlers in a http.HandlerFunc. Change-Id: I65db262ebb2e29e4b6f30df9d2688f5daf782c29 Reviewed-on: https://go-review.googlesource.com/71251 Reviewed-by: Sam Whited <sam@samwhited.com> Reviewed-by: Tom Bergan <tombergan@google.com> Run-TryBot: Sam Whited <sam@samwhited.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/pprof: mention mutex profile in docHana (Hyang-Ah) Kim2017-06-261-0/+5
| | | | | | | | | | | mutex profile requires explicit calls to runtime.SetMutexProfileFraction to enable/disable profiling (like block profile). It is worth mentioning in the doc. Change-Id: I2b8d654be9f5c6bc49fc802b7708c4c552fea9b2 Reviewed-on: https://go-review.googlesource.com/42070 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: remove redundant returnsDaniel Martí2017-04-191-1/+0
| | | | | | | | | | | Returns at the end of func bodies where the funcs have no return values are pointless. Change-Id: I0da5ea78671503e41a9f56dd770df8c919310ce5 Reviewed-on: https://go-review.googlesource.com/41093 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/pprof: return error when requested profile duration exceeds ↵Kale Blankenship2017-02-081-0/+23
| | | | | | | | | | | | | | | | | | WriteTimeout Updates Profile and Trace handlers to reject requests for durations >= WriteTimeout. Modifies go tool pprof to print the body of the http response when status != 200. Fixes #18755 Change-Id: I6faed21685693caf39f315f003039538114937b0 Reviewed-on: https://go-review.googlesource.com/35564 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/pprof: remove comments pointing to gperftoolsRaul Silvera2016-06-281-2/+0
| | | | | | | | | | The version of pprof in gperftools has been deprecated. No need to have a pointer to that version since go tool pprof is included with the Go distro. Change-Id: I6d769a68f64280f5db89ff6fbc67bfea9c8f1526 Reviewed-on: https://go-review.googlesource.com/24509 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/pprof: accept fractional seconds in trace handlerRuss Cox2016-04-111-3/+3
| | | | | | | | | | For heavily loaded servers, even 1 second of trace is too large to process with the trace viewer; using a float64 here allows fetching /debug/pprof/trace?seconds=0.1. Change-Id: I286c07abf04f9c1fe594b0e26799bf37f5c734db Reviewed-on: https://go-review.googlesource.com/21455 Reviewed-by: Austin Clements <austin@google.com>
* net/http/pprof: note calling runtime.SetBlockProfileRate is required for ↵Dan Peterson2016-04-061-1/+2
| | | | | | | | | | block profile Fixes #15076 Change-Id: I5ce8f6253245d8cc1f862a1bf618775f557f955d Reviewed-on: https://go-review.googlesource.com/21610 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: single space after period.Brad Fitzpatrick2016-03-021-3/+3
| | | | | | | | | | | | | | | | | | | | The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* all: make copyright headers consistent with one space after periodBrad Fitzpatrick2016-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/pprof: stop profiling if client's connection closesBrad Fitzpatrick2016-01-061-2/+13
| | | | | | | | | Fixes #13833 Change-Id: If0bd5f7dcfc39d34680d11eb998050f0900d5a26 Reviewed-on: https://go-review.googlesource.com/18283 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* runtime/trace: add new packageDmitry Vyukov2015-07-221-4/+5
| | | | | | | | | | Move tracing functions from runtime/pprof to the new runtime/trace package. Fixes #9710 Change-Id: I718bcb2ae3e5959d9f72cab5e6708289e5c8ebd5 Reviewed-on: https://go-review.googlesource.com/12511 Reviewed-by: Russ Cox <rsc@golang.org>
* all: link to https for golang subdomains tooBrad Fitzpatrick2015-07-121-1/+1
| | | | | | | | | The previous commit (git 2ae77376) just did golang.org. This one includes golang.org subdomains like blog, play, and build. Change-Id: I4469f7b307ae2a12ea89323422044e604c5133ae Reviewed-on: https://go-review.googlesource.com/12071 Reviewed-by: Rob Pike <r@golang.org>
* net/http/pprof: Correct body tag in index templateQuoc-Viet Nguyen2015-03-191-1/+1
| | | | | | | | The body tag in the pprof template was misplaced. Change-Id: Icd7948b358f52df1acc7e033ab27a062990ef977 Reviewed-on: https://go-review.googlesource.com/7795 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/pprof: Use relative links to profiles in index htmlMatt Joiner2015-03-121-2/+2
| | | | | | | | | This allows /debug/pprof/ and descendents to be used through http.StripPrefix and other path rewriting handlers. Change-Id: I53673876c107bbfaf430123ead78e6524b42ac21 Reviewed-on: https://go-review.googlesource.com/7351 Reviewed-by: Andrew Gerrand <adg@golang.org>
* net/http/pprof: add tracing supportDmitry Vyukov2015-01-281-0/+29
| | | | | | | | | | | net/http/pprof part of tracing functionality: https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub Full change: https://codereview.appspot.com/146920043 Change-Id: I9092028fcbd5e8f97a56f2c155889ccdfb494afb Reviewed-on: https://go-review.googlesource.com/1453 Reviewed-by: Russ Cox <rsc@golang.org>
* net/http/pprof: run GC for /debug/pprof/heap?gc=1Russ Cox2014-10-241-0/+4
| | | | | | | | | | | | | | | | We force runtime.GC before WriteHeapProfile with -test.heapprofile. Make it possible to do the same with the HTTP interface. Some servers only run a GC every few minutes. On such servers, the heap profile will be a few minutes stale, which may be too old to be useful. Requested by private mail. LGTM=dvyukov R=dvyukov CC=golang-codereviews https://golang.org/cl/161990043
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+205
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.