Mercurial > public > mercurial-scm > hg
diff mercurial/wireprotov2server.py @ 40138:b5bf3dd6ec5b
wireprotov2: send content encoded frames from server
Now that we have support for negotiating encodings and configuring
an encoder, we can start sending content encoded frames from the
server.
This commit teaches the wireprotov2 server code to send content
encoded frames.
On the mozilla-unified repository with zstd enabled peers, this change
reduces the total amount of data transferred from server to client
drastically:
befor: 7,190,995,812 bytes
after: 1,605,508,691 bytes
Differential Revision: https://phab.mercurial-scm.org/D4927
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 08 Oct 2018 17:24:28 -0700 |
parents | 762ef19a07e3 |
children | 30f70d11c224 |
line wrap: on
line diff
--- a/mercurial/wireprotov2server.py Mon Oct 08 15:19:32 2018 -0700 +++ b/mercurial/wireprotov2server.py Mon Oct 08 17:24:28 2018 -0700 @@ -194,7 +194,7 @@ reactor = wireprotoframing.serverreactor(ui, deferoutput=True) seencommand = False - outstream = reactor.makeoutputstream() + outstream = None while True: frame = wireprotoframing.readframe(req.bodyfh) @@ -207,6 +207,11 @@ # Need more data before we can do anything. continue elif action == 'runcommand': + # Defer creating output stream because we need to wait for + # protocol settings frames so proper encoding can be applied. + if not outstream: + outstream = reactor.makeoutputstream() + sentoutput = _httpv2runcommand(ui, repo, req, res, authedperm, reqcommand, reactor, outstream, meta, issubsequent=seencommand)