-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protocol delay_between_messages hindering server performance #203
Comments
This prevents performance problems when multiple clients are subscribing to high frequency topics. Fixes RobotWebTools#203
Should consider, for the 2016 distro, deprecating that undocumented "message_intervall" key since it seems to be completely superceded by throttle/queue opts. |
Good catch! I agree we should get rid of "message_intervall", though. Maybe we should replace it with something like Also, as long as `delay_between_messages`` is still there, it should be available as a ROS parameter. It is for the TCP version of rosbridge, but nowhere else. I'll make a PR to fix that :) |
The Protocol is sleeping for a (default) 10ms after sending each message from the graph to its outgoing method. This is causing a very severe performance problem.
Affecting code looks like this:
rosbridge_suite/rosbridge_library/src/rosbridge_library/protocol.py
Lines 247 to 248 in d7138dc
I'm working on a distributed rosbridge app with at least five client connections at the same time, subscribing to some of the same topics, across different hosts. I tried adding a two-line monkeypatch to
rosbridge_websocket.py
, the gist of it was:This sets the default
delay_between_messages
to zero for new instances of Protocol. I verified this was being applied with some debug logging in the websocket handler.The performance boost was tremendous. I removed all throtte/queue from client code and it ran silky smooth. I compared this with the default behavior (sleep 10ms after every outgoing) and it showed the signs I'd come to expect from rosbridge under even a small amount of load: messages backing up and slowing down the websocket stream.
The server did use twice as much CPU, but only went from 25-50% aggregate across all threads. I still expect Tornado to bog down under extreme load, but have yet to hit its limit since the native masking speedups were added to rosbridge_server.
With
delay_between_messages
completely bypassed, the experience of using robridge changes from "I'd better throttle and queue every single topic" to "let 'er rip".Why is this happening? I haven't read all of the code, but can prepose that the effect of this delay is multiplied by the number of clients, since a message on one topic (in its own rospy subscription Thread) potentially causes the sleep once per client per message.
There is an undocumented Protocol parameter "message_intervall" that allows for setting
delay_between_messages
per-Protocol instance. This is not implemented in roslibjs.rosbridge_suite/rosbridge_library/src/rosbridge_library/protocol.py
Lines 181 to 182 in d7138dc
I'd like to default
delay_between_messages
to zero, unless there is a compelling case not to. Selective throttling and queuing works great when you need it. The only effects ofdelay_between_messages > 0
are backlogged, late messages that never get dropped from a queue and a Tornado IOLoop that is sitting around bored while this is happening.The text was updated successfully, but these errors were encountered: