-
Notifications
You must be signed in to change notification settings - Fork 205
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
Improve perf of sync device lists #17191
Conversation
It's almost always more efficient to query the rooms that have device list changes, rather than looking at the list of all users whose devices have changed and then look for shared rooms.
8201e3b
to
ca001e8
Compare
@@ -1475,7 +1462,7 @@ async def get_device_list_changes_in_rooms( | |||
|
|||
sql = """ | |||
SELECT DISTINCT user_id FROM device_lists_changes_in_room | |||
WHERE {clause} AND stream_id >= ? | |||
WHERE {clause} AND stream_id > ? |
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.
This is actually a bug that we didn't catch as we didn't test this code path much. I don't think its much of a problem, we'll just keep sending down the same device list repeatedly until the stream ID increments.
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.
Good catch!
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.
Looks plausible, and nice to see the reduction in code size as well.
Hopefully at least some tests cover this code path...
@@ -1475,7 +1462,7 @@ async def get_device_list_changes_in_rooms( | |||
|
|||
sql = """ | |||
SELECT DISTINCT user_id FROM device_lists_changes_in_room | |||
WHERE {clause} AND stream_id >= ? | |||
WHERE {clause} AND stream_id > ? |
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.
Good catch!
Yeah, we do have quite a few tests for device lists, which should now all test this code path (rather than the other one...) |
This reverts commit 0b91ccc.
It's almost always more efficient to query the rooms that have device list changes, rather than looking at the list of all users whose devices have changed and then look for shared rooms.
Re-introduces element-hq#17191, and includes element-hq#17197 and element-hq#17214 The basic idea is to stop calling `get_rooms_for_user` everywhere, and instead use the table `device_lists_changes_in_room`. Commits reviewable one-by-one.
It's almost always more efficient to query the rooms that have device list changes, rather than looking at the list of all users whose devices have changed and then look for shared rooms.