mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 08:36:03 -04:00
Fix performance of responding to user key requests over federation (#10221)
We were repeatedly looking up a config option in a loop (using the unclassed config style), which is expensive enough that it can cause large CPU usage.
This commit is contained in:
parent
182147195b
commit
a5cd05beee
3 changed files with 11 additions and 1 deletions
|
@ -62,6 +62,13 @@ class EndToEndKeyBackgroundStore(SQLBaseStore):
|
|||
|
||||
|
||||
class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore):
|
||||
def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"):
|
||||
super().__init__(database, db_conn, hs)
|
||||
|
||||
self._allow_device_name_lookup_over_federation = (
|
||||
self.hs.config.federation.allow_device_name_lookup_over_federation
|
||||
)
|
||||
|
||||
async def get_e2e_device_keys_for_federation_query(
|
||||
self, user_id: str
|
||||
) -> Tuple[int, List[JsonDict]]:
|
||||
|
@ -85,7 +92,7 @@ class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore):
|
|||
result["keys"] = keys
|
||||
|
||||
device_display_name = None
|
||||
if self.hs.config.allow_device_name_lookup_over_federation:
|
||||
if self._allow_device_name_lookup_over_federation:
|
||||
device_display_name = device.display_name
|
||||
if device_display_name:
|
||||
result["device_display_name"] = device_display_name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue