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

Avoid state_can_deliver call when SubOptions are not available causing Pub-sub performance improvement of 40 times #1313

Closed
wants to merge 1 commit into from

Conversation

janani4u
Copy link

@janani4u janani4u commented Sep 30, 2016

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/

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.002%) to 31.822% when pulling e8607bb on janani4u:master into 15ebb79 on processone:master.

@janani4u
Copy link
Author

janani4u commented Sep 30, 2016

I see that the code-coverage decreased by 0.002% and hence this check was unsuccessful.
Is this code-coverage based out of elixir test-cases?
The change is in the mod_pubsub code where elixir test-case for many use-cases do not exist.

Would this code still be reviewed?

I believe this change can be a significant performance booster and the community would benefit greatly.

@janani4u janani4u changed the title Avoid state_can_deliver call when SubOptions are not available Avoid state_can_deliver call when SubOptions are not available causing Pub-sub performance improvement of 40times Oct 3, 2016
@janani4u janani4u changed the title Avoid state_can_deliver call when SubOptions are not available causing Pub-sub performance improvement of 40times Avoid state_can_deliver call when SubOptions are not available causing Pub-sub performance improvement of 40 times Oct 3, 2016
@janani4u
Copy link
Author

janani4u commented Oct 11, 2016

@cromain @badlop Hi, I would like to know which ejabberd release can this fix be a part of?

@eswarantg
Copy link

@cromain @badlop We are looking forward to having this fix for our work. Do let know progress.

@cromain
Copy link
Contributor

cromain commented Apr 6, 2017

i need to review possible side effect on all possible cases

@cromain cromain modified the milestones: ejabberd 17.x, ejabberd 17.06 Apr 6, 2017
@cromain
Copy link
Contributor

cromain commented Jun 29, 2017

I applied a simple similar change. call to state_can_deliver does not cost when SubOpts=[] so I kept same structure of the loop to make it simpler to optimize later.

@cromain cromain closed this Jun 29, 2017
@lock
Copy link

lock bot commented Jun 9, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants