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

Minor perf fixes to get_auth_chain_ids #6954

Closed
Closed
Show file tree
Hide file tree
Changes from 2 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/6954.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Minor perf fixes to `get_auth_chain_ids`.
6 changes: 3 additions & 3 deletions synapse/storage/data_stores/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ def _get_auth_chain_ids_txn(self, txn, event_ids, include_given):
while front:
new_front = set()
front_list = list(front)
chunks = [front_list[x : x + 100] for x in range(0, len(front), 100)]
chunks = (front_list[x : x + 100] for x in range(0, len(front), 100))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

batch_iter is a thing which I think is optimal here?

for chunk in chunks:
clause, args = make_in_list_sql_clause(
txn.database_engine, "event_id", chunk
)
txn.execute(base_sql + clause, list(args))
new_front.update([r[0] for r in txn])
txn.execute(base_sql + clause, args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're relying on make_in_list_sql_clause returning a list, we should probably update its type annotation to say that's what it does?

new_front.update(r[0] for r in txn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past I've used flake8-comprehensions to find unnecessary comprehensions like this.


new_front -= results

Expand Down