This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Use new device_lists_changes_in_room
table for fetching device lists in /sync
#12388
Copy link
Copy link
Closed
Closed
Copy link
Labels
T-EnhancementNew features, changes in functionality, improvements in performance, or user-facing enhancements.New features, changes in functionality, improvements in performance, or user-facing enhancements.
Description
We added a table that tracks device list changes in a room in #12321. We can use this in /sync
(and /keys/changes
) to more efficiently calculate the device list changes without having to calculate the full set of users who share a room with the requester.
c.f.
synapse/synapse/handlers/sync.py
Lines 1313 to 1329 in 573cd0f
users_who_share_room = ( | |
await self.store.get_users_who_share_room_with_user(user_id) | |
) | |
# Always tell the user about their own devices. We check as the user | |
# ID is almost certainly already included (unless they're not in any | |
# rooms) and taking a copy of the set is relatively expensive. | |
if user_id not in users_who_share_room: | |
users_who_share_room = set(users_who_share_room) | |
users_who_share_room.add(user_id) | |
tracked_users = users_who_share_room | |
users_that_have_changed = ( | |
await self.store.get_users_whose_devices_changed( | |
since_token.device_list_key, tracked_users | |
) | |
) |
and
synapse/synapse/handlers/device.py
Lines 139 to 143 in 573cd0f
# First we check if any devices have changed for users that we share | |
# rooms with. | |
users_who_share_room = await self.store.get_users_who_share_room_with_user( | |
user_id | |
) |
The tricky thing is that since the table has been added recently we need to a) only use it once our minimum schema is 69
and b) only for device list stream IDs that have happened after a.
Metadata
Metadata
Assignees
Labels
T-EnhancementNew features, changes in functionality, improvements in performance, or user-facing enhancements.New features, changes in functionality, improvements in performance, or user-facing enhancements.