1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Tests a GC-heavy program. This is useful for shaking out
6 // all sorts of corner cases about GC-related ranges.
26 func makeTree(depth int) *node {
41 var ballast *[32]*[8192]*node
45 for i := range trees {
46 trees[i] = makeTree(6)
48 ballast = new([32]*[8192]*node)
49 for i := range ballast {
50 ballast[i] = new([8192]*node)
51 for j := range ballast[i] {
52 ballast[i][j] = &node{
53 data: [128]byte{1, 2, 3, 4},
57 for i := 0; i < runtime.GOMAXPROCS(-1); i++ {
60 sink = make([]byte, rand.Intn(65536))
64 // Increase the chance that we end up starting and stopping
65 // mid-GC by only starting to trace after a few milliseconds.
66 time.Sleep(5 * time.Millisecond)
69 if err := trace.Start(os.Stdout); err != nil {
70 log.Fatalf("failed to start tracing: %v", err)
74 // Let the tracing happen for a bit.
75 time.Sleep(400 * time.Millisecond)