mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Skip filtering during push if there are no push actions (#13992)
This commit is contained in:
parent
285d72556b
commit
535f8c8f7d
1
changelog.d/13992.misc
Normal file
1
changelog.d/13992.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Speed up calculating push actions in large rooms.
|
@ -332,6 +332,11 @@ class BulkPushRuleEvaluator:
|
|||||||
# Push rules say we should notify the user of this event
|
# Push rules say we should notify the user of this event
|
||||||
actions_by_user[uid] = actions
|
actions_by_user[uid] = actions
|
||||||
|
|
||||||
|
# If there aren't any actions then we can skip the rest of the
|
||||||
|
# processing.
|
||||||
|
if not actions_by_user:
|
||||||
|
return
|
||||||
|
|
||||||
# This is a check for the case where user joins a room without being
|
# This is a check for the case where user joins a room without being
|
||||||
# allowed to see history, and then the server receives a delayed event
|
# allowed to see history, and then the server receives a delayed event
|
||||||
# from before the user joined, which they should not be pushed for
|
# from before the user joined, which they should not be pushed for
|
||||||
|
@ -162,6 +162,10 @@ async def filter_event_for_clients_with_state(
|
|||||||
if event.internal_metadata.is_soft_failed():
|
if event.internal_metadata.is_soft_failed():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# Fast path if we don't have any user IDs to check.
|
||||||
|
if not user_ids:
|
||||||
|
return ()
|
||||||
|
|
||||||
# Make a set for all user IDs that haven't been filtered out by a check.
|
# Make a set for all user IDs that haven't been filtered out by a check.
|
||||||
allowed_user_ids = set(user_ids)
|
allowed_user_ids = set(user_ids)
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ class RoomsCreateTestCase(RoomBase):
|
|||||||
self.assertEqual(HTTPStatus.OK, channel.code, channel.result)
|
self.assertEqual(HTTPStatus.OK, channel.code, channel.result)
|
||||||
self.assertTrue("room_id" in channel.json_body)
|
self.assertTrue("room_id" in channel.json_body)
|
||||||
assert channel.resource_usage is not None
|
assert channel.resource_usage is not None
|
||||||
self.assertEqual(35, channel.resource_usage.db_txn_count)
|
self.assertEqual(34, channel.resource_usage.db_txn_count)
|
||||||
|
|
||||||
def test_post_room_initial_state(self) -> None:
|
def test_post_room_initial_state(self) -> None:
|
||||||
# POST with initial_state config key, expect new room id
|
# POST with initial_state config key, expect new room id
|
||||||
@ -723,7 +723,7 @@ class RoomsCreateTestCase(RoomBase):
|
|||||||
self.assertEqual(HTTPStatus.OK, channel.code, channel.result)
|
self.assertEqual(HTTPStatus.OK, channel.code, channel.result)
|
||||||
self.assertTrue("room_id" in channel.json_body)
|
self.assertTrue("room_id" in channel.json_body)
|
||||||
assert channel.resource_usage is not None
|
assert channel.resource_usage is not None
|
||||||
self.assertEqual(38, channel.resource_usage.db_txn_count)
|
self.assertEqual(37, channel.resource_usage.db_txn_count)
|
||||||
|
|
||||||
def test_post_room_visibility_key(self) -> None:
|
def test_post_room_visibility_key(self) -> None:
|
||||||
# POST with visibility config key, expect new room id
|
# POST with visibility config key, expect new room id
|
||||||
|
Loading…
Reference in New Issue
Block a user