From 94158ee54b270eb5667821ecf6feda5e472e4604 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 7 Feb 2024 10:46:41 +0000 Subject: [PATCH 1/2] Increase batching when fetching auth chains --- synapse/storage/databases/main/event_federation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py index 12e882062a0..846c3f363a5 100644 --- a/synapse/storage/databases/main/event_federation.py +++ b/synapse/storage/databases/main/event_federation.py @@ -310,7 +310,7 @@ def _get_auth_chain_ids_using_cover_index_txn( # Add all linked chains reachable from initial set of chains. chains_to_fetch = set(event_chains.keys()) while chains_to_fetch: - batch2 = tuple(itertools.islice(chains_to_fetch, 100)) + batch2 = tuple(itertools.islice(chains_to_fetch, 1000)) chains_to_fetch.difference_update(batch2) clause, args = make_in_list_sql_clause( txn.database_engine, "origin_chain_id", batch2 @@ -593,7 +593,7 @@ def fetch_chain_info(events_to_fetch: Collection[str]) -> None: # the loop) chains_to_fetch = set(seen_chains) while chains_to_fetch: - batch2 = tuple(itertools.islice(chains_to_fetch, 100)) + batch2 = tuple(itertools.islice(chains_to_fetch, 1000)) clause, args = make_in_list_sql_clause( txn.database_engine, "origin_chain_id", batch2 ) From d3efcb6d9c0221673b90ddb97ae7f4d3fb3023db Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 7 Feb 2024 10:48:31 +0000 Subject: [PATCH 2/2] Newsfile --- changelog.d/16893.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16893.bugfix diff --git a/changelog.d/16893.bugfix b/changelog.d/16893.bugfix new file mode 100644 index 00000000000..7222cd765c2 --- /dev/null +++ b/changelog.d/16893.bugfix @@ -0,0 +1 @@ +Fix performance regression when fetching auth chains from the DB. Introduced in v1.100.0.