From bedfeed54a7a80123c07f83c325a0bcfe5c43398 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 7 Aug 2020 16:28:35 +0000 Subject: runtime,runtime/metrics: add metric to track scheduling latencies This change adds a metric to track scheduling latencies, defined as the cumulative amount of time a goroutine spends being runnable before running again. The metric is an approximations and samples instead of trying to record every goroutine scheduling latency. This change was primarily authored by mknyszek@google.com. Change-Id: Ie0be7e6e7be421572eb2317d3dd8dd6f3d6aa152 Reviewed-on: https://go-review.googlesource.com/c/go/+/308933 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Michael Knyszek --- src/runtime/histogram.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/runtime/histogram.go') diff --git a/src/runtime/histogram.go b/src/runtime/histogram.go index da4910d341..0cccbcca16 100644 --- a/src/runtime/histogram.go +++ b/src/runtime/histogram.go @@ -81,6 +81,10 @@ type timeHistogram struct { } // record adds the given duration to the distribution. +// +// Disallow preemptions and stack growths because this function +// may run in sensitive locations. +//go:nosplit func (h *timeHistogram) record(duration int64) { if duration < 0 { atomic.Xadd64(&h.underflow, 1) -- cgit v1.3-5-g45d5