GeezerVison is showing github.com — Epoll channel register creates a busy-loop with high CPU usage · Issue #16240 · netty/netty
Epoll channel register creates a busy-loop with high CPU usage #16240DescriptionFollowing 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. Activitynormanmaurer commented on Feb 8, 2026 This is definitely an issue ... let me check in detail franz1981 commented on Feb 8, 2026 In the event processing loop we could check if the channel is active before processing EPOLLHUP events. If inactive, simply ignore the event 🤔 normanmaurer commented on Feb 8, 2026
In the event processing loop we could check if the channel is active before processing EPOLLHUP events. If inactive, simply ignore the event 🤔
I will provide a better fix tomorrow Reacted by Isaac A. Rivera Rivas Reacted by Francesco Nigro isaacrivriv commented on Feb 8, 2026 ContributorAuthor More actions Thanks for taking a look!!
In the event processing loop we could check if the channel is active before processing EPOLLHUP events. If inactive, simply ignore the event 🤔
I did try this Francesco but unfortunately because the channel is still registered in epoll, whenever the next epollWait is called it will still return immediately continuing the busy loop... A solution I found that would work was to wait on calling epollCtlAdd until the channel is active, by then the EPOLLHUP events would no longer continue occurring and the implementation would work as expected.
I'll leave it to @normanmaurer for a proper solution and continue monitoring. Thanks again! normanmaurer commented on Feb 9, 2026 This is a bit more complicated as it also needs some other fixes. Working on it. Reacted by Isaac A. Rivera Rivas normanmaurer commented on Feb 10, 2026 normanmaurer commented on Feb 12, 2026 Ok verified... this problem only affects 4.2 and 5.0
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|