diff options
| author | Austin Clements <austin@google.com> | 2023-02-13 16:20:54 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2023-03-10 17:59:32 +0000 |
| commit | 2d99109cfcaef22b6872dc2e07e4582586c032a2 (patch) | |
| tree | 958a2c7da4df9d94953e7c2f09aaff9e4c788129 /src/runtime/mbitmap.go | |
| parent | da384766a053d851d912f04afaa1113b627a0822 (diff) | |
| download | go-2d99109cfcaef22b6872dc2e07e4582586c032a2.tar.xz | |
runtime: replace all callback uses of gentraceback with unwinder
This is a really nice simplification for all of these call sites.
It also achieves a nice performance improvement for stack copying:
goos: linux
goarch: amd64
pkg: runtime
cpu: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz
│ before │ after │
│ sec/op │ sec/op vs base │
StackCopyPtr-48 89.25m ± 1% 79.78m ± 1% -10.62% (p=0.000 n=20)
StackCopy-48 83.48m ± 2% 71.88m ± 1% -13.90% (p=0.000 n=20)
StackCopyNoCache-48 2.504m ± 2% 2.195m ± 1% -12.32% (p=0.000 n=20)
StackCopyWithStkobj-48 21.66m ± 1% 21.02m ± 2% -2.95% (p=0.000 n=20)
geomean 25.21m 22.68m -10.04%
Updates #54466.
Change-Id: I31715b7b6efd65726940041d3052bb1c0a1186f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/468297
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mbitmap.go')
| -rw-r--r-- | src/runtime/mbitmap.go | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 7c5856d9e7..ac20bd9ade 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -1397,15 +1397,6 @@ func dumpGCProg(p *byte) { // Testing. -func getgcmaskcb(frame *stkframe, ctxt unsafe.Pointer) bool { - target := (*stkframe)(ctxt) - if frame.sp <= target.sp && target.sp < frame.varp { - *target = *frame - return false - } - return true -} - // reflect_gcbits returns the GC type info for x, for testing. // The result is the bitmap entries (0 or 1), one entry per byte. // @@ -1472,11 +1463,16 @@ func getgcmask(ep any) (mask []byte) { // stack if gp := getg(); gp.m.curg.stack.lo <= uintptr(p) && uintptr(p) < gp.m.curg.stack.hi { - var frame stkframe - frame.sp = uintptr(p) - gentraceback(gp.m.curg.sched.pc, gp.m.curg.sched.sp, 0, gp.m.curg, 0, nil, 1000, getgcmaskcb, noescape(unsafe.Pointer(&frame)), 0) - if frame.fn.valid() { - locals, _, _ := frame.getStackMap(nil, false) + found := false + var u unwinder + for u.initAt(gp.m.curg.sched.pc, gp.m.curg.sched.sp, 0, gp.m.curg, 0); u.valid(); u.next() { + if u.frame.sp <= uintptr(p) && uintptr(p) < u.frame.varp { + found = true + break + } + } + if found { + locals, _, _ := u.frame.getStackMap(nil, false) if locals.n == 0 { return } @@ -1484,7 +1480,7 @@ func getgcmask(ep any) (mask []byte) { n := (*ptrtype)(unsafe.Pointer(t)).elem.size mask = make([]byte, n/goarch.PtrSize) for i := uintptr(0); i < n; i += goarch.PtrSize { - off := (uintptr(p) + i - frame.varp + size) / goarch.PtrSize + off := (uintptr(p) + i - u.frame.varp + size) / goarch.PtrSize mask[i/goarch.PtrSize] = locals.ptrbit(off) } } |
