diff options
author | zeripath <art27@cantab.net> | 2022-06-18 11:04:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-18 11:04:52 +0100 |
commit | 90f3365d93448c45bcb646d4449f9af8f3568bb8 (patch) | |
tree | 6017dbcbde15a90d089db9492c456aa4e756ec1b /cmd | |
parent | 7fbf00240332751bf68081664118fdc02f51fe4a (diff) | |
download | gitea-90f3365d93448c45bcb646d4449f9af8f3568bb8.tar.gz gitea-90f3365d93448c45bcb646d4449f9af8f3568bb8.zip |
Add fgprof pprof profiler (#20005)
fgprof is a sampling Go profiler that allows you to analyze On-CPU as
well as Off-CPU (e.g. I/O) time together.
Go's builtin sampling CPU profiler can only show On-CPU time, but it's
better than fgprof at that. Go also includes tracing profilers that can
analyze I/O, but they can't be combined with the CPU profiler.
fgprof is designed for analyzing applications with mixed I/O and CPU
workloads. This kind of profiling is also known as wall-clock profiling.
Whilst fgprof can cause significant STW latencies in applications with a
lot of goroutines (> 1-10k), these latencies only occur if the profile
is requested - it doesn't cause a delay by simply being available.
The fgprof profile is mounted on
`http://localhost:6060/debug/fgprof?seconds=3`
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/web.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/cmd/web.go b/cmd/web.go index 8c7c026172..43bb0ada91 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/routers" "code.gitea.io/gitea/routers/install" + "github.com/felixge/fgprof" "github.com/urfave/cli" ini "gopkg.in/ini.v1" ) @@ -145,6 +146,7 @@ func runWeb(ctx *cli.Context) error { if setting.EnablePprof { go func() { + http.DefaultServeMux.Handle("/debug/fgprof", fgprof.Handler()) _, _, finished := process.GetManager().AddTypedContext(context.Background(), "Web: PProf Server", process.SystemProcessType, true) log.Info("Starting pprof server on localhost:6060") log.Info("%v", http.ListenAndServe("localhost:6060", nil)) |