Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use store.get_users_in_room rather than state handler in typing for speed #7856

Merged
merged 4 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7856.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Small performance improvement in typing processing.
4 changes: 2 additions & 2 deletions synapse/handlers/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _push_update(self, member, typing):

async def _push_remote(self, member, typing):
try:
users = await self.state.get_current_users_in_room(member.room_id)
users = await self.store.get_users_in_room(member.room_id)
self._member_last_federation_poke[member] = self.clock.time_msec()

now = self.clock.time_msec()
Expand Down Expand Up @@ -224,7 +224,7 @@ async def _recv_edu(self, origin, content):
)
return

users = await self.state.get_current_users_in_room(room_id)
users = await self.store.get_users_in_room(room_id)
domains = {get_domain_from_id(u) for u in users}

if self.server_name in domains:
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ def get_joined_hosts_for_room(room_id):

self.datastore.get_joined_hosts_for_room = get_joined_hosts_for_room

def get_current_users_in_room(room_id):
def get_users_in_room(room_id):
return defer.succeed({str(u) for u in self.room_members})

hs.get_state_handler().get_current_users_in_room = get_current_users_in_room
self.datastore.get_users_in_room = get_users_in_room

self.datastore.get_user_directory_stream_pos.return_value = (
# we deliberately return a non-None stream pos to avoid doing an initial_spam
Expand Down