mirror of
https://github.com/golang/go
synced 2024-10-06 08:00:07 +00:00
runtime/trace: ignore fallback stacks in test
When runtime.sigprof encounters a stack that gentraceback is unable to process, it synthesizes a call stack with a sentinel function (such as runtime._System) at the leaf. The test to confirm that runtime/trace and runtime/pprof have similar views of CPU profile samples has trouble with those stacks. The test confirms that the samples match by confirming that their symbolized forms match, and the symbolization procedure is very different for the two packages. Skip the samples that the CPU profiler's view symbolizes to include one of runtime.sigprof's sentinel functions at the leaf. (The test design expects the CPU profiler to under-report samples relative to the execution tracer.) Fixes #53378 Change-Id: I60c27de4c69b454057d28a3b6e12d70369de4c4f Reviewed-on: https://go-review.googlesource.com/c/go/+/413457 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Rhys Hiltner <rhys@justin.tv> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
66685fb7dd
commit
ab422f2749
|
@ -634,15 +634,29 @@ func TestTraceCPUProfile(t *testing.T) {
|
||||||
pprofStacks := make(map[string]int)
|
pprofStacks := make(map[string]int)
|
||||||
for _, s := range prof.Sample {
|
for _, s := range prof.Sample {
|
||||||
if s.Label["tracing"] != nil {
|
if s.Label["tracing"] != nil {
|
||||||
samples := int(s.Value[0])
|
|
||||||
pprofSamples += samples
|
|
||||||
var fns []string
|
var fns []string
|
||||||
|
var leaf string
|
||||||
for _, loc := range s.Location {
|
for _, loc := range s.Location {
|
||||||
for _, line := range loc.Line {
|
for _, line := range loc.Line {
|
||||||
fns = append(fns, fmt.Sprintf("%s:%d", line.Function.Name, line.Line))
|
fns = append(fns, fmt.Sprintf("%s:%d", line.Function.Name, line.Line))
|
||||||
|
leaf = line.Function.Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// runtime.sigprof synthesizes call stacks when "normal traceback is
|
||||||
|
// impossible or has failed", using particular placeholder functions
|
||||||
|
// to represent common failure cases. Look for those functions in
|
||||||
|
// the leaf position as a sign that the call stack and its
|
||||||
|
// symbolization are more complex than this test can handle.
|
||||||
|
//
|
||||||
|
// TODO: Make the symbolization done by the execution tracer and CPU
|
||||||
|
// profiler match up even in these harder cases. See #53378.
|
||||||
|
switch leaf {
|
||||||
|
case "runtime._System", "runtime._GC", "runtime._ExternalCode", "runtime._VDSO":
|
||||||
|
continue
|
||||||
|
}
|
||||||
stack := strings.Join(fns, " ")
|
stack := strings.Join(fns, " ")
|
||||||
|
samples := int(s.Value[0])
|
||||||
|
pprofSamples += samples
|
||||||
pprofStacks[stack] += samples
|
pprofStacks[stack] += samples
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue