-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Optimise queueing of inbound replication commands #7861
Conversation
When we get behind on replication, we tend to stack up background processes behind a linearizer. Bg processes are heavy (particularly with respect to prometheus metrics) and linearizers aren't terribly efficient once the queue gets long either. A better approach is to maintain a queue of requests to be processed, and nominate a single process to work its way through the queue. Fixes: #7444
(this is best reviewed with whitespace changes hidden) |
1bc4e93
to
1cc6c93
Compare
1cc6c93
to
a507496
Compare
... because stock `typing` doesn't have it in Python 3.5.
synapse/replication/tcp/handler.py
Outdated
stream_name: Deque[ | ||
Tuple[Union[RdataCommand, PositionCommand], AbstractConnection] | ||
]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, from PEP 484:
It is not recommended to use the subscripted class (e.g.
Node[int]
) directly in an expression -- using a type alias (e.g.IntNode = Node[int]
) instead is preferred. (First, creating the subscripted class, e.g.Node[int]
, has a runtime cost. Second, using a type alias is more readable.)
Since this is instantiating the type a few times, and the type is going across 3 lines, probably worth aliasing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great suggestion, thanks.
When we get behind on replication, we tend to stack up background processes behind a linearizer. Bg processes are heavy (particularly with respect to prometheus metrics) and linearizers aren't terribly efficient once the queue gets long either.
A better approach is to maintain a queue of requests to be processed, and nominate a single process to work its way through the queue.
Fixes: #7444