-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Batch up storing state groups when creating new room #14918
Changes from 1 commit
a47ee14
8f4282c
b9bef42
4f991a0
eba04f5
bc0ccd1
7ec7b9a
c4646cb
4f6f50f
1f752ff
8634ba6
467a731
3d564ef
5811fd9
d92b3a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,13 +457,14 @@ def insert_deltas_group_txn( | |
) | ||
|
||
sg_before = prev_group | ||
for index, (event, context) in enumerate(events_and_context): | ||
state_group_iter = iter(state_groups) | ||
for event, context in events_and_context: | ||
if not event.is_state(): | ||
context.state_group_after_event = sg_before | ||
context.state_group_before_event = sg_before | ||
pass | ||
continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hahaha, I did not notice that |
||
|
||
sg_after = state_groups[index] | ||
sg_after = next(state_group_iter) | ||
context.state_group_after_event = sg_after | ||
context.state_group_before_event = sg_before | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These context don't have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do set the prev group immediately after this function returns and the UnpersistedEventContext is turned into an EventContext (in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, OK. |
||
context.state_delta_due_to_event = { | ||
|
@@ -478,6 +479,7 @@ def insert_deltas_group_txn( | |
values=[ | ||
(context.state_group_after_event, room_id, event.event_id) | ||
for event, context in events_and_context | ||
H-Shay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if event.is_state() | ||
], | ||
) | ||
|
||
|
@@ -490,32 +492,27 @@ def insert_deltas_group_txn( | |
context.state_group_after_event, | ||
context.state_group_before_event, | ||
) | ||
for _, context in events_and_context | ||
for event, context in events_and_context | ||
if event.is_state() | ||
], | ||
) | ||
|
||
values = [] | ||
for _, context in events_and_context: | ||
assert context.state_delta_due_to_event is not None | ||
for ( | ||
key, | ||
state_id, | ||
) in context.state_delta_due_to_event.items(): | ||
values.append( | ||
( | ||
context.state_group_after_event, | ||
room_id, | ||
key[0], | ||
key[1], | ||
state_id, | ||
) | ||
) | ||
|
||
self.db_pool.simple_insert_many_txn( | ||
txn, | ||
table="state_groups_state", | ||
keys=("state_group", "room_id", "type", "state_key", "event_id"), | ||
values=values, | ||
values=[ | ||
( | ||
context.state_group_after_event, | ||
room_id, | ||
key[0], | ||
key[1], | ||
state_id, | ||
) | ||
for event, context in events_and_context | ||
if context.state_delta_due_to_event is not None | ||
for key, state_id in context.state_delta_due_to_event.items() | ||
], | ||
) | ||
return events_and_context | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.