config+lnd: add new option --cpuprofile for writing cpuprofile to file
In this commit we add a new option to lnd, cpuprofile. With this option we add additional telemetry hooks into and, allowing users to generate CPU profiling files to measure hot spots within the daemon.
This commit is contained in:
2 files changed
+15
No files matched your search
@@ -16,6 +16,7 @@ import (
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -88,6 +89,18 @@ func lndMain() error {
|
||||
}()
|
||||
}
|
||||
|
||||
// Write cpu profile if requested.
|
||||
if cfg.CPUProfile != "" {
|
||||
f, err := os.Create(cfg.CPUProfile)
|
||||
if err != nil {
|
||||
ltndLog.Errorf("Unable to create cpu profile: %v", err)
|
||||
return err
|
||||
}
|
||||
pprof.StartCPUProfile(f)
|
||||
defer f.Close()
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
// Open the channeldb, which is dedicated to storing channel, and
|
||||
// network related metadata.
|
||||
chanDB, err := channeldb.Open(cfg.DataDir)
|
||||
|
||||
Reference in new issue
Block a user