mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 09:52:20 +08:00
write memory profiles every 30 seconds when enabled
This commit is contained in:
@ -447,15 +447,19 @@ func startProfiling() (func(), error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pprof.StartCPUProfile(ofi)
|
pprof.StartCPUProfile(ofi)
|
||||||
|
go func() {
|
||||||
stopProfiling := func() {
|
for _ = range time.NewTicker(time.Second * 30).C {
|
||||||
pprof.StopCPUProfile()
|
|
||||||
defer ofi.Close() // captured by the closure
|
|
||||||
err := writeHeapProfileToFile()
|
err := writeHeapProfileToFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Critical(err)
|
log.Critical(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
stopProfiling := func() {
|
||||||
|
pprof.StopCPUProfile()
|
||||||
|
defer ofi.Close() // captured by the closure
|
||||||
|
}
|
||||||
return stopProfiling, nil
|
return stopProfiling, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +491,6 @@ func (ih *IntrHandler) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle starts handling the given signals, and will call the handler
|
// Handle starts handling the given signals, and will call the handler
|
||||||
// callback function each time a signal is catched. The function is passed
|
// callback function each time a signal is catched. The function is passed
|
||||||
// the number of times the handler has been triggered in total, as
|
// the number of times the handler has been triggered in total, as
|
||||||
|
Reference in New Issue
Block a user