I use the NetBeans profiler ,the result in attach.
2014-05-09 11:14 GMT+08:00 fuyou <[email protected]>: > My program is build on Netty4 . > In benchmark,i find the epollWait consume many cpu,the jstack is > > > The stack of busy(10.4%) thread(30873/0x7899) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-9" prio=10 tid=0x00002aaac418a000 nid=0x7899 > runnable [0x0000000045f9a000] > 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 <0x000000076c4cf1e0> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.4%) thread(30866/0x7892) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-2" prio=10 tid=0x00002aaac4252800 nid=0x7892 > runnable [0x0000000045893000] > 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 <0x000000076c4d1990> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.4%) thread(30865/0x7891) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-1" prio=10 tid=0x00002aaab95c0800 nid=0x7891 > runnable [0x0000000045792000] > 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 <0x000000076c47c0f0> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.3%) thread(30871/0x7897) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-7" prio=10 tid=0x00002aaac417f800 nid=0x7897 > runnable [0x0000000045d98000] > 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 <0x000000076c676820> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.3%) thread(30869/0x7895) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-5" prio=10 tid=0x00002aaac4061800 nid=0x7895 > runnable [0x0000000045b96000] > 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 <0x000000076c528d90> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.3%) thread(30867/0x7893) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-3" prio=10 tid=0x00002aaac4254800 nid=0x7893 > runnable [0x0000000045994000] > java.lang.Thread.State: RUNNABLE > at sun.nio.ch.NativeThread.current(Native Method) > at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:333) > - locked <0x000000076c4c90c8> (a java.lang.Object) > - locked <0x000000076c4c90b0> (a java.lang.Object) > at > io.netty.buffer.PooledUnsafeDirectByteBuf.getBytes(PooledUnsafeDirectByteBuf.java:208) > -- > The stack of busy(10.2%) thread(30874/0x789a) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-10" prio=10 tid=0x00002aaac418c800 nid=0x789a > runnable [0x000000004609b000] > 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 <0x000000076c5a70b0> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.2%) thread(30872/0x7898) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-8" prio=10 tid=0x00002aaac4187800 nid=0x7898 > runnable [0x0000000045e99000] > 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 <0x000000076c62f290> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.2%) thread(30870/0x7896) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-6" prio=10 tid=0x00002aaac4190800 nid=0x7896 > runnable [0x0000000045c97000] > 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 <0x000000076c45e320> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > The stack of busy(10.2%) thread(30868/0x7894) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-4" prio=10 tid=0x00002aaac405b000 nid=0x7894 > runnable [0x0000000045a95000] > 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 <0x000000076c6c2660> (a > io.netty.channel.nio.SelectedSelectionKeySet) > [yubao.fyb@vkvm169051 ~]$ cat busy_thread_20140509104529|grep > 'NETTYSERVER-WORKER' -A6 -B2 > The stack of busy(10.4%) thread(30873/0x7899) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-9" prio=10 tid=0x00002aaac418a000 nid=0x7899 > runnable [0x0000000045f9a000] > 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 <0x000000076c4cf1e0> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.4%) thread(30866/0x7892) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-2" prio=10 tid=0x00002aaac4252800 nid=0x7892 > runnable [0x0000000045893000] > 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 <0x000000076c4d1990> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.4%) thread(30865/0x7891) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-1" prio=10 tid=0x00002aaab95c0800 nid=0x7891 > runnable [0x0000000045792000] > 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 <0x000000076c47c0f0> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.3%) thread(30871/0x7897) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-7" prio=10 tid=0x00002aaac417f800 nid=0x7897 > runnable [0x0000000045d98000] > 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 <0x000000076c676820> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.3%) thread(30869/0x7895) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-5" prio=10 tid=0x00002aaac4061800 nid=0x7895 > runnable [0x0000000045b96000] > 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 <0x000000076c528d90> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.3%) thread(30867/0x7893) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-3" prio=10 tid=0x00002aaac4254800 nid=0x7893 > runnable [0x0000000045994000] > java.lang.Thread.State: RUNNABLE > at sun.nio.ch.NativeThread.current(Native Method) > at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:333) > - locked <0x000000076c4c90c8> (a java.lang.Object) > - locked <0x000000076c4c90b0> (a java.lang.Object) > at > io.netty.buffer.PooledUnsafeDirectByteBuf.getBytes(PooledUnsafeDirectByteBuf.java:208) > -- > > The stack of busy(10.2%) thread(30874/0x789a) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-10" prio=10 tid=0x00002aaac418c800 nid=0x789a > runnable [0x000000004609b000] > 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 <0x000000076c5a70b0> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.2%) thread(30872/0x7898) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-8" prio=10 tid=0x00002aaac4187800 nid=0x7898 > runnable [0x0000000045e99000] > 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 <0x000000076c62f290> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.2%) thread(30870/0x7896) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-6" prio=10 tid=0x00002aaac4190800 nid=0x7896 > runnable [0x0000000045c97000] > 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 <0x000000076c45e320> (a > io.netty.channel.nio.SelectedSelectionKeySet) > -- > > The stack of busy(10.2%) thread(30868/0x7894) of java process(30757) of > user(fuyou): > "NETTYSERVER-WORKER-19-thread-4" prio=10 tid=0x00002aaac405b000 nid=0x7894 > runnable [0x0000000045a95000] > 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 <0x000000076c6c2660> (a > io.netty.channel.nio.SelectedSelectionKeySet) > > epollWait(...) blocks.why the consume cpu? has any idea to reduce cpu > > I also asked the question in Netty > github<https://github.com/netty/netty/issues/2465> > ============================================= > > fuyou001 > Best Regards > > -- ============================================= fuyou001 Best Regards
