diff --git a/changelog.d/18939.misc b/changelog.d/18939.misc new file mode 100644 index 000000000..6cfae2cea --- /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 cc389d158..2e9f62075 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) )