Project

General

Profile

Speed up MUC startup time

Igor Khomenko
Added about 4 years ago

Hi there,

we have realised that MUC takes long time to startup if there are a lot of rooms, for example > 100K

We found that there are 2 for cycles at startup which can produce delays

1st is in MucDAO.getRoomsJIDList and 2nd is in InMemoryMucRepository constructor.

MucDAO:

    public ArrayList<BareJID> getRoomsJIDList() throws RepositoryException {
        ArrayList<BareJID> jids = new ArrayList<BareJID>();
        BareJID serviceName = mucConfig.getServiceName();
        try {
            String[] ids = repository.getSubnodes(serviceName, ROOMS_KEY);
            if (ids != null) {
                for (String id : ids) {
                    jids.add(BareJID.bareJIDInstance(id));
                }
            }
            return jids;
        } catch (Exception e) {
            e.printStackTrace();
            throw new RepositoryException("Room list reading error", e);
        }
    }

InMemoryMucRepository:

        ArrayList<BareJID> roomJids = dao.getRoomsJIDList();
        if (roomJids != null) {
            for (BareJID jid : roomJids) {
                this.allRooms.put(jid, new InternalRoom());
            }
        }

Will it be better to replace with something like this?

MucDAO:

    public String[] getRoomsJIDList() throws RepositoryException {
        BareJID serviceName = mucConfig.getServiceName();
        try {
            String[] ids = repository.getSubnodes(serviceName, ROOMS_KEY);
            return ids;
        } catch (Exception e) {
            e.printStackTrace();
            throw new RepositoryException("Room list reading error", e);
        }
    }

InMemoryMucRepository:

        String[] roomJids = dao.getRoomsJIDList();
        if (roomJids != null) {
            for (String jid : roomJids) {
                try {
                    this.allRooms.put(BareJID.bareJIDInstance(jid), new InternalRoom());
                } catch (TigaseStringprepException e) {
                    e.printStackTrace();
                }
            }
        }

so we can remove one for cycle

Does it make sense?


Replies (1)

(1)
Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 4 years ago

Created a ticket: #2861

thank you for reporting.

    (1-1/1)