From 2afe30189267532baadd95023d7cb84b8bab23e5 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 19 Aug 2020 07:40:07 -0400 Subject: [PATCH] Expand comment. --- synapse/http/server.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/synapse/http/server.py b/synapse/http/server.py index 872ffbc6c4fa..8d791bd2ca4f 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -544,9 +544,11 @@ def resumeProducing(self) -> None: while not self._paused: # Get the next chunk and write it to the request. # - # The output of the JSON encoder is coalesced until min_chunk_size is - # reached. (This is because JSON encoders produce a very small output - # per iteration.) + # The output of the JSON encoder is buffered and coalesced until + # min_chunk_size is reached. This is because JSON encoders produce + # very small output per iteration and the Request object converts + # each call to write() to a separate chunk. Without this there would + # be an explosion in bytes written (e.g. b"{" becoming "1\r\n{\r\n"). # # Note that buffer stores a list of bytes (instead of appending to # bytes) to hopefully avoid many allocations.