paho.mqtt.c
paho.mqtt.c copied to clipboard
MQTTAsync_subscribe slows down after time
Describe the bug After subscribing/unsubscribing to many topics, all subsequent subscribe calls seem to take almost exactly 100ms to call back.
We found that in a previous version (1.3.1), this callback tended to take a few ms to return, and with an upgrade to 1.3.10 (no other changes), the callback time has jumped noticeably.
To Reproduce
- Subscribe to 300 topics (this is not an exact number, probably triggered with a lower number)
- Unsubscribe from those same topics
- Attempt another subscription, notice that it takes almost exactly 100ms for the onSuccess callback to return
Expected behavior The previous speedy behaviour of subscription :-)
Log files I've attached a trace. The slow subscriptions began at ~2022-08-02 16:53:31 in the timezone of the trace, and the last active use of the library before that (doing unsubscriptions) finished at ~2022-08-02 16:53:06.
Environment (please complete the following information): Paho 1.3.10 Redhat Enterprise 8, x86_64
Additional context This doesn't seem to actually be a problem for our application in reality - we only noticed it through some soak testing taking a bit longer. However, it might indicate some underlying leak or other more severe problem in the Paho library. Happy to help.
I have put some performance changes into the develop branch, if you want to try those out.
I have put some performance changes into the develop branch, if you want to try those out.
I'm probably looking in the wrong place, because I can't find any recent commits on 'develop'. Was this an old commit (a while before now, but after the 1.3.10 tagging) , and could you link it? Cheers.
It's from May (56c6151e9bf088f498dce8a375386fc1852ceb06). I was referring to the updates added to the develop branch since 1.3.10 in March.
But there are several timing changes in the develop branch - I would just try the develop branch as it stands rather than trying to cherry-pick any particular commits.