diff options
| author | Rick Hudson <rlh@golang.org> | 2015-01-26 13:51:39 -0500 |
|---|---|---|
| committer | Rick Hudson <rlh@golang.org> | 2015-01-28 20:05:55 +0000 |
| commit | 13aff7831d32c80b98ede611f1ffb0476f16ec51 (patch) | |
| tree | 1d1e834da6c48bf3f2e2e94469104313537355ba /src/runtime/malloc.go | |
| parent | 8332f807853d9aa47c7aa04bf3501eae88180170 (diff) | |
| download | go-13aff7831d32c80b98ede611f1ffb0476f16ec51.tar.xz | |
runtime: avoid redundant scans
During a concurrent GC stacks are scanned in
an initial scan phase informing the GC of all
pointers on the stack. The GC only needs to rescan
the stack if it potentially changes which can only
happen if the goroutine runs.
This CL tracks whether the Goroutine has run
since it was last scanned and thus may have changed
its stack. If necessary the stack is rescanned.
Change-Id: I5fb1c4338d42e3f61ab56c9beb63b7b2da25f4f1
Reviewed-on: https://go-review.googlesource.com/3275
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index f827b9c418..ea1dd6ea49 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -395,6 +395,14 @@ func gcwork(force int32) { gctimer.cycle.markterm = nanotime() systemstack(stoptheworld) systemstack(gcinstalloffwb_m) + } else { + // For non-concurrent GC (force != 0) g stack have not been scanned so + // set gcscanvalid such that mark termination scans all stacks. + // No races here since we are in a STW phase. + for _, gp := range allgs { + gp.gcworkdone = false // set to true in gcphasework + gp.gcscanvalid = false // stack has not been scanned + } } startTime := nanotime() |
