From c20bcb64882d1134770683d663ee9f82fea715e6 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 7 Jun 2021 16:24:40 -0700 Subject: runtime: remove out-of-date comments about frame skipping skipPleaseUseCallersFrames was removed in CL 152537. Change-Id: Ide47feec85a33a6fb6882e16baf9e21492521640 Reviewed-on: https://go-review.googlesource.com/c/go/+/325949 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/runtime/traceback.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 89780edc1f..814c323634 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -56,8 +56,6 @@ func tracebackdefers(gp *g, callback func(*stkframe, unsafe.Pointer) bool, v uns } } -const sizeofSkipFunction = 256 - // Generic traceback. Handles runtime stack prints (pcbuf == nil), // the runtime.Callers function (pcbuf != nil), as well as the garbage // collector (callback != nil). A little clunky to merge these, but avoids @@ -65,9 +63,7 @@ const sizeofSkipFunction = 256 // // The skip argument is only valid with pcbuf != nil and counts the number // of logical frames to skip rather than physical frames (with inlining, a -// PC in pcbuf can represent multiple calls). If a PC is partially skipped -// and max > 1, pcbuf[1] will be runtime.skipPleaseUseCallersFrames+N where -// N indicates the number of logical frames to skip in pcbuf[0]. +// PC in pcbuf can represent multiple calls). func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max int, callback func(*stkframe, unsafe.Pointer) bool, v unsafe.Pointer, flags uint) int { if skip > 0 && callback != nil { throw("gentraceback callback cannot be used with non-zero skip") -- cgit v1.3-5-g9baa From 689f4c7415acc8a135440574a483e0eeabba8b87 Mon Sep 17 00:00:00 2001 From: Felix Geisendörfer Date: Thu, 3 Jun 2021 15:33:08 +0200 Subject: doc/go1.17: mention block profile bias fix Change-Id: I76fd872b2d74704396f0683ffa9cec40b7027247 Reviewed-on: https://go-review.googlesource.com/c/go/+/324471 Reviewed-by: Heschi Kreinick Trust: Dmitri Shuralyov --- doc/go1.17.html | 10 ++++++++++ src/runtime/pprof/pprof_test.go | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'src/runtime') diff --git a/doc/go1.17.html b/doc/go1.17.html index 42f3631b92..1701508ea9 100644 --- a/doc/go1.17.html +++ b/doc/go1.17.html @@ -725,6 +725,16 @@ Do not send CLs removing the interior tags from such phrases. + +
runtime/pprof
+
+

+ Block profiles are no longer biased to favor infrequent long events over + frequent short events. +

+
+
+
strconv

diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 7cbb4fc7ae..e139ee787d 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -106,6 +106,28 @@ func TestCPUProfileMultithreaded(t *testing.T) { }) } +func TestCPUProfileThreadBias(t *testing.T) { + cpuHogA := func(dur time.Duration) { + cpuHogger(cpuHog1, &salt2, dur) + } + + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) + prof := testCPUProfile(t, stackContains, []string{"runtime/pprof.cpuHog1", "runtime/pprof.cpuHog2"}, avoidFunctions(), func(dur time.Duration) { + //c := make(chan int) + //go func() { + //cpuHogger(cpuHog1, &salt1, dur) + //c <- 1 + //}() + cpuHogA(dur) + //<-c + }) + fmt.Printf("%#v\n", prof) +} + +func cpuHogA(dur time.Duration) { + cpuHogger(cpuHog1, &salt2, dur) +} + // containsInlinedCall reports whether the function body for the function f is // known to contain an inlined function call within the first maxBytes bytes. func containsInlinedCall(f interface{}, maxBytes int) bool { -- cgit v1.3-5-g9baa From cb80937bf6b728fa56ee315d2c079f07c2f9f2a1 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 8 Jun 2021 20:38:30 +0000 Subject: Revert "doc/go1.17: mention block profile bias fix" This reverts CL 324471 (commit 689f4c7415acc8a135440574a483e0eeabba8b87). Reason for revert: break ~all builders. And it is not a doc-only change. Change-Id: Iadbdda34d2ca476a9f5e6c2d3a28592ed7ccb067 Reviewed-on: https://go-review.googlesource.com/c/go/+/326170 Trust: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Heschi Kreinick --- doc/go1.17.html | 10 ---------- src/runtime/pprof/pprof_test.go | 22 ---------------------- 2 files changed, 32 deletions(-) (limited to 'src/runtime') diff --git a/doc/go1.17.html b/doc/go1.17.html index 56f88e6724..1e153377d6 100644 --- a/doc/go1.17.html +++ b/doc/go1.17.html @@ -737,16 +737,6 @@ Do not send CLs removing the interior tags from such phrases.

- -
runtime/pprof
-
-

- Block profiles are no longer biased to favor infrequent long events over - frequent short events. -

-
-
-
strconv

diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index e139ee787d..7cbb4fc7ae 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -106,28 +106,6 @@ func TestCPUProfileMultithreaded(t *testing.T) { }) } -func TestCPUProfileThreadBias(t *testing.T) { - cpuHogA := func(dur time.Duration) { - cpuHogger(cpuHog1, &salt2, dur) - } - - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) - prof := testCPUProfile(t, stackContains, []string{"runtime/pprof.cpuHog1", "runtime/pprof.cpuHog2"}, avoidFunctions(), func(dur time.Duration) { - //c := make(chan int) - //go func() { - //cpuHogger(cpuHog1, &salt1, dur) - //c <- 1 - //}() - cpuHogA(dur) - //<-c - }) - fmt.Printf("%#v\n", prof) -} - -func cpuHogA(dur time.Duration) { - cpuHogger(cpuHog1, &salt2, dur) -} - // containsInlinedCall reports whether the function body for the function f is // known to contain an inlined function call within the first maxBytes bytes. func containsInlinedCall(f interface{}, maxBytes int) bool { -- cgit v1.3-5-g9baa From 77aa209b386a184e7f4b44938f2a05a1b5c5a3cf Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 10 Jun 2021 15:35:05 -0700 Subject: runtime: loop on EINTR in macOS sigNoteSleep Fixes #46466 Change-Id: I8fb15d0c8ef7ef6e6fc1b9e0e033d213255fe0df Reviewed-on: https://go-review.googlesource.com/c/go/+/326778 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Michael Knyszek Reviewed-by: Cherry Mui --- src/runtime/os_darwin.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/os_darwin.go b/src/runtime/os_darwin.go index 00139351ab..079be107d7 100644 --- a/src/runtime/os_darwin.go +++ b/src/runtime/os_darwin.go @@ -118,10 +118,15 @@ func sigNoteWakeup(*note) { // sigNoteSleep waits for a note created by sigNoteSetup to be woken. func sigNoteSleep(*note) { - entersyscallblock() - var b byte - read(sigNoteRead, unsafe.Pointer(&b), 1) - exitsyscall() + for { + var b byte + entersyscallblock() + n := read(sigNoteRead, unsafe.Pointer(&b), 1) + exitsyscall() + if n != -_EINTR { + return + } + } } // BSD interface for threading. -- cgit v1.3-5-g9baa From 1ed0d129e9ba9b55e9ae36ac1d7f2766ba16b373 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 11 Jun 2021 11:50:42 -0700 Subject: runtime: testprogcgo: don't call exported Go functions directly from Go Instead route through a C function, to avoid declaration conflicts between the declaration needed in the cgo comment and the declaration generated by cgo in _cgo_export.h. This is not something user code will ever do, so no need to make it work in cgo. Fixes #46502 Change-Id: I1bfffdc76ef8ea63e3829871298d0774157957a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/327309 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Cherry Mui Reviewed-by: Jason A. Donenfeld --- src/runtime/testdata/testprogcgo/aprof.go | 4 ++-- src/runtime/testdata/testprogcgo/aprof_c.c | 9 +++++++++ src/runtime/testdata/testprogcgo/bigstack1_windows.c | 12 ++++++++++++ src/runtime/testdata/testprogcgo/bigstack_windows.go | 4 ++-- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/runtime/testdata/testprogcgo/aprof_c.c create mode 100644 src/runtime/testdata/testprogcgo/bigstack1_windows.c (limited to 'src/runtime') diff --git a/src/runtime/testdata/testprogcgo/aprof.go b/src/runtime/testdata/testprogcgo/aprof.go index aabca9e1eb..44a15b0865 100644 --- a/src/runtime/testdata/testprogcgo/aprof.go +++ b/src/runtime/testdata/testprogcgo/aprof.go @@ -10,7 +10,7 @@ package main // The test fails when the function is the first C function. // The exported functions are the first C functions, so we use that. -// extern void GoNop(); +// extern void CallGoNop(); import "C" import ( @@ -38,7 +38,7 @@ func CgoCCodeSIGPROF() { break } } - C.GoNop() + C.CallGoNop() } c <- true }() diff --git a/src/runtime/testdata/testprogcgo/aprof_c.c b/src/runtime/testdata/testprogcgo/aprof_c.c new file mode 100644 index 0000000000..d588e13045 --- /dev/null +++ b/src/runtime/testdata/testprogcgo/aprof_c.c @@ -0,0 +1,9 @@ +// Copyright 2021 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. + +#include "_cgo_export.h" + +void CallGoNop() { + GoNop(); +} diff --git a/src/runtime/testdata/testprogcgo/bigstack1_windows.c b/src/runtime/testdata/testprogcgo/bigstack1_windows.c new file mode 100644 index 0000000000..551fb68309 --- /dev/null +++ b/src/runtime/testdata/testprogcgo/bigstack1_windows.c @@ -0,0 +1,12 @@ +// Copyright 2021 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. + +// This is not in bigstack_windows.c because it needs to be part of +// testprogcgo but is not part of the DLL built from bigstack_windows.c. + +#include "_cgo_export.h" + +void CallGoBigStack1(char* p) { + goBigStack1(p); +} diff --git a/src/runtime/testdata/testprogcgo/bigstack_windows.go b/src/runtime/testdata/testprogcgo/bigstack_windows.go index f58fcf993f..135b5fcfe0 100644 --- a/src/runtime/testdata/testprogcgo/bigstack_windows.go +++ b/src/runtime/testdata/testprogcgo/bigstack_windows.go @@ -6,7 +6,7 @@ package main /* typedef void callback(char*); -extern void goBigStack1(char*); +extern void CallGoBigStack1(char*); extern void bigStack(callback*); */ import "C" @@ -18,7 +18,7 @@ func init() { func BigStack() { // Create a large thread stack and call back into Go to test // if Go correctly determines the stack bounds. - C.bigStack((*C.callback)(C.goBigStack1)) + C.bigStack((*C.callback)(C.CallGoBigStack1)) } //export goBigStack1 -- cgit v1.3-5-g9baa