Avoid state_can_deliver call when SubOptions are not available causing Pub-sub performance improvement of 40 times #1313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For our use-case of a large pub-sub node containing about 1 lakh subscribers, a publish item call was taking more than 2 minutes(measured using Tsung).
In our use-case, the pub-sub subscribers are added by the node-owner himself through manage subscriptions and users are not allowed to manage their own subscription.
Hence SubOptions were never used.
Using eprof and other profiling tools, we were able to narrow the problem area to the method lists_member/2 that gets called by subscribed_nodes_by_jid method.
Through further analysis on the ejabberd code, we were able to see a solution where for our use-case of pubsub-owner managed subscriptions, call to state_can_deliver method seemed unnecessary.
This would help avoid the subsequent loop processing and call to the fateful lists_member method, thereby giving a performance boost in the order of 40 times.
For the same use-case, the average time taken went down from 2 minutes to about 3 seconds(Testing done using Tsung).
Please read more on this fix in this post below:-
https://techenthusiast4u.wordpress.com/2016/10/04/ejabberd_pubsub_performance_improvement/