Yanzqing / brown-ros-pkg

Automatically exported from code.google.com/p/brown-ros-pkg
0 stars 0 forks source link

rosbridge 100% cpu usage #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start rosbridge
2. Open TCP socket connection to rosbridge and don't close it
3. rosbridge wil consume 100% cpu

What version of the product are you using? On what operating system?
Latest checkout on ubuntu 10.04

Please provide any additional information below.
I tried to debug it a little bit and managed to find a workaround, the problem 
and my solution are explained here: 
http://answers.ros.org/question/3766/rosbridge-cpu-usage

I attach the ws.py file with the changes I mentioned in ros answers 

Original issue reported on code.google.com by lopez1...@gmail.com on 2 Feb 2012 at 1:38

Attachments:

GoogleCodeExporter commented 9 years ago
Victor,

Thanks so much for the bug-fix and for cross-posting this to ROS answers. I've 
just incorporated this fix into our SVN version ( svn co 
https://brown-ros-pkg.googlecode.com/svn/trunk/experimental/rosbridge rosbridge 
) and it will be available in the Electric and Diamondback binaries as soon as 
Willow refreshes their distribution (the packages will be labeled 0.0.19).

What your fix basically does is make the loop sensitive to the HZ parameter. 
Since the default HZ in your version is so low (200Hz) CPU usage drops 
dramatically. However, at the moment most of our users are expecting 
performance to favor throughput. I've thus changed the default HZ to 100000 
(equivalent to 100 kHz) coincident with applying your fix. This will mean that 
if you want to cut down on CPU usage, you'll need to specify your own HZ as the 
default will do quite a bit of spinning.

One other thing I should mention is that the 100% usage is a bit misleading and 
you should always try to run rosbridge alongside your planned load. While 
select operations will dominate a CPU on an "empty" processor according to top, 
they are still blocking (as called in rosbridge) and present yield 
opportunities. The end result is that while rosbridge will take 100% of a CPU 
with no other load, it will not in general effect the performance of other 
applications very much (if at all). For example, when you run Gazebo (a 
CPU-bound process) on the same core, rosbridge will only take up ~1% of the 
proc according to top.

Thanks again for the patch!

_Trevor

Original comment by trevor...@gmail.com on 3 Feb 2012 at 8:10