diff options
author | Eric Eastwood <erice@element.io> | 2022-01-19 18:00:03 -0600 |
---|---|---|
committer | Eric Eastwood <erice@element.io> | 2022-01-19 18:00:03 -0600 |
commit | e0b718622a8142fc591f5f839ecdafcee98070f2 (patch) | |
tree | 94e5f7f9750b44f64bd929b26f60ebd5347e1ec3 | |
parent | Cache event creation info and context (diff) | |
download | synapse-e0b718622a8142fc591f5f839ecdafcee98070f2.tar.xz |
We only have to store the state_group for events created by create_event first
This gets us down to the ~0.8s per 100 event batch times!
-rw-r--r-- | synapse/handlers/room_batch.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/synapse/handlers/room_batch.py b/synapse/handlers/room_batch.py index c9cb3377d9..cacc09e461 100644 --- a/synapse/handlers/room_batch.py +++ b/synapse/handlers/room_batch.py @@ -354,6 +354,16 @@ class RoomBatchHandler: event_type_creation_cache[event.type] = EventCreationCacheItem( event=event, context=context ) + + # Normally this is done when persisting the event but we have to + # pre-emptively do it here because we create all the events first, + # then persist them in another pass below. And we want to share + # state_groups across the whole batch so this lookup needs to work + # for the next event in the batch in this loop. + await self.store.store_state_group_id_for_event_id( + event_id=event.event_id, + state_group_id=context._state_group, + ) else: builder = self.event_builder_factory.for_room_version( room_version_obj, event_dict @@ -380,16 +390,6 @@ class RoomBatchHandler: # TODO: Can we get away without this? # self.validator.validate_new(event, self.config) - # Normally this is done when persisting the event but we have to - # pre-emptively do it here because we create all the events first, - # then persist them in another pass below. And we want to share - # state_groups across the whole batch so this lookup needs to work - # for the next event in the batch in this loop. - await self.store.store_state_group_id_for_event_id( - event_id=event.event_id, - state_group_id=context._state_group, - ) - logger.debug( "RoomBatchSendEventRestServlet inserting event=%s, prev_event_ids=%s, auth_event_ids=%s", event, |