matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.83k stars 2.13k forks source link

Remove manys calls to cursor_to_dict #16431

Closed clokep closed 1 year ago

clokep commented 1 year ago

Instead of calling cursor_to_dict and then immediately unpacking the dict / changing the form to something else we should just use the raw tuples returned from the cursor.

A smoke test of this reduced my sync (for a rather small account on my test server) from 2757 allocations to 1861. Reducing the total allocated memory by _wait_for_sync_from_user from 217.2 KiB to 146.7 KiB.

clokep commented 1 year ago

(Also I secretly hate cursor_to_dict because it just hides types.)

DMRobertson commented 1 year ago

Err I'm a bit scared about https://github.com/matrix-org/synapse/pull/16431#discussion_r1347366268 actually

clokep commented 1 year ago

Are there any other uses of cursor_to_dict? Should we mark it as deprecated?

Yes, I plan to poke at more.