paho.mqtt.c
paho.mqtt.c copied to clipboard
Saw-tooth latencies due to poll system call in paho.mqtt.c v1.3.10
Describe the bug
Starting with paho.mqtt.c v1.3.10, I'm seeing saw-tooth latencies measured by our ROS-MQTT-Interface mqtt_client. Our mqtt_client is using paho.mqtt.cpp to send arbitrary ROS messages via MQTT to a second instance of the mqtt_client. I am filing an issue here, since this behavior wasn't present with paho.mqtt.c v1.3.9.
From the release notes of v1.3.10:
A significant internal change is to use the poll system call instead of select to monitor sockets. Most people should notice no difference, except that poll does not exist on Windows XP as select does. You can use the USE_SELECT compile definition to switch back to use select for those platforms that don't have poll.
I have successfully verified that the issue is in fact due to the above mentioned change. If I build paho.mqtt.c with -DPAHO_USE_SELECT=ON
, the issue is gone.
Unfortunately, my knowledge of poll
vs. select
is close to none. Could you please help to identify whether this might be a bug in paho.mqtt.c, or expected behavior, or rather a bug on our side in how we are using the paho.mqtt.cpp?
To Reproduce
Please see https://github.com/ika-rwth-aachen/mqtt_client/issues/2 for easy steps to reproduce. Note that a ROS Noetic installation is required.
Expected behavior
No saw-tooth latencies, pretty consistent latencies.
Screenshots
Environment:
- OS: Linux Ubuntu
- Version 20.04
- Docker container with ROS Noetic installed
I put some changes into the develop branch that may address this, if you'd like to try them.
I started to try to reproduce to see if my changes would fix it, but I don't know where to get the ros-noetic-mqtt-client package from.
Thank you very much, I will try this out as soon as possible!
If ROS is installed, the package can simply be installed via sudo apt install ros-noetic-mqtt-client
.
I tried that command, but I presume I'd need to add some extra sources as it didn't find the package.
Thanks, I just tried it out with the most recent changes on develop and -DPAHO_USE_SELECT=OFF
.
Looks like the saw-tooth pattern is gone.
The behavior is now equivalent to v1.3.9 or v1.3.10 with -DPAHO_USE_SELECT=ON
.
Are the changes going to be part of a new release v1.3.11? Can you already estimate when that is going to happen?
Great, thanks for trying it out. I'll think about the next release but as this is pretty important sometime in August seems a good idea.
Perfect, thanks a lot for your help. Looking forward to the release!