github.com/grafana/pyroscope-go/godeltaprof@v0.1.8-0.20240513050943-1b1f97373e2a/internal/pprof/mutex_scale_go19.go (about) 1 //go:build go1.16 && !go1.20 2 // +build go1.16,!go1.20 3 4 package pprof 5 6 import "runtime" 7 8 type MutexProfileScaler struct { 9 f func(cnt int64, ns float64) (int64, float64) 10 } 11 12 func ScaleMutexProfile(scaler MutexProfileScaler, cnt int64, ns float64) (int64, float64) { 13 return scaler.f(cnt, ns) 14 } 15 16 var ScalerMutexProfile = MutexProfileScaler{func(cnt int64, ns float64) (int64, float64) { 17 period := runtime.SetMutexProfileFraction(-1) 18 return cnt * int64(period), ns * float64(period) 19 }} 20 21 var ScalerBlockProfile = MutexProfileScaler{func(cnt int64, ns float64) (int64, float64) { 22 // Do nothing. 23 // The current way of block profile sampling makes it 24 // hard to compute the unsampled number. The legacy block 25 // profile parse doesn't attempt to scale or unsample. 26 return cnt, ns 27 }}