From 6eb1bf7feb8508f513a89e0df232481ba479f5eb Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Thu, 7 Apr 2022 12:41:40 +0100 Subject: Try using orjson for deserialisation replication messages --- synapse/replication/tcp/commands.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'synapse') diff --git a/synapse/replication/tcp/commands.py b/synapse/replication/tcp/commands.py index 3654f6c03c..d47841c07c 100644 --- a/synapse/replication/tcp/commands.py +++ b/synapse/replication/tcp/commands.py @@ -20,8 +20,10 @@ import abc import logging from typing import Optional, Tuple, Type, TypeVar +import orjson + from synapse.replication.tcp.streams._base import StreamRow -from synapse.util import json_decoder, json_encoder +from synapse.util import json_encoder logger = logging.getLogger(__name__) @@ -130,7 +132,7 @@ class RdataCommand(Command): stream_name, instance_name, None if token == "batch" else int(token), - json_decoder.decode(row_json), + orjson.loads(row_json), ) def to_line(self) -> str: @@ -370,7 +372,7 @@ class UserIpCommand(Command): def from_line(cls: Type["UserIpCommand"], line: str) -> "UserIpCommand": user_id, jsn = line.split(" ", 1) - access_token, ip, user_agent, device_id, last_seen = json_decoder.decode(jsn) + access_token, ip, user_agent, device_id, last_seen = orjson.loads(jsn) return cls(user_id, access_token, ip, user_agent, device_id, last_seen) -- cgit 1.5.1