Skip to content

Commit cc16cdf

Browse files
ianlancetaylorgopherbot
authored andcommitted
[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 <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 9563300 commit cc16cdf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime/time.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,11 @@ func (t *timer) unlockAndRun(now int64) {
11141114
// started to send the value. That lets them correctly return
11151115
// true meaning that no value was sent.
11161116
lock(&t.sendLock)
1117+
1118+
// We are committed to possibly sending a value based on seq,
1119+
// so no need to keep telling stop/modify that we are sending.
1120+
t.isSending.And(^isSendingClear)
1121+
11171122
if t.seq != seq {
11181123
f = func(any, uintptr, int64) {}
11191124
}
@@ -1122,9 +1127,6 @@ func (t *timer) unlockAndRun(now int64) {
11221127
f(arg, seq, delay)
11231128

11241129
if !async && t.isChan {
1125-
// We are no longer sending a value.
1126-
t.isSending.And(^isSendingClear)
1127-
11281130
unlock(&t.sendLock)
11291131
}
11301132

0 commit comments

Comments
 (0)