mirror of
https://github.com/golang/go
synced 2024-11-11 23:40:22 -07:00
runtime: fix documented alignment of 32KiB and 64KiB size classes
As Cherry pointed out on golang.org/cl/299909, the page allocator doesn't guarantee any alignment for multi-page allocations, so object alignments are thus implicitly capped at page alignment. Change-Id: I6f5df27f269b095cde54056f876fe4240f69c5c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/301292 Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
8e725f8452
commit
a8a85281ca
@ -239,7 +239,7 @@ func computeDivMagic(c *class) {
|
||||
func printComment(w io.Writer, classes []class) {
|
||||
fmt.Fprintf(w, "// %-5s %-9s %-10s %-7s %-10s %-9s %-9s\n", "class", "bytes/obj", "bytes/span", "objects", "tail waste", "max waste", "min align")
|
||||
prevSize := 0
|
||||
var minAligns [32]int
|
||||
var minAligns [pageShift + 1]int
|
||||
for i, c := range classes {
|
||||
if i == 0 {
|
||||
continue
|
||||
@ -249,6 +249,10 @@ func printComment(w io.Writer, classes []class) {
|
||||
tailWaste := spanSize - c.size*(spanSize/c.size)
|
||||
maxWaste := float64((c.size-prevSize-1)*objects+tailWaste) / float64(spanSize)
|
||||
alignBits := bits.TrailingZeros(uint(c.size))
|
||||
if alignBits > pageShift {
|
||||
// object alignment is capped at page alignment
|
||||
alignBits = pageShift
|
||||
}
|
||||
for i := range minAligns {
|
||||
if i > alignBits {
|
||||
minAligns[i] = 0
|
||||
|
@ -62,7 +62,7 @@ package runtime
|
||||
// 56 12288 24576 2 0 11.45% 4096
|
||||
// 57 13568 40960 3 256 9.99% 256
|
||||
// 58 14336 57344 4 0 5.35% 2048
|
||||
// 59 16384 16384 1 0 12.49% 16384
|
||||
// 59 16384 16384 1 0 12.49% 8192
|
||||
// 60 18432 73728 4 0 11.11% 2048
|
||||
// 61 19072 57344 3 128 3.57% 128
|
||||
// 62 20480 40960 2 0 6.87% 4096
|
||||
@ -70,7 +70,7 @@ package runtime
|
||||
// 64 24576 24576 1 0 11.45% 8192
|
||||
// 65 27264 81920 3 128 10.00% 128
|
||||
// 66 28672 57344 2 0 4.91% 4096
|
||||
// 67 32768 32768 1 0 12.50% 32768
|
||||
// 67 32768 32768 1 0 12.50% 8192
|
||||
|
||||
// alignment bits min obj size
|
||||
// 8 3 8
|
||||
@ -79,7 +79,7 @@ package runtime
|
||||
// 64 6 512
|
||||
// 128 7 768
|
||||
// 4096 12 28672
|
||||
// 32768 15 32768
|
||||
// 8192 13 32768
|
||||
|
||||
const (
|
||||
_MaxSmallSize = 32768
|
||||
|
Loading…
Reference in New Issue
Block a user