hi, Alexey
Thank you for you reply.
I see at least 20 threads and I did not read every line of the log.
But I set the read thread count to 10.
Michael
Oleksiy Stashok wrote:
>
> Hi,
>
> how many threads you see in the mentioned state?
>
> Thanks.
>
> WBR,
> Alexey.
>
> On Sep 9, 2008, at 15:44 , gnome wrote:
>
>>
>> Hi all,
>> I am using grizzly for a nio server. And it always take 800% CPU
>> on a
>> multi-core system. In kill -3 log there is many thread is doing
>> epollWait()
>> like this:
>> "Thread-27" prio=10 tid=0x00002aaaf72c8400 nid=0x7217 runnable
>> [0x0000000043159000..0x0000000043159ab0]
>> java.lang.Thread.State: RUNNABLE
>> at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
>> at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:
>> 215)
>> at
>> sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
>> at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:
>> 69)
>> - locked <0x00002aaab35a5e78> (a sun.nio.ch.Util$1)
>> - locked <0x00002aaab35a5e60> (a
>> java.util.Collections$UnmodifiableSet)
>> - locked <0x00002aaab35a5ad0> (a sun.nio.ch.EPollSelectorImpl)
>> at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
>> at
>> com.sun.grizzly.TCPSelectorHandler.select(TCPSelectorHandler.java:343)
>> at com.sun.grizzly.Controller.doSelect(Controller.java:280)
>> at com.sun.grizzly.ReadController.start(ReadController.java:
>> 108)
>> - locked <0x00002aaab35a6120> (a java.lang.Object)
>> at com.sun.grizzly.Controller.run(Controller.java:652)
>> at java.lang.Thread.run(Thread.java:619)
>>
>>
>> The server code is:
>>
>> int port = 5333;
>> try {
>> Controller controller = new Controller();
>> TCPSelectorHandler selectorHandler = new TCPSelectorHandler(false);
>> selectorHandler.setPort(port);
>> selectorHandler.setSocketTimeout(5 * 60 * 1000);
>> selectorHandler.setSelectTimeout(50);
>> controller.setSelectorHandler(selectorHandler);
>> controller.setReadThreadsCount(10);
>> controller.setHandleReadWriteConcurrently(true);
>>
>> DefaultSelectionKeyHandler keyHandler = new
>> DefaultSelectionKeyHandler(
>> selectorHandler) {
>>
>> @Override
>> public void register(Iterator<SelectionKey> iterator, int ops) {
>> long currentTime = System.currentTimeMillis();
>> SelectionKey key;
>> while (iterator.hasNext()) {
>> key = iterator.next();
>> iterator.remove();
>> if (!key.isValid()) {
>> continue;
>> }
>>
>> key.interestOps(key.interestOps() | ops);
>> Object attachment = key.attachment();
>> // By default, attachment a null.
>> if (attachment == null) {
>> key.attach(currentTime);
>> } else if (attachment instanceof ThreadAttachment) {
>> }
>> }
>> }
>> };
>> selectorHandler.setSelectionKeyHandler(keyHandler);
>>
>> final DefaultProtocolChain protocolChain = new
>> DefaultProtocolChain();
>>
>> DefaultProtocolChainInstanceHandler instanceHandler = new
>> DefaultProtocolChainInstanceHandler() {
>> /**
>> * Always return instance of ProtocolChain.
>> */
>> @Override
>> public ProtocolChain poll() {
>> return protocolChain;
>> }
>>
>> /**
>> * Pool an instance of ProtocolChain.
>> */
>> @Override
>> public boolean offer(ProtocolChain instance) {
>> return true;
>> }
>> };
>>
>> controller.setProtocolChainInstanceHandler(instanceHandler);
>>
>> protocolChain.addFilter(new MimoXMLReadFilter(true));
>>
>> DefaultPipeline pipeLine = new DefaultPipeline(3,2
>> "pipeline", port, 3);
>> pipeLine.setInitialByteBufferSize(8192);
>> controller.setPipeline(pipeLine);
>>
>> new Thread(controller).start();
>>
>> } catch (Exception e) {
>> log.error("Error starting on port " + port, e);
>> }
>> --
>> View this message in context:
>> http://www.nabble.com/Why-so-many-threads--tp19392738p19392738.html
>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>
>
--
View this message in context: http://www.nabble.com/Why-so-many-threads--tp19392738p19405854.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.