rosbridge_suite
rosbridge_suite copied to clipboard
fix: Reduce idle CPU consumption of websocket server
Public API Changes None
Description
This PR removes the use of tornado.ioloop and instead uses the asyncio event loop interface, as recommended in tornado documentation since version 6.0.
The ROS spinning is now done in a separate thread instead of a periodic async callback.
SIGINT and SIGTERM signal handling is now done manually to ensure graceful shutdown.
In my case, the idle CPU consumption went from 9% to 0%. With a client connected, the consumption went from 38% to 34%.
This is still quite high but a good step forward. I tried improving it further by using EventsExecutor and the consumption with the client connected went from 34% to 18% which is huge but I'm reluctant to use it as it is experimental.