zulip/zerver/tornado
Alex Vandiver 6427d85cf6 tornado: Replace dataclasses.asdict() call, as it is slow.
This code is called in the hot path when Tornado is processing events.
As such, making this code performant is important.  Profiling shows
that a significant portion of the time is spent calling asdict() to
serialize the UserMessageNotificationsData dataclass.  In this case
`asdict` does several steps which we do not need, such as attempting
to recurse into its fields, and deepcopy'ing the values of the fields.

In our use case, these add a notable amount of overhead:
```py3
from zerver.tornado.event_queue import UserMessageNotificationsData
from dataclasses import asdict
from timeit import timeit
o = UserMessageNotificationsData(1, False, False, False, False, False, False, False, False, False, False, False)
%timeit asdict(o)
%timeit {**vars(o)}
```

Replace the `asdict` call with a direct access of the fields.  We
perform a shallow copy because we do need to modify the resulting
fields.
2023-02-23 11:01:38 -08:00
..
__init__.py
application.py tornado: Construct Django BaseHandler once, not per-request. 2022-09-30 11:20:45 -07:00
descriptors.py tornado: Support sharding by user ID. 2022-11-15 17:27:01 -08:00
django_api.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
event_queue.py tornado: Replace dataclasses.asdict() call, as it is slow. 2023-02-23 11:01:38 -08:00
exceptions.py exceptions: Update error message for BAD_EVENT_QUEUE_ID. 2022-11-30 17:16:12 -08:00
handlers.py ruff: Fix SIM105 Use `contextlib.suppress` instead of try-except-pass. 2023-01-23 11:18:36 -08:00
ioloop_logging.py tornado: Remove instrument_tornado_ioloop. 2022-05-02 17:41:49 -07:00
sharding.py tornado: Support sharding by user ID. 2022-11-15 17:27:01 -08:00
views.py tornado: Move internal tornado redirect to under /internal/. 2023-01-09 18:23:58 -05:00