GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — EPollArrayWrapper.epollWait 100% CPU Usage · Issue #327 · netty/netty

EPollArrayWrapper.epollWait 100% CPU Usage #327

New issue
Copy link
New issue
Copy link
Closed
Closed
EPollArrayWrapper.epollWait 100% CPU Usage#327
Copy link
Assignees
normanmaurer
Labels
defect
Milestone
3.5.7.Final

Description

@blucas
blucas
opened on May 16, 2012
Issue body actions

Hi,

I believe I have an issue similar to #302 but on Linux (Ubuntu 10.04) with JDK (1.6.0u30) and JDK(1.7.0u4) using Netty-4.0.0 (Revision: 52a7d28)

The app is proxying connections to backend systems. The proxy has a pool of channels that it can use to send requests to the backend systems. If the pool is low on channels, new channels are spawned and put into the pool so that requests sent to the proxy can be serviced. The pools get populated on app startup, so that is why it doesn't take long at all for the CPU to spike through the roof (22 seconds into the app lifecycle).

The test box has two CPUs, the output from 'top' is below:

PID  USER   PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
8220 root   20   0 2281m 741m  10m R 50.2 18.7  0:22.57 java                                                                             
8218 root   20   0 2281m 741m  10m R 49.9 18.7  0:22.65 java                                                                             
8219 root   20   0 2281m 741m  10m R 49.2 18.7  0:22.86 java                                                                             
8221 root   20   0 2281m 741m  10m R 49.2 18.7  0:22.20 java 

Thread Dump for the four NioClient based Worker Threads that are chewing up all the CPU.

"backend-worker-pool-7-thread-1" prio=10 tid=0x00007f5918015800 nid=0x201a runnable [0x00007f5924ba3000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
    - locked <0x000000008be93580> (a sun.nio.ch.Util$2)
    - locked <0x000000008be93570> (a java.util.Collections$UnmodifiableSet)
    - locked <0x000000008be92548> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
    at io.netty.channel.socket.nio.SelectorUtil.select(SelectorUtil.java:55)
    at io.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:261)
    at io.netty.channel.socket.nio.NioWorker.run(NioWorker.java:37)
    at io.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:43)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)   Locked ownable synchronizers:    - <0x000000008be00748> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
"backend-worker-pool-7-thread-2" prio=10 tid=0x00007f5918012000 nid=0x201b runnable [0x00007f5924b82000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
    - locked <0x000000008be94a28> (a sun.nio.ch.Util$2)
    - locked <0x000000008be94a18> (a java.util.Collections$UnmodifiableSet)
    - locked <0x000000008be90648> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
    at io.netty.channel.socket.nio.SelectorUtil.select(SelectorUtil.java:55)
    at io.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:261)
    at io.netty.channel.socket.nio.NioWorker.run(NioWorker.java:37)
    at io.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:43)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)   Locked ownable synchronizers:    - <0x000000008be904c8> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
"backend-worker-pool-7-thread-3" prio=10 tid=0x00007f5918007800 nid=0x201c runnable [0x00007f5924b61000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
    - locked <0x000000008be952e0> (a sun.nio.ch.Util$2)
    - locked <0x000000008be952d0> (a java.util.Collections$UnmodifiableSet)
    - locked <0x000000008be8f858> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
    at io.netty.channel.socket.nio.SelectorUtil.select(SelectorUtil.java:55)
    at io.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:261)
    at io.netty.channel.socket.nio.NioWorker.run(NioWorker.java:37)
    at io.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:43)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)   Locked ownable synchronizers:    - <0x000000008be8f618> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
"backend-worker-pool-7-thread-4" prio=10 tid=0x00007f5918019000 nid=0x201d runnable [0x00007f5924b40000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
    - locked <0x000000008be003f8> (a sun.nio.ch.Util$2)
    - locked <0x000000008be003e8> (a java.util.Collections$UnmodifiableSet)
    - locked <0x000000008be00408> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
    at io.netty.channel.socket.nio.SelectorUtil.select(SelectorUtil.java:55)
    at io.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:261)
    at io.netty.channel.socket.nio.NioWorker.run(NioWorker.java:37)
    at io.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:43)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)   Locked ownable synchronizers:    - <0x000000008be004e0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

