duypq94 / kryonet

Automatically exported from code.google.com/p/kryonet
0 stars 0 forks source link

Server.update() consumes 100% CPU resources #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have noticed that kryonet server is consuming too much CPU time. 

When my app is running on my local Tomcat in Windows environment everything is 
working fine. But after being deployed to a production server which is Debian 
based it starts to load CPU at 100% even with few users connected. I can see in 
profiler that kryonet thread called "Server" consumes almost 100% CPU time with 
executing Server.update() method. 

I have found that a lot of NIO-based network libraries had a similar issue due 
broken NIO Selector implementation on Linux. But I use the latest jdk in wich I 
suppose this bug should be already fixed.

So is any workarounds to avoid such high CPU load?

Server environment:

uname -a:
Linux 2.6.32.46-xenU #1 SMP Thu Oct 27 23:15:48 UTC 2011 i686 GNU/Linux

java -version:
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)

Original issue reported on code.google.com by KingSqua...@gmail.com on 10 Mar 2012 at 3:44

Attachments:

GoogleCodeExporter commented 8 years ago
The latest code in SVN should remedy this problem. I don't know why NIO returns 
immediately from a select without any channels selected. We now sleep for a 
short time when this occurs to avoid 100% CPU.

Original comment by nathan.s...@gmail.com on 26 Apr 2012 at 3:01