diff options
author | Michael Kaye <1917473+michaelkaye@users.noreply.github.com> | 2019-10-24 18:08:45 +0100 |
---|---|---|
committer | Michael Kaye <1917473+michaelkaye@users.noreply.github.com> | 2019-10-24 18:08:45 +0100 |
commit | f85b9842f07aad66daf09d5ac6d943b430513434 (patch) | |
tree | f8c9f863daf1510ba6c485160138a0415cf38a9a | |
parent | Merge pull request #6248 from matrix-org/erikj/move_schema_files (diff) | |
download | synapse-f85b9842f07aad66daf09d5ac6d943b430513434.tar.xz |
Don't encode object as UTF-8 string if not needed.
I believe that string formatting ~10-15 sized events will take a proportion of CPU time.
-rw-r--r-- | synapse/crypto/event_signing.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/crypto/event_signing.py b/synapse/crypto/event_signing.py index 694fb2c816..ccaa8a9920 100644 --- a/synapse/crypto/event_signing.py +++ b/synapse/crypto/event_signing.py @@ -125,9 +125,11 @@ def compute_event_signature(event_dict, signature_name, signing_key): redact_json = prune_event_dict(event_dict) redact_json.pop("age_ts", None) redact_json.pop("unsigned", None) - logger.debug("Signing event: %s", encode_canonical_json(redact_json)) + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Signing event: %s", encode_canonical_json(redact_json)) redact_json = sign_json(redact_json, signature_name, signing_key) - logger.debug("Signed event: %s", encode_canonical_json(redact_json)) + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Signed event: %s", encode_canonical_json(redact_json)) return redact_json["signatures"] |