mirror of
https://github.com/golang/go
synced 2024-11-23 20:30:04 -07:00
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>
This commit is contained in:
parent
b79db4f2fd
commit
b86e71f5aa
@ -684,7 +684,7 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldtriggergc() {
|
if shouldhelpgc && shouldtriggergc() {
|
||||||
startGC(gcBackgroundMode)
|
startGC(gcBackgroundMode)
|
||||||
} else if gcBlackenEnabled != 0 {
|
} else if gcBlackenEnabled != 0 {
|
||||||
// Assist garbage collector. We delay this until the
|
// Assist garbage collector. We delay this until the
|
||||||
|
Loading…
Reference in New Issue
Block a user