Configurable heap profiling rate
This commit is contained in:
parent
ee000dabfd
commit
c482c13dcb
@ -20,19 +20,24 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if innerProcess && os.Getenv("STHEAPPROFILE") != "" {
|
if innerProcess && os.Getenv("STHEAPPROFILE") != "" {
|
||||||
|
rate := 1
|
||||||
|
if i, err := strconv.Atoi(os.Getenv("STHEAPPROFILE")); err == nil {
|
||||||
|
rate = i
|
||||||
|
}
|
||||||
l.Debugln("Starting heap profiling")
|
l.Debugln("Starting heap profiling")
|
||||||
go saveHeapProfiles()
|
go saveHeapProfiles(rate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveHeapProfiles() {
|
func saveHeapProfiles(rate int) {
|
||||||
runtime.MemProfileRate = 1
|
runtime.MemProfileRate = rate
|
||||||
var memstats, prevMemstats runtime.MemStats
|
var memstats, prevMemstats runtime.MemStats
|
||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user