diff options
author | Austin Clements <austin@google.com> | 2017-07-19 14:18:08 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2017-07-19 20:56:20 +0000 |
commit | ffd5687a8217e6829d2248dd0698f18c0e128ac2 (patch) | |
tree | 1f104caeeba8b3d626d1884f955b42ed4581234f | |
parent | 93b7eb973f4f6812a6b9c093b4b6d5c80409eb92 (diff) | |
download | go-ffd5687a8217e6829d2248dd0698f18c0e128ac2.tar.gz go-ffd5687a8217e6829d2248dd0698f18c0e128ac2.zip |
runtime: only trace mark assists that do work
Currently we trace mark assists even if they're satisfied entirely by
stealing. This means even if background marking is keeping up with
allocation, we'll still emit a trace event every N bytes of
allocation. The event will be a few microseconds, if that, but they're
frequent enough that, when zoomed out in the trace view, it looks like
all of the time is spent in mark assists even if almost none is.
Change this so we only emit a trace event if the assist actually has
to do assisting. This makes the traces of these events far more
useful.
Change-Id: If4aed1c413b814341ef2fba61d2f10751d00451b
Reviewed-on: https://go-review.googlesource.com/50030
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
-rw-r--r-- | src/runtime/mgcmark.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index dbca5cd1c7..9029d19d43 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -415,10 +415,7 @@ func gcAssistAlloc(gp *g) { return } - if trace.enabled { - traceGCMarkAssistStart() - } - + traced := false retry: // Compute the amount of scan work we need to do to make the // balance positive. When the required amount of work is low, @@ -454,13 +451,18 @@ retry: if scanWork == 0 { // We were able to steal all of the credit we // needed. - if trace.enabled { + if traced { traceGCMarkAssistDone() } return } } + if trace.enabled && !traced { + traced = true + traceGCMarkAssistStart() + } + // Perform assist work systemstack(func() { gcAssistAlloc1(gp, scanWork) @@ -503,7 +505,7 @@ retry: // At this point either background GC has satisfied // this G's assist debt, or the GC cycle is over. } - if trace.enabled { + if traced { traceGCMarkAssistDone() } } |