aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mksizeclasses.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2024-05-20 20:31:36 +0000
committerGopher Robot <gobot@golang.org>2024-05-22 20:31:27 +0000
commitefe7a1f5d3ccdef5c25cb4d8386492a7b1785600 (patch)
tree17d999b94c25ecd3f5e54bac6426b10e08dc4661 /src/runtime/mksizeclasses.go
parentfb5d0cdd491017db1978001b5054cd19569aa8de (diff)
downloadgo-efe7a1f5d3ccdef5c25cb4d8386492a7b1785600.tar.xz
runtime: write out a batch with alignment info for traceallocfree
Currently the traceallocfree experiment is missing info in the trace for interpeting the produced events. Most notably, the base heap address is missing. While not technically necessary, it is useful for getting an accurate picture of the program's memory layout, and will be useful for future trace experiments. Since we want to emit a batch for this, we should also emit a batch for all the alignment info that's used to compress the addresses (IDs) produced for the alloc/free events. This CL distinguishes the different formats of the experimental batches (note that there's already batches containing type information in this experiment) by putting a byte at the beginning of each experimental batch indicating its format. Change-Id: Ifc4e77a23458713b7d95e0dfa056a29e1629ccd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/586997 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mksizeclasses.go')
-rw-r--r--src/runtime/mksizeclasses.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/mksizeclasses.go b/src/runtime/mksizeclasses.go
index 26ca49e6eb..bb06ba1edd 100644
--- a/src/runtime/mksizeclasses.go
+++ b/src/runtime/mksizeclasses.go
@@ -75,6 +75,7 @@ func main() {
const (
// Constants that we use and will transfer to the runtime.
+ minHeapAlign = 8
maxSmallSize = 32 << 10
smallSizeDiv = 8
smallSizeMax = 1024
@@ -99,7 +100,7 @@ func makeClasses() []class {
classes = append(classes, class{}) // class #0 is a dummy entry
- align := 8
+ align := minHeapAlign
for size := align; size <= maxSmallSize; size += align {
if powerOfTwo(size) { // bump alignment once in a while
if size >= 2048 {
@@ -288,6 +289,7 @@ func maxObjsPerSpan(classes []class) int {
func printClasses(w io.Writer, classes []class) {
fmt.Fprintln(w, "const (")
+ fmt.Fprintf(w, "minHeapAlign = %d\n", minHeapAlign)
fmt.Fprintf(w, "_MaxSmallSize = %d\n", maxSmallSize)
fmt.Fprintf(w, "smallSizeDiv = %d\n", smallSizeDiv)
fmt.Fprintf(w, "smallSizeMax = %d\n", smallSizeMax)