From bd5595d7fa4eb3e234aabeac554f2ba8f2a95790 Mon Sep 17 00:00:00 2001 From: Leonard Wang Date: Wed, 13 Apr 2022 21:14:22 +0800 Subject: runtime: refactor finalizer goroutine status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use an atomic.Uint32 to represent the state of finalizer goroutine. fingStatus will only be changed to fingWake in non fingWait state, so it is safe to set fingRunningFinalizer status in runfinq. name old time/op new time/op delta Finalizer-8 592µs ± 4% 561µs ± 1% -5.22% (p=0.000 n=10+10) FinalizerRun-8 694ns ± 6% 675ns ± 7% ~ (p=0.059 n=9+8) Change-Id: I7e4da30cec98ce99f7d8cf4c97f933a8a2d1cae1 Reviewed-on: https://go-review.googlesource.com/c/go/+/400134 Reviewed-by: Joedian Reid TryBot-Result: Gopher Robot Run-TryBot: Daniel Martí Reviewed-by: Michael Pratt --- src/runtime/export_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/runtime/export_test.go') diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 77e4279b9d..c29d64a885 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -1264,10 +1264,7 @@ func SetIntArgRegs(a int) int { } func FinalizerGAsleep() bool { - lock(&finlock) - result := fingwait - unlock(&finlock) - return result + return fingStatus.Load()&fingWait != 0 } // For GCTestMoveStackOnNextCall, it's important not to introduce an -- cgit v1.3-5-g9baa