]> Cypherpunks repositories - gostls13.git/commit
runtime: add physHugePageShift
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 16 Jul 2019 20:36:33 +0000 (20:36 +0000)
committerAustin Clements <austin@google.com>
Tue, 30 Jul 2019 18:44:52 +0000 (18:44 +0000)
commita41ebe6e259af020d4ce7029544439b39d07936b
treefe706075c4932e316580356f9260348b4afdb4dc
parentfbb819ebc443518e9caea3c1b0d0f9e0efec2262
runtime: add physHugePageShift

This change adds physHugePageShift which is defined such that
1 << physHugePageShift == physHugePageSize. The purpose of this variable
is to avoid doing expensive divisions in key functions, such as
(*mspan).hugePages.

This change also does a sweep of any place we might do a division or mod
operation with physHugePageSize and turns it into bit shifts and other
bitwise operations.

Finally, this change adds a check to mallocinit which ensures that
physHugePageSize is always a power of two. osinit might choose to ignore
non-powers-of-two for the value and replace it with zero, but mallocinit
will fail if it's not a power of two (or zero). It also derives
physHugePageShift from physHugePageSize.

This change helps improve the performance of most applications because
of how often (*mspan).hugePages is called.

Updates #32828.

Change-Id: I1a6db113d52d563f59ae8fd4f0e130858859e68f
Reviewed-on: https://go-review.googlesource.com/c/go/+/186598
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/malloc.go
src/runtime/mem_linux.go
src/runtime/mgcscavenge.go
src/runtime/mheap.go