-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: increase profiling stack depth to 128
The current stack depth limit for alloc, mutex, block, threadcreate and goroutine profiles of 32 frequently leads to truncated stack traces in production applications. Increase the limit to 128 which is the same size used by the execution tracer. Create internal/profilerecord to define variants of the runtime's StackRecord, MemProfileRecord and BlockProfileRecord types that can hold arbitrarily big stack traces. Implement internal profiling APIs based on these new types and use them for creating protobuf profiles and to act as shims for the public profiling APIs using the old types. This will lead to an increase in memory usage for applications that use the impacted profile types and have stack traces exceeding the current limit of 32. Those applications will also experience a slight increase in CPU usage, but this will hopefully soon be mitigated via CL 540476 and 533258 which introduce frame pointer unwinding for the relevant profile types. For #43669. Change-Id: Ie53762e65d0f6295f5d4c7d3c87172d5a052164e Reviewed-on: https://go-review.googlesource.com/c/go/+/572396 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Austin Clements <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
- Loading branch information
Showing
12 changed files
with
310 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The maximum stack depth for alloc, mutex, block, threadcreate and goroutine | ||
profiles has been raised from 32 to 128 frames. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Package profilerecord holds internal types used to represent profiling | ||
// records with deep stack traces. | ||
// | ||
// TODO: Consider moving this to internal/runtime, see golang.org/issue/65355. | ||
package profilerecord | ||
|
||
type StackRecord struct { | ||
Stack []uintptr | ||
} | ||
|
||
type MemProfileRecord struct { | ||
AllocBytes, FreeBytes int64 | ||
AllocObjects, FreeObjects int64 | ||
Stack []uintptr | ||
} | ||
|
||
func (r *MemProfileRecord) InUseBytes() int64 { return r.AllocBytes - r.FreeBytes } | ||
func (r *MemProfileRecord) InUseObjects() int64 { return r.AllocObjects - r.FreeObjects } | ||
|
||
type BlockProfileRecord struct { | ||
Count int64 | ||
Cycles int64 | ||
Stack []uintptr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.