diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2018-04-23 21:20:39 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-04-23 21:20:39 +0800 |
commit | e7067be94f0edb47b39d4fa1725bce18bdadf122 (patch) | |
tree | 03da66169154814fd5eee6a4aba2b2a3790ff739 /internal | |
parent | 9586f2acc76f10c4a7ce364291d075997c5f8eff (diff) | |
download | go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.tar go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.tar.gz go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.tar.bz2 go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.tar.lz go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.tar.xz go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.tar.zst go-tangerine-e7067be94f0edb47b39d4fa1725bce18bdadf122.zip |
cmd/geth, mobile: add memsize to pprof server (#16532)
* cmd/geth, mobile: add memsize to pprof server
This is a temporary change, to be reverted before the next release.
* cmd/geth: fix variable name
Diffstat (limited to 'internal')
-rw-r--r-- | internal/debug/flags.go | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 1f181bf8b..5eb58e9ee 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -28,10 +28,13 @@ import ( "github.com/ethereum/go-ethereum/log/term" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/exp" + "github.com/fjl/memsize/memsizeui" colorable "github.com/mattn/go-colorable" "gopkg.in/urfave/cli.v1" ) +var Memsize memsizeui.Handler + var ( verbosityFlag = cli.IntFlag{ Name: "verbosity", @@ -129,21 +132,25 @@ func Setup(ctx *cli.Context) error { // pprof server if ctx.GlobalBool(pprofFlag.Name) { - // Hook go-metrics into expvar on any /debug/metrics request, load all vars - // from the registry into expvar, and execute regular expvar handler. - exp.Exp(metrics.DefaultRegistry) - address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name)) - go func() { - log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address)) - if err := http.ListenAndServe(address, nil); err != nil { - log.Error("Failure in running pprof server", "err", err) - } - }() + StartPProf(address) } return nil } +func StartPProf(address string) { + // Hook go-metrics into expvar on any /debug/metrics request, load all vars + // from the registry into expvar, and execute regular expvar handler. + exp.Exp(metrics.DefaultRegistry) + http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize)) + log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address)) + go func() { + if err := http.ListenAndServe(address, nil); err != nil { + log.Error("Failure in running pprof server", "err", err) + } + }() +} + // Exit stops all running profiles, flushing their output to the // respective file. func Exit() { |