Activity

Next
  1. blucas commented on May 16, 2012

    @blucas
    blucas
    on May 16, 2012
    ContributorAuthor
    More actions

    I've done some googling and it looks like this could be a JDK bug.
    Take a look at the thread dump supplied on 13-MAY-2009. It is exactly the same as mine! Although they say the bug has been fixed, it obviously hasn't. Could you please investigate the workaround supplied in the link? They mention cancelling the selector and invoking a selectNow() method. I have NO clue where to do that myself to test if it actually works, so if someone could change it in the repo, I'm more than happy to give it a test.

    In fact I've actually found a post by @trustin on this very subject. But it looks like no changes were made back then.

    Reacted by musoon, XiongQingLiang, QABQ, Sailong Ren, George Li and Nazar
  2. blucas commented on May 18, 2012

    @blucas
    blucas
    on May 18, 2012
    ContributorAuthor
    More actions

    @trustin @normanmaurer Any thoughts on this?

  3. Eirenliel commented on Jun 14, 2012

    @Eirenliel
    Eirenliel
    on Jun 14, 2012
    More actions

    Please, update. Merged on new server wit j6u33 and now experiencing this bug. Will try to downgrade jre...

  4. Eirenliel commented on Jun 14, 2012

    @Eirenliel
    Eirenliel
    on Jun 14, 2012
    More actions

    It is happens on Netty 3.5.0 Final, 3.2.7 Final and 3.4.7 j6u33 and may be others.

  5. twinforces commented on Jul 9, 2012

    @twinforces
    twinforces
    on Jul 9, 2012
    More actions

    Yeah, I see this too with UltraESB.

    I think its a problem with anything that uses the Non-blocking IO library.

  6. incubos commented on Jul 26, 2012

    @incubos
    incubos
    on Jul 26, 2012
    More actions

    I confirm this bug on Netty 3.3.0 Final (from Akka 2.0.2) & j7u4.

  7. vikiitd commented on Aug 2, 2012

    @vikiitd
    vikiitd
    on Aug 2, 2012
    More actions

    Hi,

    We are seeing this issue in our production environment also under heavy concurrent load. Are there any updates/fix for this issue. On some forums there are discussions related to this issue being resolved by upgrading jdk, etc. I am not seeing this issue with netty.3.2.4.Final.jar but it is happening consistently with netty3.4.4.Final.jar Does anyone know if there is a work-around for this issue besides downgrading back to 3.2.4 netty jar version.

    Thanks in advance!

  8. vikiitd commented on Aug 8, 2012

    @vikiitd
    vikiitd
    on Aug 8, 2012
    More actions

    I am observing this issue with Netty-3.2.6.Final.jar also, although less frequently. Is it possible that this issue got introduced before 3.3 or it is not a netty issue at all?

  9. trustin commented on Aug 9, 2012

    @trustin
    trustin
    on Aug 9, 2012
    Member
    More actions

    Is there any reliable way to reproduce this problem? Then it would be much easier for me to fix this issue (probably it's more correct to say 'apply workaround').

  10. vrajesh1989 commented on Aug 12, 2012

    @vrajesh1989
    vrajesh1989
    on Aug 12, 2012
    More actions

    Hi. This issue is occurring in Netty-3.2.4.Final.jar also. There is no reliable way to reproduce this issue, it is not happening consistently.

  11. ghost assigned
    normanmaurer
    on Aug 23, 2012
  12. normanmaurer commented on Aug 23, 2012

    @normanmaurer
    normanmaurer
    on Aug 23, 2012
    Member
    More actions

    Let me see if I can fix this ...

  13. normanmaurer
    added a commit that references this issue on Aug 25, 2012

    Re-create Selector if we hit the epoll(..) jdk bug which leads to 100…

    ff3f2b6
  14. normanmaurer commented on Aug 25, 2012

    @normanmaurer
    normanmaurer
    on Aug 25, 2012
    Member
    More actions

    @trustin I think this is because of an epoll bug which still is not fixed or was fixed and is now present again.

    Please review the following workaround:
    #565

    So basically we do the following here:

    • check if Selector.select(timeout) returns 0 and complete before the timeout
    • if so we increment a counter
    • if the counter == 10 we create a new selector and register all the Channels from the old one to the new one and close the old Selector. After that we reset the counter.
    • if the counter < 10 we just process
    • if Selector.select(timeout) returns > 0 or complete after the timeout we reset the counter

    The fix is kind of the same as jetty,grizzly and mina do :) WDYT ?

  15. vikiitd commented on Aug 27, 2012

    @vikiitd
    vikiitd
    on Aug 27, 2012
    More actions

    it will be great if we can have the workaround provided by @normanmaurer . The jdk bug seems to be hanging around for sometime now, not sure if it is getting fixed anytime soon.

  16. 63 remaining items

  17. senthilec566 commented on Jul 5, 2017

    @senthilec566
    senthilec566
    on Jul 5, 2017
    More actions

    @normanmaurer - Any work around for this ? Should i try old version of Netty ??

  18. senthilec566 commented on Jul 6, 2017

    @senthilec566
    senthilec566
    on Jul 6, 2017
    More actions

    @normanmaurer - Any findings ? Meantime i will try other version of netty ..

  19. Scottmitch commented on Jul 6, 2017

    @Scottmitch
    Scottmitch
    on Jul 6, 2017
    Member
    More actions

    @senthilec566 - your issue is using the Epoll JNI transport but this issue was opened against the NIO transport. Can you open another issue?

    Also what is your usage pattern look like? Do you have sockets being opened/closed constantly or just a few that are active? If you take successive snapshots (e..g 20 ish) do you see the stack trace change? Seeing the stack trace at epillWait is not necessarily a problem and can be common (it's how the OS tells us what events are pending and is called frequently). Also a reproducer would be nice.

  20. umerpk commented on Oct 26, 2017

    @umerpk
    umerpk
    on Oct 26, 2017
    More actions

    We are still having same issue on Java 1.8?

    "GS-LRMI-Selector-Read-Thread-0" daemon prio=10 tid=0x00007fdc3d550800 nid=0x7533 runnable [0x00007fdbbafdd000]
    java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
    - locked <0x0000000572484890> (a sun.nio.ch.Util$2)
    - locked <0x00000005724848a0> (a java.util.Collections$UnmodifiableSet)
    - locked <0x0000000572484848> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
    at com.gigaspaces.lrmi.nio.selector.handler.AbstractSelectorThread.doSelect(AbstractSelectorThread.java:62)
    at com.gigaspaces.lrmi.nio.selector.handler.AbstractSelectorThread.run(AbstractSelectorThread.java:51)
    at java.lang.Thread.run(Thread.java:744)

    Locked ownable synchronizers:
    - None

    Reacted by Dmitry Bedrin, Alik Elzin, yarondav, Hao Wang, zhengfh, rohitsahay2000, Ximo Guanter, Siarhei Krukau, Simon Schärer, George Li and 2 more
  21. rohitsahay2000 commented on Nov 13, 2018

    @rohitsahay2000
    rohitsahay2000
    on Nov 13, 2018
    More actions

    Facing the same issue with jdk 1.8, netty 4.1.25. The below screenshot was taken when the thread count already hit 1450 (starting from 200)

    screen shot 2018-11-13 at 4 08 10 pm

    The event loop group thread count keeps on increasing leading to very high cpu usage and unresponsive container inspite of closing them regularly.

    One of the typical threads (having lots of instances) from jstack
    nioEventLoopGroup-8870-1 tid=13320
    java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:281)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:105)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:98)
    - locked <0x4f8900cd> (a io.netty.channel.nio.SelectedSelectionKeySet)
    - locked <0x83732742> (a java.util.Collections$UnmodifiableSet)
    - locked <0x288f21af> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:109)
    at io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
    at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:811)

    Locked ownable synchronizers:
    - None
    
    Reacted by Siarhei Krukau and George Li
  22. VaughnVernon commented on Jan 30, 2020

    @VaughnVernon
    VaughnVernon
    on Jan 30, 2020
    More actions

    Hi All, We have hit this problem in a different project (not using Netty) and are looking for a fix/workaround. This only happens on Linux. We would really appreciate some help in learning how you solved this. Would someone please summarize the solution and source files involved? Sorry, it's difficult to piece together what finally worked given all the related discussions/issues.

    vlingo/xoom-wire#28

  23. atorr0 commented on Apr 8, 2020

    @atorr0
    atorr0
    on Apr 8, 2020
    More actions

    Hi all,

    The epoll bug is a well-known one with Java NIO framework, that seems fixed in NIO2.

    I hope Netty not having to delve into JNI/JNA/etc. to fix it, but in this case maybe you can even improve it.

    More info on #2515

  24. Workeryuan commented on Mar 11, 2021

    @Workeryuan
    Workeryuan
    on Mar 11, 2021
    More actions

    We are still having same issue on Development environment jdk1.8,Operating environment jre 1.2.
    #27 daemon prio=5 os_prio=0 tid=0x00007f6cc41f3000 nid=0xbc59 runnable [0x00007f6cd69f4000]
    java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
    at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
    at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
    - locked <0x00000006c08856c8> (a sun.nio.ch.Util$3)
    - locked <0x00000006c08856d8> (a java.util.Collections$UnmodifiableSet)
    - locked <0x00000006c0885680> (a sun.nio.ch.EPollSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:349)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)

    Locked ownable synchronizers:
    - None

  25. ITzhangqiang commented on Jul 21, 2021

    @ITzhangqiang
    ITzhangqiang
    on Jul 21, 2021
    More actions

    so how to slove this issue?

  26. Suddenlove commented on Mar 1, 2022

    @Suddenlove
    Suddenlove
    on Mar 1, 2022
    More actions

    My application changed netty from 3.6.0.Final to 3.10.6.Final and CPU usage returns to normal, JDK version is 1.8.0_101.

  27. expertjavaguy
    added a commit that references this issue on May 26, 2022

    upgrade netty to fix CPU usage in Lantern refs netty/netty#327

    1702c33
  28. happyforver commented on Dec 12, 2022

    @happyforver
    happyforver
    on Dec 12, 2022
    More actions

    We are still having same issue on Development environment jdk1.8,Operating environment jre 1.2. #27 daemon prio=5 os_prio=0 tid=0x00007f6cc41f3000 nid=0xbc59 runnable [0x00007f6cd69f4000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method) at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269) at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x00000006c08856c8> (a sun.nio.ch.Util$3) - locked <0x00000006c08856d8> (a java.util.Collections$UnmodifiableSet) - locked <0x00000006c0885680> (a sun.nio.ch.EPollSelectorImpl) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:349) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)

    Locked ownable synchronizers: - None

    Workeryuan

    hi, now, i have same issue. do you fix this ?

  29. happyforver commented on Dec 13, 2022

    @happyforver
    happyforver
    on Dec 13, 2022
    More actions

    i updated to jdk11 , not working...

  30. chrisvest
    added a commit that references this issue on Apr 2, 2025

    Add support for Mac m1 (netty#327)

    f20b191
  31. chrisvest
    added a commit that references this issue on Apr 18, 2025

    Update to netty-incubator-codec-quic 0.0.71.Final (netty#327)

    ebff1e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @normanmaurer
    normanmaurer

Labels

defect

Type

No type

Projects

No projects

    Milestone

    • 3.5.7.Final

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.