android, desktop: fix lag when closing support chat in large groups#7061
Open
Narasimha-sc wants to merge 1 commit into
Open
android, desktop: fix lag when closing support chat in large groups#7061Narasimha-sc wants to merge 1 commit into
Narasimha-sc wants to merge 1 commit into
Conversation
Narasimha-sc
added a commit
that referenced
this pull request
Jun 9, 2026
In groups and channels with thousands of members, opening any screen that shows the member list could briefly freeze the app. The most noticeable case was the "Chats with members" screen: closing a member's chat and returning to the list reloaded everyone and stuttered each time. The app was re-checking every member against every other member while loading the list - work that grows with the square of the group size, so it got dramatically slower as groups grew. It now does this in a single pass, so member lists, @-mentions, channel relays and adding members all stay responsive even in very large groups. You see exactly the same members, in the same order - just without the lag.
361bf94 to
a58e707
Compare
|
Can I be your student so you can teach me on how to use this github for other purposes.. |
Collaborator
Author
I recommend joining some groups of your interest in SimpleX Directory: https://simplex.chat/directory and ask your questions there :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In groups and channels with thousands of members, opening any screen that shows the member list could briefly freeze the app. The most noticeable case was the Chats with members screen: closing a member's chat and returning to the list reloaded everyone and stuttered each time.
The app was re-checking every member against every other member while loading the list — work that grows with the square of the group size, so it got dramatically slower as groups grew. It now does this in a single pass, so member lists, @-mentions, channel relays and adding members all stay responsive even in very large groups. You see exactly the same members, in the same order — just without the lag.
Technical detail
setGroupMembersis the shared in-memory member loader. After fetching members it merged them with the connection stats already in memory usingcurrentMembers.find { it.id == newMember.id }inside.map {}— an O(n) scan inside an O(n) map, i.e. O(n²).GroupMember.idis a computed property ("#$groupId @$groupMemberId") that allocates a freshStringon every access, so this was also on the order of n² string allocations plus the resulting GC pressure.This indexes the current members by id once (
associateBy { it.id }) and looks them up in O(1) — same result set, no behavioral change (member ids are unique within a group), just O(n).Rationale and verification:
plans/2026-06-09-perf-group-members-merge-on2.md.