diff options
| author | Leonard Wang <wangdeyu0907@gmail.com> | 2022-04-13 21:14:22 +0800 |
|---|---|---|
| committer | Daniel Martí <mvdan@mvdan.cc> | 2022-09-05 08:28:34 +0000 |
| commit | bd5595d7fa4eb3e234aabeac554f2ba8f2a95790 (patch) | |
| tree | 5f1e4bc7f0e801e11b3698d199e1c4eb4fd9f7ff /src/runtime/proc.go | |
| parent | 67e6542467321099c0ffcf77ee660e28ec211588 (diff) | |
| download | go-bd5595d7fa4eb3e234aabeac554f2ba8f2a95790.tar.xz | |
runtime: refactor finalizer goroutine status
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 <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 49f2caceac..9ebb25bfd0 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -2628,7 +2628,7 @@ top: } // Wake up the finalizer G. - if fingwait && fingwake { + if fingStatus.Load()&(fingWait|fingWake) == fingWait|fingWake { if gp := wakefing(); gp != nil { ready(gp, 0, true) } |
