aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/netpoll_kqueue.go
diff options
context:
space:
mode:
authorMaksym Sobolyev <sobomax@sippysoft.com>2024-11-20 19:27:40 +0000
committerGopher Robot <gobot@golang.org>2024-11-21 16:24:21 +0000
commit21b5f2637a37fe2fece7e6bf3d5f97a9520693ba (patch)
treeba9bbf54ff94e8eed06ba12938d7f79a325da243 /src/runtime/netpoll_kqueue.go
parent844426104a901b68f3a8c7a7ca96d910b03fb054 (diff)
downloadgo-21b5f2637a37fe2fece7e6bf3d5f97a9520693ba.tar.xz
runtime: utilize EVFILT_USER more effectively
Re-work kqueue_event wakeup logic to use one-shot events. In an event of waking up a wrong thread, simply re-post the event. This saves close to 1 system call per wakeup on average, since chances of non-blocking poller picking it up is pretty low. Change-Id: I202d0d57a31d91ac5354ea075215f647c65790d3 GitHub-Last-Rev: e707d4732683702bd2989f07230a2f34354c288b GitHub-Pull-Request: golang/go#70408 Reviewed-on: https://go-review.googlesource.com/c/go/+/628975 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/netpoll_kqueue.go')
-rw-r--r--src/runtime/netpoll_kqueue.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/runtime/netpoll_kqueue.go b/src/runtime/netpoll_kqueue.go
index ca7898205e..db4dddc2fe 100644
--- a/src/runtime/netpoll_kqueue.go
+++ b/src/runtime/netpoll_kqueue.go
@@ -129,10 +129,11 @@ retry:
ev := &events[i]
if isWakeup(ev) {
- if delay != 0 {
+ isBlocking := delay != 0
+ processWakeupEvent(kq, isBlocking)
+ if isBlocking {
// netpollBreak could be picked up by a nonblocking poll.
- // Only call drainWakeupEvent and reset the netpollWakeSig if blocking.
- drainWakeupEvent(kq)
+ // Only reset the netpollWakeSig if blocking.
netpollWakeSig.Store(0)
}
continue