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