Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presence logic for handling newly joined rooms is very inefficient and does duplicate work #8956

Open
matrixbot opened this issue Dec 18, 2023 · 0 comments

Comments

@matrixbot
Copy link
Collaborator

matrixbot commented Dec 18, 2023

This issue has been migrated from #8956.


When a user joins a room Synapse needs to decide what presence updates to send out. For local users joining a room we need to send a presence update to all users in the room, for remote users joining we need to send out all local users presence to the remote user.

This is implemented by streaming the current state delta stream, however when the server joins a federated room for the first time the state delta will include join events for all members. This leads to a situation where we correctly process the fact that a local user has joined a room and send out presence updates, and then incorrectly process each remote join event as if they're a new user join, leading to a lot of unnecessary work and superfluous presence events being generated and sent over federation.

https://github.com/matrix-org/synapse/blob/6d02eb22dfde9551c515acaf73503e2500e00eaf/synapse/handlers/presence.py#L860-L953

On top of that, we should also only send presence updates when this is the first time a remote server shares a room with the local user.

@matrixbot matrixbot changed the title Dummy issue Presence logic for handling newly joined rooms is very inefficient and does duplicate work Dec 21, 2023
@matrixbot matrixbot reopened this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant