-
Notifications
You must be signed in to change notification settings - Fork 198
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
Added presence update on change of profile information and config flags for selective presence tracking #16992
base: develop
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
28e1f2f
to
c893e5a
Compare
I fixed the linter issues I was experiencing and also added some documentation for the config flags. Open to feedback to see if these PR changes would be of interest for merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed PR description! This looks good on the whole, though I have some quibbles about the wording.
* `federation_presence_tracking` (Default enabled): Determines if the server will accept | ||
presence EDUs that only contain presence activity updates. If disabled, the server will drop | ||
processing EDUs that do not contain updates to the `status_msg`, `displayname`, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this a bit confusing, as the name of this option implies that "presence" equates to only the online/offline/etc. state of the user, and not the transport which carries activity and profile updates. Whereas if you set presence.enabled: false
, then both activity and profile updates are ignored.
Could you clarify the difference in your description of these options?
* `sync_presence_tracking` (Default enabled): Determines if the server tracks a user's presence | ||
activity when syncing. If disabled, the server will not automatically update the user's presence | ||
activity when the sync endpoint is called. Note that client applications can still update their | ||
presence by calling the respective presence endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that Synapse will also count a user as "online" if they call /events
:
synapse/synapse/handlers/events.py
Lines 54 to 80 in b548f78
async def get_stream( | |
self, | |
requester: Requester, | |
pagin_config: PaginationConfig, | |
timeout: int = 0, | |
as_client_event: bool = True, | |
affect_presence: bool = True, | |
room_id: Optional[str] = None, | |
) -> JsonDict: | |
"""Fetches the events stream for a given user.""" | |
if room_id: | |
blocked = await self.store.is_room_blocked(room_id) | |
if blocked: | |
raise SynapseError(403, "This room has been blocked on this server") | |
# send any outstanding server notices to the user. | |
await self._server_notices_sender.on_user_syncing(requester.user.to_string()) | |
presence_handler = self.hs.get_presence_handler() | |
context = await presence_handler.user_syncing( | |
requester.user.to_string(), | |
requester.device_id, | |
affect_presence=affect_presence, | |
presence_state=PresenceState.ONLINE, | |
) |
This option would disable that as well. Perhaps instead of "sync_presence_tracking", you could just call this option "client_presence_tracking"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use the terms local_activity_tracking
and remote_activity_tracking
for these presence config options since the previous paragraph in the docs used similar language:
Presence tracking allows users to see the state (e.g online/offline)
of other local and remote users. ...
I also like client_presence_tracking
though, and if you don't prefer the new names I used, I don't mind changing it to client_presence_tracking
and federation_client_presence_tracking
respectively.
# Process only profile presence updates to reduce resource impact | ||
if "status_msg" in e or "displayname" in e or "avatar_url" in e: | ||
filtered_edus.append(e) | ||
content["push"] = filtered_edus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a docstring to on_edu
mentioning that it potentially modifies the passed content
dictionary?
Looking at the calling functions, this isn't a problem. But it's good to call out for future reference.
Thanks for the feedback! I've applied the suggestions. Feel free to resolve the remaining conversations if the changes are satisfactory. |
…17231) This is to address an issue in which `m.presence` results on initial sync are not returning entries of users who are currently offline. The original behaviour was from #1535 This change is useful for applications that use the presence system for tracking user profile information/updates (e.g. #16992 or for profile status messages). This is gated behind a new configuration option to avoid performance impact for applications that don't need this, as a pragmatic solution for now.
…gs for selective presence tracking Signed-off-by: Michael Hollister <michael@futo.org>
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
9716d53
to
2428eb8
Compare
This PR address two issues:
m.presence
update on change of profile information (displayname
andavatar_url
) per stated in the spec: https://spec.matrix.org/v1.9/client-server-api/#events-on-change-of-profile-informationpresence
is enabled:a.
sync_presence_tracking
(Default enabled): Determines if the server tracks a user's presence activity when syncing. If disabled, the server will not automatically update the user's presence activity when the sync endpoint is called.b.
federation_presence_tracking
(Default enabled): Determines if the server will accept presence EDUs that only contain presence activity updates. If disabled, the server will drop processing EDUs that do not contain updates to thestatus_msg
,displayname
, andavatar_url
fields.Note that if
sync_presence_tracking
and/orfederation_presence_tracking
is disabled, client applications an still call the/presence/{userId}/status
endpoints to update the user's presence.The motivation for adding the config options is to improve server performance when applications are using presence to track user profile updates, but not user activity status. Combining this along with MSC4069 for disabling profile
m.room.member
event propagation results in more efficient profile update process for client applications to use.Below are some graphs from loadtests that show performance improvements when
sync_presence_tracking
andfederation_presence_tracking
are disabled. The setup is that of 500 users distributed among 2 federated servers in which users only call the/sync
endpoint (no room updates or messages being sent during the test).With current default behavior (
presence
,sync_presence_tracking
, andfederation_presence_tracking
are enabled)Server 1: (workers enabled, 1 master worker and 1 presence writer)
Server 2: (workers disabled)
We see that there are CPU usage spikes of up to 50% when processing presence events. When disabling
sync_presence_tracking
andfederation_presence_tracking
, we eliminate CPU usage spikes when processing presence updates from user's sync activity:Server 1: (workers enabled, 1 master worker and 1 presence writer)
Server 2: (workers disabled)
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)