Skip to content
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

MQTTAsync_send cpu load increases a lot while buffering messages #495

Open
tbultel opened this issue May 27, 2024 · 2 comments
Open

MQTTAsync_send cpu load increases a lot while buffering messages #495

tbultel opened this issue May 27, 2024 · 2 comments
Labels
upstream Problem with upstream library

Comments

@tbultel
Copy link

tbultel commented May 27, 2024

Hi, I am currently using v1.3.1 with paho.mqtt.c submodule

In my test case, I have got a single async_client that pushes messages to the broker.
The configuration is no persistence, and the client can keep 180000 messages upon connection lost.

a) When the connection is fine, the MQTTAsync_sender thread takes 2 to 4 % of one CPU.
b) When the connection to the broker is lost, then the thread quickly jumps to up to 48% of CPU load
c) When the connection comes back, MQTTAsync_sender goes back to 2% , but seems to not deliver messages
as fast as before (checked with push and deliver counters), slowly enough to not reach the speed I need.

d) Finally, it is worth to notice that pushing is asynchronous indeed, but takes a significant amount of CPU load of the caller,
making is hard to use in realtime contexts (I had to add an intermediate queue so solve this)

The most annoying thing are points b) and c), I am currently trying to understand what is possibly wrong in the implementation.
Does anyone have faced it ?

@tbultel
Copy link
Author

tbultel commented May 27, 2024

I found the reason in the lib.
This is due to the implementation of MQTTAsync_processCommand

Namely, when disconnected, the command queue keeps growing and the while(..) loop iterates through it all the time.
After some thousands of queued messages, the time spent becomes significant.

@fpagliughi
Copy link
Contributor

Is this something that should be reported to the upstream Paho C library?

@fpagliughi fpagliughi added the upstream Problem with upstream library label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Problem with upstream library
Projects
None yet
Development

No branches or pull requests

2 participants