Erlang/OTP Forums

Author Message

<  Ejabberd mailing list  ~  ejabberd mod_muc bottleneck

Guest
Posted: Fri Jun 18, 2010 9:42 pm Reply with quote
Guest
Hi,
cstar
Posted: Sun Jun 20, 2010 4:22 pm Reply with quote
Joined: 05 Jan 2009 Posts: 4
Hi Karthik,
Several notes :
View user's profile Send private message
Guest
Posted: Tue Jun 22, 2010 7:34 pm Reply with quote
Guest
Hi Eric,
cstar
Posted: Tue Jun 22, 2010 7:46 pm Reply with quote
Joined: 05 Jan 2009 Posts: 4
Le 22 juin 2010
View user's profile Send private message
Guest
Posted: Thu Jul 01, 2010 2:41 am Reply with quote
Guest
I've been doing more load testing, this is what I've learned.


The bottlenecking in mod_muc is not actually a flaw in the mod_muc process itself, I was wrong to assume that, and the fprof analysis was misleading because fprof itself slowed the system down so much.
Guest
Posted: Thu Jul 01, 2010 3:55 am Reply with quote
Guest
01.07.2010 12:40, Karthik Kailash wrote:
> *Finally I found the source of ejabberd_router:route's occasional extreme
> slowness is a single mnesia call in ejabberd_sm:do_route.* The line is:
> mnesia:dirty_index_read(session, USR, #session.usr). Sampling using
> timer:tc every few thousand messages, I found that 80-90% of the time, this
> call is fast (< 100 us), but the remaining 10-20% it takes tens of ms to
> complete. This is exactly the same as the ejabberd_router:route behavior.
>
> So I'm pretty certain I've narrowed the bottleneck problem down to this
> line. However, the session table is in RAM and there is an index on the usr
> field, so I can't figure out why this problem is happening!
>
> Any thoughts or ideas?

Hello, Karthik. First of all, your investigation is interesting Smile
However, I cannot reproduce the issue. This is how I reproduce it:
1) Connect with 2 clients and join to some muc conference.
2) Start eprof on the room pid.
3) Route messages from one of the connected users to the room in erlang
shell:
> lists:foreach(fun(_) -> ejabberd_router:route(jlib:make_jid("user",
"domain.com", "resource"), jlib:make_jid("room",
"conference.domain.com", ""), {xmlelement, "message", [{"type",
"groupchat"}], [{xmlelement, "body", [], [{xmlcdata, "a"}]}]}) end,
lists:seq(1, 1000)).
4) Analyze eprof data.

According to your report, there should be
mod_muc_room:process_groupchat_message (and maybe some mnesia functions)
in the top of eprof output, but I don't see this.
On the other hand, according to your symptoms and looking into mnesia
sources I've found that dirty functions call to mnesia:do_dirty_rpc/5
function, which calls rpc:call, here is a snippet:
do_dirty_rpc(Tab, Node, M, F, Args) ->
case rpc:call(Node, M, F, Args) of
{badrpc, Reason} ->
timer:sleep(20), %% Do not be too eager, and can't use yield on SMP
...
do_dirty_rpc(Tab, NewNode, M, F, Args)

This might be a problem in your case. Try to add debug output there to
check if you don't get {badrpc, Reason} in this function.

--
Regards,
Evgeniy Khramtsov, ProcessOne.
xmpp:xram@jabber.ru.

_______________________________________________
ejabberd mailing list
ejabberd@jabber.ru
http://lists.jabber.ru/mailman/listinfo/ejabberd
Post received from mailinglist
Guest
Posted: Thu Jul 01, 2010 6:28 am Reply with quote
Guest
Hi Evgeniy,

Quote:
Hello, Karthik. First of all, your investigation is interesting Smile However, I cannot reproduce the issue. This is how I reproduce it:


Thanks!
Guest
Posted: Thu Jul 01, 2010 6:37 am Reply with quote
Guest
01.07.2010 16:27, Karthik Kailash wrote:
> Also I'm using the ejabberd 2.1.4 source, are you using the same?

Yes, more or less Wink

> I'd be happy to share my Tsung script and my modified ejabberd source
> files.

That would be great. If the problem is not in do_dirty_rpc/5, then just
post the script here, so I can borrow it and try in spare time.

