From 9ed0d36fe240ce3daaba65bc3d1cbf51c4dac172 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Tue, 23 Sep 2025 15:47:29 +0100 Subject: [PATCH] Bump batch size from 50 to 1000 for `_get_e2e_cross_signing_signatures_for_devices` query (#18939) Co-authored-by: Eric Eastwood --- changelog.d/18939.misc | 1 + synapse/storage/databases/main/end_to_end_keys.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog.d/18939.misc diff --git a/changelog.d/18939.misc b/changelog.d/18939.misc new file mode 100644 index 0000000000..6cfae2ceaf --- /dev/null +++ b/changelog.d/18939.misc @@ -0,0 +1 @@ +Reduce overall number of calls to `_get_e2e_cross_signing_signatures_for_devices` by increasing the batch size of devices the query is called with, reducing DB load. diff --git a/synapse/storage/databases/main/end_to_end_keys.py b/synapse/storage/databases/main/end_to_end_keys.py index cc389d1582..2e9f62075a 100644 --- a/synapse/storage/databases/main/end_to_end_keys.py +++ b/synapse/storage/databases/main/end_to_end_keys.py @@ -354,7 +354,10 @@ class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore, CacheInvalidationWorker if d is not None and d.keys is not None ) - for batch in batch_iter(signature_query, 50): + # 1000 is an arbitrary batch size. It helped performance on a very + # large-scale deployment (matrix.org), but has not been tested against + # any other setup. + for batch in batch_iter(signature_query, 1000): cross_sigs_result = ( await self._get_e2e_cross_signing_signatures_for_devices(batch) )