Skip to content
This repository has been 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

Closed
@erikjohnston

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.

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

# 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

Assignees

No one assigned

    Labels

    T-EnhancementNew features, changes in functionality, improvements in performance, or user-facing enhancements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions