mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Only calculate initial sync for 10 rooms at a time
This helps to ensure we don't completely starve other requests.
This commit is contained in:
parent
e557dc80b8
commit
8e49892b21
@ -18,7 +18,7 @@ from ._base import BaseHandler
|
|||||||
from synapse.streams.config import PaginationConfig
|
from synapse.streams.config import PaginationConfig
|
||||||
from synapse.api.constants import Membership, EventTypes
|
from synapse.api.constants import Membership, EventTypes
|
||||||
from synapse.util import unwrapFirstError
|
from synapse.util import unwrapFirstError
|
||||||
from synapse.util.logcontext import LoggingContext, PreserveLoggingContext
|
from synapse.util.logcontext import LoggingContext, PreserveLoggingContext, preserve_fn
|
||||||
from synapse.util.metrics import Measure
|
from synapse.util.metrics import Measure
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
@ -228,10 +228,14 @@ class SyncHandler(BaseHandler):
|
|||||||
invited = []
|
invited = []
|
||||||
archived = []
|
archived = []
|
||||||
deferreds = []
|
deferreds = []
|
||||||
for event in room_list:
|
|
||||||
|
room_list_chunks = [room_list[i:i + 10] for i in xrange(0, len(room_list), 10)]
|
||||||
|
for room_list_chunk in room_list_chunks:
|
||||||
|
for event in room_list_chunk:
|
||||||
if event.membership == Membership.JOIN:
|
if event.membership == Membership.JOIN:
|
||||||
with PreserveLoggingContext(LoggingContext.current_context()):
|
room_sync_deferred = preserve_fn(
|
||||||
room_sync_deferred = self.full_state_sync_for_joined_room(
|
self.full_state_sync_for_joined_room
|
||||||
|
)(
|
||||||
room_id=event.room_id,
|
room_id=event.room_id,
|
||||||
sync_config=sync_config,
|
sync_config=sync_config,
|
||||||
now_token=now_token,
|
now_token=now_token,
|
||||||
@ -252,8 +256,9 @@ class SyncHandler(BaseHandler):
|
|||||||
leave_token = now_token.copy_and_replace(
|
leave_token = now_token.copy_and_replace(
|
||||||
"room_key", "s%d" % (event.stream_ordering,)
|
"room_key", "s%d" % (event.stream_ordering,)
|
||||||
)
|
)
|
||||||
with PreserveLoggingContext(LoggingContext.current_context()):
|
room_sync_deferred = preserve_fn(
|
||||||
room_sync_deferred = self.full_state_sync_for_archived_room(
|
self.full_state_sync_for_archived_room
|
||||||
|
)(
|
||||||
sync_config=sync_config,
|
sync_config=sync_config,
|
||||||
room_id=event.room_id,
|
room_id=event.room_id,
|
||||||
leave_event_id=event.event_id,
|
leave_event_id=event.event_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user