edge-node gc命令增加耗时和gc pause时长

This commit is contained in:
刘祥超
2023-12-25 09:24:20 +08:00
parent cfa57fac66
commit 17af07cce0
2 changed files with 20 additions and 3 deletions

View File

@@ -777,9 +777,19 @@ func (this *Node) listenSock() error {
_ = cmd.ReplyOk()
}
case "gc":
var before = time.Now()
runtime.GC()
debug.FreeOSMemory()
_ = cmd.ReplyOk()
var costSeconds = time.Since(before).Seconds()
var gcStats = &debug.GCStats{}
debug.ReadGCStats(gcStats)
_ = cmd.Reply(&gosock.Command{
Params: map[string]any{
"pauseMS": gcStats.PauseTotal.Seconds() * 1000,
"costMS": costSeconds * 1000,
},
})
case "reload":
err := this.syncConfig(0)
if err != nil {