You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/wgengine/rusage.go

24 lines
585 B
Go

// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package wgengine
import (
"fmt"
"runtime"
"tailscale.com/logger"
)
func RusagePrefixLog(logf logger.Logf) func(f string, argv ...interface{}) {
return func(f string, argv ...interface{}) {
var m runtime.MemStats
runtime.ReadMemStats(&m)
goMem := float64(m.HeapInuse+m.StackInuse) / (1 << 20)
maxRSS := rusageMaxRSS()
pf := fmt.Sprintf("%.1fM/%.1fM %s", goMem, maxRSS, f)
logf(pf, argv...)
}
}