aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-10-02 13:38:25 -0700
committerGopher Robot <gobot@golang.org>2024-10-08 22:28:41 +0000
commitcc16cdf48f228caebc55c982ed5b1b187ff39fcc (patch)
treea2c1c48beaa373482c97cef10320f3fb136cd803
parent9563300f6e262589ae25c71d778bfcd646d4a750 (diff)
downloadgo-cc16cdf48f228caebc55c982ed5b1b187ff39fcc.tar.xz
[release-branch.go1.23] runtime: clear isSending bit earlier
I've done some more testing of the new isSending field. I'm not able to get more than 2 bits set. That said, with this change it's significantly less likely to have even 2 bits set. The idea here is to clear the bit before possibly locking the channel we are sending the value on, thus avoiding some delay and some serialization. For #69312 For #69333 Change-Id: I8b5f167f162bbcbcbf7ea47305967f349b62b0f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/617596 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
-rw-r--r--src/runtime/time.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/runtime/time.go b/src/runtime/time.go
index b43cf9589b..7abd15ee86 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -1114,6 +1114,11 @@ func (t *timer) unlockAndRun(now int64) {
// started to send the value. That lets them correctly return
// true meaning that no value was sent.
lock(&t.sendLock)
+
+ // We are committed to possibly sending a value based on seq,
+ // so no need to keep telling stop/modify that we are sending.
+ t.isSending.And(^isSendingClear)
+
if t.seq != seq {
f = func(any, uintptr, int64) {}
}
@@ -1122,9 +1127,6 @@ func (t *timer) unlockAndRun(now int64) {
f(arg, seq, delay)
if !async && t.isChan {
- // We are no longer sending a value.
- t.isSending.And(^isSendingClear)
-
unlock(&t.sendLock)
}