mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 12:43:50 +01: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
1
changelog.d/10221.bugfix
Normal file
1
changelog.d/10221.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix performance regression in responding to user key requests over federation. Introduced in v1.34.0rc1.
|
|
@ -11,6 +11,7 @@ from synapse.config import (
|
||||||
database,
|
database,
|
||||||
emailconfig,
|
emailconfig,
|
||||||
experimental,
|
experimental,
|
||||||
|
federation,
|
||||||
groups,
|
groups,
|
||||||
jwt,
|
jwt,
|
||||||
key,
|
key,
|
||||||
|
@ -87,6 +88,7 @@ class RootConfig:
|
||||||
tracer: tracer.TracerConfig
|
tracer: tracer.TracerConfig
|
||||||
redis: redis.RedisConfig
|
redis: redis.RedisConfig
|
||||||
modules: modules.ModulesConfig
|
modules: modules.ModulesConfig
|
||||||
|
federation: federation.FederationConfig
|
||||||
|
|
||||||
config_classes: List = ...
|
config_classes: List = ...
|
||||||
def __init__(self) -> None: ...
|
def __init__(self) -> None: ...
|
||||||
|
|
|
@ -62,6 +62,13 @@ class EndToEndKeyBackgroundStore(SQLBaseStore):
|
||||||
|
|
||||||
|
|
||||||
class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore):
|
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(
|
async def get_e2e_device_keys_for_federation_query(
|
||||||
self, user_id: str
|
self, user_id: str
|
||||||
) -> Tuple[int, List[JsonDict]]:
|
) -> Tuple[int, List[JsonDict]]:
|
||||||
|
@ -85,7 +92,7 @@ class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore):
|
||||||
result["keys"] = keys
|
result["keys"] = keys
|
||||||
|
|
||||||
device_display_name = None
|
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
|
device_display_name = device.display_name
|
||||||
if device_display_name:
|
if device_display_name:
|
||||||
result["device_display_name"] = device_display_name
|
result["device_display_name"] = device_display_name
|
||||||
|
|
Loading…
Reference in a new issue