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 has been available since Linux 2.6.22 and eventfd2 has been available since Linux 2.6.27, the minimal kernel version for 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

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

@panjf2000 panjf2000 self-assigned this Feb 2, 2024
@mknyszek mknyszek added this to the Backlog milestone Feb 7, 2024
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
Development

No branches or pull requests

3 participants