mirror of
https://github.com/btcsuite/btcd.git
synced 2026-08-13 12:32:51 +02:00
main: add flag to write execution traces
Execution traces are part of the go runtime tooling and is useful to check what is slowing down the ibd. For example, a slow ibd because of slow block downloads from peers won't show up on cpu profiling but will on a trace.
This commit is contained in:
parent
b161cd6a19
commit
10ef9cc042
2 changed files with 14 additions and 0 deletions
13
btcd.go
13
btcd.go
|
|
@ -14,6 +14,7 @@ import (
|
|||
"runtime"
|
||||
"runtime/debug"
|
||||
"runtime/pprof"
|
||||
"runtime/trace"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain/indexers"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
|
|
@ -100,6 +101,18 @@ func btcdMain(serverChan chan<- *server) error {
|
|||
defer runtime.GC()
|
||||
}
|
||||
|
||||
// Write execution trace if requested.
|
||||
if cfg.TraceProfile != "" {
|
||||
f, err := os.Create(cfg.TraceProfile)
|
||||
if err != nil {
|
||||
btcdLog.Errorf("Unable to create execution trace: %v", err)
|
||||
return err
|
||||
}
|
||||
trace.Start(f)
|
||||
defer f.Close()
|
||||
defer trace.Stop()
|
||||
}
|
||||
|
||||
// Perform upgrades to btcd as new versions require it.
|
||||
if err := doUpgrades(); err != nil {
|
||||
btcdLog.Errorf("%v", err)
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ type config struct {
|
|||
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"`
|
||||
MemoryProfile string `long:"memprofile" description:"Write memory profile to the specified file"`
|
||||
TraceProfile string `long:"traceprofile" description:"Write execution trace to the specified file"`
|
||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||
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"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue