-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
MQTT maximum throughput #161
Comments
Hello,
|
I had quite interesting speed improvement when I reduce the timeout for select from 10ms to 1ms here. |
It does wait for data to become available, @squonk11 Smooth/lib/smooth/core/Task.cpp Line 164 in c874fed
|
yes, I agree, but in case there is a message, then only the message is being processed and tick() is not being called (if I interpret the code correctly). |
Correct - but tick() isn't meant to handle events (i.e. incoming messages). Tick is meant to do things that are not triggered by an event. The Task impl. attempts to ensure that the tick is called on the desired interval. Smooth/lib/smooth/core/Task.cpp Line 148 in c874fed
|
ah, o.k. I understand. |
@Elfelsoufim : The link in your post seems to point to a wrong location?
|
Hello, thank you both for your timely support. @squonk11 I have tried all the solutions you have suggested both in this issue and in #142, without success, unfortunately. My transmission rate seems to be fixed at around 12 messages per second. I ran a few tests to benchmark Smooth MQTT. I put my results and my conclusion in this short document: The tests and documentation are rather informal, but I believe they illustrate my main point: Smooth's MQTT can be optimized further 😄. |
Serious investigation :) Yes, I'm sure there are ways to optimize it. I have a faint memory of the parsing of incoming messages being a bottleneck, iirc it was read a byte at a time to determine the message size etc. I don't remember if I optimized that part or not. so that may be a starting point. |
Hello, I have tested ESP-IDF's MQTT library using very similar code & conditions to the TCP/IP benchmark I have done previously to give us a useful comparison with Smooth MQTT. Here is the documentation: The result is an average of 640 messages sent per second. I am only a student so it is not something I could do myself, but this would be a nice result to achieve with Smooth MQTT. |
Hello,
For my application, I need to send messages from an ESP32 to my main computer (which hosts a mosquitto broker) at a minimum rate of 1000 messages per second. However, when I tested Smooth MQTT throughput using the example found in
Smooth/test/mqtt
, I get the following result:Transmission Rate:
That, however, is not the expected behaviour, since:
For troubleshooting, I have tried several solutions. Notably:
To detect the source of the problem, I tried timing several methods such as publish(), publish_next() and send_packet(). All of these take at most a few milliseconds to execute.
I also tried timing the loop inside exec(). Here I found that it sometimes takes up to 150 ms to execute the loop. Knowing that, I tried circumventing exec() by not calling start() (start() calls exec()). I did this by calling init() and then send_message() repeatedly. Please see the code provided below.
After trying this fix, the throughput did not improve at all, which leads me to think that send_message() (which really is just publish()) is guilty of this issue. But considering that publish() takes only a few milliseconds to put the data in the transmit buffer, and after having read this #142, I conclude that there must be a problem with how messages are being sent.
What I really want to ask here is:
For reference, here is the environment I used:
git describe --tags
to find it): v4.2.1xtensa-esp32-elf-gcc --version
to find it): (crosstool-NG esp-2020r3) 8.4.0Here is the code I used to test MQTT: GIST
The text was updated successfully, but these errors were encountered: