mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
707d5e4e48
Currently we use `JsonEncoder.iterencode` to write JSON responses, which ensures that we don't block the main reactor thread when encoding huge objects. The downside to this is that `iterencode` falls back to using a pure Python encoder that is *much* less efficient and can easily burn a lot of CPU for huge responses. To fix this, while still ensuring we don't block the reactor loop, we encode the JSON on a threadpool using the standard `JsonEncoder.encode` functions, which is backed by a C library. Doing so, however, requires `respond_with_json` to have access to the reactor, which it previously didn't. There are two ways of doing this: 1. threading through the reactor object, which is a bit fiddly as e.g. `DirectServeJsonResource` doesn't currently take a reactor, but is exposed to modules and so is a PITA to change; or 2. expose the reactor in `SynapseRequest`, which requires updating a bunch of servlet types. I went with the latter as that is just a mechanical change, and I think makes sense as a request already has a reactor associated with it (via its http channel). |
||
---|---|---|
.. | ||
caches | ||
__init__.py | ||
async_helpers.py | ||
batching_queue.py | ||
daemonize.py | ||
distributor.py | ||
file_consumer.py | ||
frozenutils.py | ||
hash.py | ||
httpresourcetree.py | ||
iterutils.py | ||
linked_list.py | ||
logcontext.py | ||
logformatter.py | ||
macaroons.py | ||
manhole.py | ||
metrics.py | ||
module_loader.py | ||
msisdn.py | ||
patch_inline_callbacks.py | ||
ratelimitutils.py | ||
retryutils.py | ||
rlimit.py | ||
stringutils.py | ||
templates.py | ||
threepids.py | ||
versionstring.py | ||
wheel_timer.py |