mirror of
https://github.com/golang/go
synced 2024-11-17 22:24:47 -07:00
runtime: add "max waste" column to size class table comment
This computes the maximum possible waste in a size class due to both internal and external fragmentation as a percent of the span size. This parallels the reasoning about overhead in the comment at the top of mksizeclasses.go and confirms that comment's assertion that (except for the few smallest size classes), none of the size classes have worst-case internal and external fragmentation simultaneously. Change-Id: Idb66fe6c241d56f33d391831d4cd5a626955562b Reviewed-on: https://go-review.googlesource.com/49370 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
1ee55c3ab6
commit
a6ae01a64a
@ -24,8 +24,8 @@
|
||||
// In practice, only one of the wastes comes into play for a
|
||||
// given size (sizes < 512 waste mainly on the round-up,
|
||||
// sizes > 512 waste mainly on the page chopping).
|
||||
//
|
||||
// TODO(rsc): Compute max waste for any given size.
|
||||
// For really small sizes, alignment constraints force the
|
||||
// overhead higher.
|
||||
|
||||
package main
|
||||
|
||||
@ -242,15 +242,18 @@ nextk:
|
||||
}
|
||||
|
||||
func printComment(w io.Writer, classes []class) {
|
||||
fmt.Fprintf(w, "// %-5s %-9s %-10s %-7s %-11s\n", "class", "bytes/obj", "bytes/span", "objects", "waste bytes")
|
||||
fmt.Fprintf(w, "// %-5s %-9s %-10s %-7s %-10s %-9s\n", "class", "bytes/obj", "bytes/span", "objects", "tail waste", "max waste")
|
||||
prevSize := 0
|
||||
for i, c := range classes {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
spanSize := c.npages * pageSize
|
||||
objects := spanSize / c.size
|
||||
waste := spanSize - c.size*(spanSize/c.size)
|
||||
fmt.Fprintf(w, "// %5d %9d %10d %7d %11d\n", i, c.size, spanSize, objects, waste)
|
||||
tailWaste := spanSize - c.size*(spanSize/c.size)
|
||||
maxWaste := float64((c.size-prevSize-1)*objects+tailWaste) / float64(spanSize)
|
||||
prevSize = c.size
|
||||
fmt.Fprintf(w, "// %5d %9d %10d %7d %10d %8.2f%%\n", i, c.size, spanSize, objects, tailWaste, 100*maxWaste)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
}
|
||||
|
@ -3,73 +3,73 @@
|
||||
|
||||
package runtime
|
||||
|
||||
// class bytes/obj bytes/span objects waste bytes
|
||||
// 1 8 8192 1024 0
|
||||
// 2 16 8192 512 0
|
||||
// 3 32 8192 256 0
|
||||
// 4 48 8192 170 32
|
||||
// 5 64 8192 128 0
|
||||
// 6 80 8192 102 32
|
||||
// 7 96 8192 85 32
|
||||
// 8 112 8192 73 16
|
||||
// 9 128 8192 64 0
|
||||
// 10 144 8192 56 128
|
||||
// 11 160 8192 51 32
|
||||
// 12 176 8192 46 96
|
||||
// 13 192 8192 42 128
|
||||
// 14 208 8192 39 80
|
||||
// 15 224 8192 36 128
|
||||
// 16 240 8192 34 32
|
||||
// 17 256 8192 32 0
|
||||
// 18 288 8192 28 128
|
||||
// 19 320 8192 25 192
|
||||
// 20 352 8192 23 96
|
||||
// 21 384 8192 21 128
|
||||
// 22 416 8192 19 288
|
||||
// 23 448 8192 18 128
|
||||
// 24 480 8192 17 32
|
||||
// 25 512 8192 16 0
|
||||
// 26 576 8192 14 128
|
||||
// 27 640 8192 12 512
|
||||
// 28 704 8192 11 448
|
||||
// 29 768 8192 10 512
|
||||
// 30 896 8192 9 128
|
||||
// 31 1024 8192 8 0
|
||||
// 32 1152 8192 7 128
|
||||
// 33 1280 8192 6 512
|
||||
// 34 1408 16384 11 896
|
||||
// 35 1536 8192 5 512
|
||||
// 36 1792 16384 9 256
|
||||
// 37 2048 8192 4 0
|
||||
// 38 2304 16384 7 256
|
||||
// 39 2688 8192 3 128
|
||||
// 40 3072 24576 8 0
|
||||
// 41 3200 16384 5 384
|
||||
// 42 3456 24576 7 384
|
||||
// 43 4096 8192 2 0
|
||||
// 44 4864 24576 5 256
|
||||
// 45 5376 16384 3 256
|
||||
// 46 6144 24576 4 0
|
||||
// 47 6528 32768 5 128
|
||||
// 48 6784 40960 6 256
|
||||
// 49 6912 49152 7 768
|
||||
// 50 8192 8192 1 0
|
||||
// 51 9472 57344 6 512
|
||||
// 52 9728 49152 5 512
|
||||
// 53 10240 40960 4 0
|
||||
// 54 10880 32768 3 128
|
||||
// 55 12288 24576 2 0
|
||||
// 56 13568 40960 3 256
|
||||
// 57 14336 57344 4 0
|
||||
// 58 16384 16384 1 0
|
||||
// 59 18432 73728 4 0
|
||||
// 60 19072 57344 3 128
|
||||
// 61 20480 40960 2 0
|
||||
// 62 21760 65536 3 256
|
||||
// 63 24576 24576 1 0
|
||||
// 64 27264 81920 3 128
|
||||
// 65 28672 57344 2 0
|
||||
// 66 32768 32768 1 0
|
||||
// class bytes/obj bytes/span objects tail waste max waste
|
||||
// 1 8 8192 1024 0 87.50%
|
||||
// 2 16 8192 512 0 43.75%
|
||||
// 3 32 8192 256 0 46.88%
|
||||
// 4 48 8192 170 32 31.52%
|
||||
// 5 64 8192 128 0 23.44%
|
||||
// 6 80 8192 102 32 19.07%
|
||||
// 7 96 8192 85 32 15.95%
|
||||
// 8 112 8192 73 16 13.56%
|
||||
// 9 128 8192 64 0 11.72%
|
||||
// 10 144 8192 56 128 11.82%
|
||||
// 11 160 8192 51 32 9.73%
|
||||
// 12 176 8192 46 96 9.59%
|
||||
// 13 192 8192 42 128 9.25%
|
||||
// 14 208 8192 39 80 8.12%
|
||||
// 15 224 8192 36 128 8.15%
|
||||
// 16 240 8192 34 32 6.62%
|
||||
// 17 256 8192 32 0 5.86%
|
||||
// 18 288 8192 28 128 12.16%
|
||||
// 19 320 8192 25 192 11.80%
|
||||
// 20 352 8192 23 96 9.88%
|
||||
// 21 384 8192 21 128 9.51%
|
||||
// 22 416 8192 19 288 10.71%
|
||||
// 23 448 8192 18 128 8.37%
|
||||
// 24 480 8192 17 32 6.82%
|
||||
// 25 512 8192 16 0 6.05%
|
||||
// 26 576 8192 14 128 12.33%
|
||||
// 27 640 8192 12 512 15.48%
|
||||
// 28 704 8192 11 448 13.93%
|
||||
// 29 768 8192 10 512 13.94%
|
||||
// 30 896 8192 9 128 15.52%
|
||||
// 31 1024 8192 8 0 12.40%
|
||||
// 32 1152 8192 7 128 12.41%
|
||||
// 33 1280 8192 6 512 15.55%
|
||||
// 34 1408 16384 11 896 14.00%
|
||||
// 35 1536 8192 5 512 14.00%
|
||||
// 36 1792 16384 9 256 15.57%
|
||||
// 37 2048 8192 4 0 12.45%
|
||||
// 38 2304 16384 7 256 12.46%
|
||||
// 39 2688 8192 3 128 15.59%
|
||||
// 40 3072 24576 8 0 12.47%
|
||||
// 41 3200 16384 5 384 6.22%
|
||||
// 42 3456 24576 7 384 8.83%
|
||||
// 43 4096 8192 2 0 15.60%
|
||||
// 44 4864 24576 5 256 16.65%
|
||||
// 45 5376 16384 3 256 10.92%
|
||||
// 46 6144 24576 4 0 12.48%
|
||||
// 47 6528 32768 5 128 6.23%
|
||||
// 48 6784 40960 6 256 4.36%
|
||||
// 49 6912 49152 7 768 3.37%
|
||||
// 50 8192 8192 1 0 15.61%
|
||||
// 51 9472 57344 6 512 14.28%
|
||||
// 52 9728 49152 5 512 3.64%
|
||||
// 53 10240 40960 4 0 4.99%
|
||||
// 54 10880 32768 3 128 6.24%
|
||||
// 55 12288 24576 2 0 11.45%
|
||||
// 56 13568 40960 3 256 9.99%
|
||||
// 57 14336 57344 4 0 5.35%
|
||||
// 58 16384 16384 1 0 12.49%
|
||||
// 59 18432 73728 4 0 11.11%
|
||||
// 60 19072 57344 3 128 3.57%
|
||||
// 61 20480 40960 2 0 6.87%
|
||||
// 62 21760 65536 3 256 6.25%
|
||||
// 63 24576 24576 1 0 11.45%
|
||||
// 64 27264 81920 3 128 10.00%
|
||||
// 65 28672 57344 2 0 4.91%
|
||||
// 66 32768 32768 1 0 12.50%
|
||||
|
||||
const (
|
||||
_MaxSmallSize = 32768
|
||||
|
Loading…
Reference in New Issue
Block a user