-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Epoll channel register creates a busy-loop with high CPU usage #16240
Description
Following the discussion #16236, I'm opening this issue to discuss a solution. When using the native Epoll implementation, I'm seeing a high CPU usage when a server channel is registered to the EventLoop but not yet bound to a port. After some investigation, I'm seeing the issue seems to lie in the epollWait method not waiting but returning every time with an EPOLLHUP event. I don't know a lot about the native Epoll side, but I'm assuming this is normal because the channel hasn't been bound to a port yet and so epoll generating the event makes sense to me based off what I have read.
This behavior however, causes the eventloop thread to be constantly spinning with no work happening and from testing, this will always happen until the channel is bound to a port and will consume a lot of CPU. Does it make sense to treat is as an issue or is this working as designed? I have an alternative in mind to wait on registering inactive channels until they are active but I wanted to bring this up before I work on a PR.