High CPU in NIO Selector calls

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP) 6
  • Java 6

Issue

  • We are seeing high CPU in remoting threads making calls on NIO Selectors, for example:
"Remoting "smisqa2:smisqa2-a:MANAGEMENT" read-1" prio=3 tid=0x0000000101b3e000 nid=0x18 runnable [0xffffffff71efe000]
    java.lang.Thread.State: RUNNABLE
      at sun.nio.ch.DevPollArrayWrapper.poll0(Native Method)
      at sun.nio.ch.DevPollArrayWrapper.poll(DevPollArrayWrapper.java:220)
      at sun.nio.ch.DevPollSelectorImpl.doSelect(DevPollSelectorImpl.java:84)
      at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
      - locked <0xffffffff586bcc20> (a sun.nio.ch.Util$2)
      - locked <0xffffffff586bcc10> (a java.util.Collections$UnmodifiableSet)
      - locked <0xffffffff586b7f90> (a sun.nio.ch.DevPollSelectorImpl)
      at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
      at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:102)
      at org.xnio.nio.WorkerThread.run(WorkerThread.java:153)

Or:

"Thread-83" prio=6 tid=0x00000000285d9000 nid=0x1398 runnable [0x000000002e55f000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:295)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:277)
	at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:158)
	at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
	- locked <0x00000006d1693fa0> (a sun.nio.ch.Util$2)
	- locked <0x00000006d1693f90> (a java.util.Collections$UnmodifiableSet)
	- locked <0x00000006d1693fb0> (a sun.nio.ch.WindowsSelectorImpl)
	at sun.nio.ch.SelectorImpl.selectNow(SelectorImpl.java:106)
	at org.jboss.sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:445)
	at java.lang.Thread.run(Thread.java:722)

Resolution

  • This issue was fixed in JDK7 b12. Upgrade to the latest Java 7 update to acquire all relevant fixes.

  • If that CPU is seen from ServerImpl$Dispatcher's selector calls, that would be tied to the http management interface. To avoid that, you can consider disabling the http management interface by commenting out the following in your standalone or host xml file:

      <http-interface security-realm="ManagementRealm">
          <socket-binding http="management-http"/>
      </http-interface>
    

Root Cause

Diagnostic Steps

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.