aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRick Hudson <rlh@golang.org>2015-04-28 09:07:51 -0400
committerRick Hudson <rlh@golang.org>2015-05-04 17:38:58 +0000
commitb86e71f5aae4bd2cd2b1010e1c57909c068178cc (patch)
treedb95d67bffad17ecb077b5aa6b36f01e563877e9 /src/runtime
parentb79db4f2fd76cf1d8ce58144fc609a08ab5dd7b3 (diff)
downloadgo-b86e71f5aae4bd2cd2b1010e1c57909c068178cc.tar.xz
runtime: Reduce calls to shouldtriggergc
shouldtriggergc is slightly expensive due to the call overhead and the use of an atomic. This CL reduces the number of time one checks if a GC should be done from one at each allocation to once when a span is allocated. Since shouldtriggergc is an important abstraction simply hand inlining it, along with its atomic instruction would lose the abstraction. Change-Id: Ia3210655b4b3d433f77064a21ecb54e4d9d435f7 Reviewed-on: https://go-review.googlesource.com/9403 Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/malloc.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 91d69b5a9b..22ad6b581f 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -684,7 +684,7 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer {
}
}
- if shouldtriggergc() {
+ if shouldhelpgc && shouldtriggergc() {
startGC(gcBackgroundMode)
} else if gcBlackenEnabled != 0 {
// Assist garbage collector. We delay this until the