--
Regards,
Evgeniy Khramtsov, ProcessOne.
xmpp:xram@jabber.ru.

_______________________________________________
ejabberd mailing list
ejabberd@jabber.ru
http://lists.jabber.ru/mailman/listinfo/ejabberd
Post received from mailinglist
Guest
Posted: Thu Jul 01, 2010 6:49 am Reply with quote
Guest
Ejabberd 2.1.4 comes with mnesia 4.4.5, but Erlang R13B03 has mnesia 4.4.12.
Guest
Posted: Thu Jul 01, 2010 6:55 am Reply with quote
Guest
01.07.2010 16:49, Karthik Kailash wrote:
> Ejabberd 2.1.4 comes with mnesia 4.4.5,

What do you mean? Ejabberd doesn't rely on mnesia version and doesn't
have mnesia sources. Or do you use binary installer?

> but Erlang R13B03 has mnesia 4.4.12.
> Is there a difference to use one or the other?

No idea.

--
Regards,
Evgeniy Khramtsov, ProcessOne.
xmpp:xram@jabber.ru.

_______________________________________________
ejabberd mailing list
ejabberd@jabber.ru
http://lists.jabber.ru/mailman/listinfo/ejabberd
Post received from mailinglist
Guest
Posted: Thu Jul 01, 2010 7:03 am Reply with quote
Guest
On Wed, Jun 30, 2010 at 11:54 PM, Evgeniy Khramtsov <xramtsov@gmail.com (xramtsov@gmail.com)> wrote:
Quote:
01.07.2010 16:49, Karthik Kailash wrote:
Quote:
Ejabberd 2.1.4 comes with mnesia 4.4.5,


What do you mean? Ejabberd doesn't rely on mnesia version and doesn't have mnesia sources. Or do you use binary installer?


I used the binary installer.
Guest
Posted: Thu Jul 01, 2010 8:46 pm Reply with quote
Guest
On Wed, Jun 30, 2010 at 11:36 PM, Evgeniy Khramtsov
Guest
Posted: Wed Jul 07, 2010 4:15 am Reply with quote
Guest
I uploaded the ejabberd log file with all of the timing sample statements here: http://www.mediafire.com/file/ztzlmmekhmh/ejabberd.log
Guest
Posted: Wed Jul 07, 2010 4:26 am Reply with quote
Guest
Here’s the Tsung configuration file.
Guest
Posted: Wed Jul 07, 2010 4:35 am Reply with quote
Guest
07.07.2010 14:14, Karthik Kailash wrote:
> I uploaded the ejabberd log file with all of the timing sample statements
> here: http://www.mediafire.com/file/ztzlmmekhmh/ejabberd.log
>
>
>
> I wrote a simple script to extract and print out all of the sample times:
> http://www.mediafire.com/file/duwhyyjdjom/times.sh
>
>
>
> Here are all the ejabberd files I've modified to add the timing samples:
>
> http://www.mediafire.com/file/jmjtyng3mga/mod_muc.erl
>
> http://www.mediafire.com/file/zmhzttzkuyy/mod_muc_room.erl
>
> http://www.mediafire.com/file/wwtywhymnqk/ejabberd_router.erl
>
> http://www.mediafire.com/file/ixjondnqw2i/ejabberd_local.erl
>
> http://www.mediafire.com/file/ywzmwgaoymz/ejabberd_sm.erl
>
>
>
> Here are the modified mnesia files with timing samples:
>
> http://www.mediafire.com/file/urr4onn1ugn/mnesia.erl
>
> http://www.mediafire.com/file/ywzmwgaoymz/ejabberd_sm.erl
>
>

I'm unable to download those files: "Your user identity is invalid,
please login or use a supported browser to save files."

> I'm going to try compiling ejabberd with HiPE and see if that changes
> anything. I'll also try running ejabberd (normal and HiPE) on Erlang R14A.
>
>

ejabberd is not compiled on R14A yet.

--
Regards,
Evgeniy Khramtsov, ProcessOne.
xmpp:xram@jabber.ru.

_______________________________________________
ejabberd mailing list
ejabberd@jabber.ru
http://lists.jabber.ru/mailman/listinfo/ejabberd
Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 2
Goto page 1, 2  Next
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum