Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: use eventfd as the event wait/notify mechanism for epoll #65443

Closed
panjf2000 opened this issue Feb 2, 2024 · 1 comment
Closed

runtime: use eventfd as the event wait/notify mechanism for epoll #65443

panjf2000 opened this issue Feb 2, 2024 · 1 comment
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done. OS-Linux Performance
Milestone

Comments

@panjf2000
Copy link
Member

panjf2000 commented Feb 2, 2024

Currently, we use pipe to interrupt the epoll_wait, which requires two file descriptors. Furthermore, given its complexity inside, pipe is a bit heavyweight for just a simple event wait/notify mechanism.

eventfd would be a more suitable solution for the current netpoll with epoll in Go, kernel also advocates for developers to use eventfd instead of pipe in some simple scenarios:

Applications can use an eventfd file descriptor instead of a pipe
(see pipe(2)) in all cases where a pipe is used simply to signal
events. The kernel overhead of an eventfd file descriptor is
much lower than that of a pipe, and only one file descriptor is
required (versus the two required for a pipe).

eventfd had been available since Linux 2.6.22 and eventfd2 had been available since Linux 2.6.27, the minimal kernel version required by Go is 2.6.32, so we're good to go.

CC @golang/runtime

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 2, 2024
@panjf2000 panjf2000 added Performance OS-Linux NeedsFix The path to resolution is known, but the work has not been done. labels Feb 2, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/560615 mentions this issue: runtime: use eventfd as the event wait/notify mechanism for epoll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done. OS-Linux Performance
Projects
None yet
Development

No branches or pull requests

3 participants