[lbry] runtime: Add --memprofile option
* Add --memprofile option. Add memprofile to sample config. * Add --memprofile to doc.go.
This commit is contained in:
parent
92a7a2087a
commit
15191b7ede
4 changed files with 24 additions and 0 deletions
|
@ -117,6 +117,7 @@ type config struct {
|
||||||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
||||||
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
|
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
|
||||||
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
|
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
|
||||||
|
MemProfile string `long:"memprofile" description:"Write memory profile to the specified file"`
|
||||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||||
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
|
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
|
||||||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
||||||
|
|
1
doc.go
1
doc.go
|
@ -78,6 +78,7 @@ Application Options:
|
||||||
memory (default: 100)
|
memory (default: 100)
|
||||||
--maxpeers= Max number of inbound and outbound peers
|
--maxpeers= Max number of inbound and outbound peers
|
||||||
(default: 125)
|
(default: 125)
|
||||||
|
--memprofile= Write memory profile to the specified file
|
||||||
--miningaddr= Add the specified payment address to the list of
|
--miningaddr= Add the specified payment address to the list of
|
||||||
addresses to use for generated blocks -- At least
|
addresses to use for generated blocks -- At least
|
||||||
one address is required if the generate option is
|
one address is required if the generate option is
|
||||||
|
|
19
lbcd.go
19
lbcd.go
|
@ -92,6 +92,25 @@ func btcdMain(serverChan chan<- *server) error {
|
||||||
defer pprof.StopCPUProfile()
|
defer pprof.StopCPUProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write memory profile if requested.
|
||||||
|
if cfg.MemProfile != "" {
|
||||||
|
f, err := os.Create(cfg.MemProfile + ".heap")
|
||||||
|
if err != nil {
|
||||||
|
btcdLog.Errorf("Unable to create mem profile: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
defer pprof.Lookup("heap").WriteTo(f, 0)
|
||||||
|
|
||||||
|
f, err = os.Create(cfg.MemProfile + ".allocs")
|
||||||
|
if err != nil {
|
||||||
|
btcdLog.Errorf("Unable to create mem profile: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
defer pprof.Lookup("allocs").WriteTo(f, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// Perform upgrades to btcd as new versions require it.
|
// Perform upgrades to btcd as new versions require it.
|
||||||
if err := doUpgrades(); err != nil {
|
if err := doUpgrades(); err != nil {
|
||||||
btcdLog.Errorf("%v", err)
|
btcdLog.Errorf("%v", err)
|
||||||
|
|
|
@ -376,6 +376,9 @@
|
||||||
; Write CPU profile to the specified file.
|
; Write CPU profile to the specified file.
|
||||||
; cpuprofile=
|
; cpuprofile=
|
||||||
|
|
||||||
|
; Write memory profile to the specified file.
|
||||||
|
; memprofile=
|
||||||
|
|
||||||
; The port used to listen for HTTP profile requests. The profile server will
|
; The port used to listen for HTTP profile requests. The profile server will
|
||||||
; be disabled if this option is not specified. The profile information can be
|
; be disabled if this option is not specified. The profile information can be
|
||||||
; accessed at http://localhost:<profileport>/debug/pprof once running.
|
; accessed at http://localhost:<profileport>/debug/pprof once running.
|
||||||
|
|
Loading…
Reference in a new issue