Closed clokep closed 1 year ago
(Aside: I was slightly surprised these classes aren't defined with attrs or stdlib dataclasses, which would make it easier to turn on
__slots__
.)
Due to the NAME
class var I was having trouble getting that to work and decided it wasn't worth my effort figuring out how to make those compatible.
Seems reasonable. I guess this only helps a lot if we have a huge queue of replication commands to work through?
It should help just in general with allocating less memory.
I'm hoping this will slim down our replication needs very very slightly, but it is also minimal effort.
WIth this change we have the following, sizes are done using
_get_size_of
._SimpleCommand
subclassRdataCommand
PositionCommand
UserSyncCommand
ClearUserSyncsCommand
FederationAckCommand
UserIpCommand
LockReleasedCommand
Code to produce the above
```python from synapse.util.caches.lrucache import _get_size_of from synapse.replication.tcp.commands import * def do(inst): print(f"{inst.__class__.__name__}: {_get_size_of(inst)}") do(ServerCommand("")) do(RdataCommand("", "", None, ())) do(PositionCommand("", "", 0, 1)) do(UserSyncCommand("", "", None, True, 1)) do(ClearUserSyncsCommand("")) do(FederationAckCommand("", 1)) do(UserIpCommand("", "", 1, "", None, 1)) do(LockReleasedCommand("", "", "")) ```