[patch] Optimize stanza cloning in case of broadcast_roles setting

46 views
Skip to first unread message

Damian Minkov

unread,
Nov 16, 2022, 3:43:14 PM11/16/22
to prosody-dev
While testing big conferences and observing and profiling prosody we noticed(thanks to Boris Grozev) that some presences are created and not sent to participants which drastically increased CPU usage for 2000 participants in a room. This is a case with a large room with mostly occupants with a role 'visitor'.

A possible fix in muc/muc.lib.lua:
342c342
< if filter == nil or filter(occupant_jid, occupant) then
---
> if (filter == nil or filter(occupant_jid, occupant)) and (to_bare == occupant.bare_jid or broadcast_roles[occupant.role or "none"]) then
349,351c349
< if to_bare == occupant.bare_jid or broadcast_roles[occupant.role or "none"] then
< self:route_stanza(pres);
< end
---
> self:route_stanza(pres);

We tested this change which reduced the CPU by more than 60% in that test case.

The following change was not tested but seems reasonable as unnecessary clones of stanzas are created.

307d306
< local pr = get_p(n_occupant);
309c308
< self:route_to_occupant(n_occupant, pr);
---
> self:route_to_occupant(n_occupant, get_p(n_occupant));
310a310
> local pr = get_p(n_occupant);

Thank you
damencho


Damian Minkov

unread,
Dec 30, 2022, 3:24:36 AM12/30/22
to prosody-dev
Hi again,

What do you think about this?

Regards
damencho

Damian Minkov

unread,
Feb 18, 2023, 12:32:18 PM2/18/23
to prosody-dev
Hi again,

What about this one, can this optimization be included in the next 0.12 release? 
We have been running it for a while on meet.jit.si

Thank you
damencho

Matthew Wild

unread,
Feb 21, 2023, 5:34:39 AM2/21/23
to proso...@googlegroups.com
On Sat, 18 Feb 2023 at 17:32, Damian Minkov <dame...@damencho.com> wrote:
> What about this one, can this optimization be included in the next 0.12 release?
> We have been running it for a while on meet.jit.si
> https://github.com/jitsi/infra-configuration/blob/061508f9a8736169d73e76b824e101de40d03da1/ansible/roles/prosody/files/muc_lib_visitor_broadcast.patch

Thanks for the patch. As the 0.12.3 release is already behind
schedule, I won't have time to review this patch for inclusion.
However I will work on getting it reviewed and merged soon after the
release.

Sorry for the wait!

Regards,
Matthew

Damian Minkov

unread,
Sep 6, 2023, 10:13:05 AM9/6/23
to proso...@googlegroups.com
Hey Matthew,

Did this manage to go into 0.12.4 as I don't see it?

Thanks
damencho


--
You received this message because you are subscribed to the Google Groups "prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prosody-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prosody-dev/CAJt9-x6qvNutWnvECZCKtQ5RFO90YwtN71mZF34%3D4je62qdVPA%40mail.gmail.com.

Damian Minkov

unread,
Nov 14, 2024, 5:08:47 PM11/14/24
to proso...@googlegroups.com
Bump :) 

Can you take a look?

Thanks

Matthew Wild

unread,
Nov 15, 2024, 9:39:50 AM11/15/24
to proso...@googlegroups.com
Hi Damien,

On Thu, 14 Nov 2024 at 22:08, 'Damian Minkov' via prosody-dev
<proso...@googlegroups.com> wrote:
>
> Bump :)
>
> Can you take a look?

Thanks for the nudge, and sorry it took a while. The patch is now
merged into 0.12 and trunk as
https://hg.prosody.im/trunk/rev/eedae7d47784 - it will be in the next
releases which are due "soon" :)

Regards,
Matthew
Reply all
Reply to author
Forward
0 new messages