[PATCH] hgweb: config option to control zlib compression level

Yuya Nishihara yuya at tcha.org
Mon Aug 8 09:45:29 EDT 2016


On Sun, 07 Aug 2016 18:12:37 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1470618598 25200
> #      Sun Aug 07 18:09:58 2016 -0700
> # Node ID d5e9dedbc7f912ff2dc2e92586347250aee11ac2
> # Parent  3ef9aa7ad1fc4c43b92d48e4bb1f4e3de68b6910
> hgweb: config option to control zlib compression level
> 
> Before this patch, the HTTP transport protocol would always zlib
> compress certain responses (notably "getbundle" wire protocol commands)
> at zlib compression level 6.
> 
> zlib can be a massive CPU resource sink for servers. Some server
> operators may wish to reduce server-side CPU requirements while
> requiring more bandwidth. This is common on corporate intranets, for
> example. Others may wish to use more CPU but reduce bandwidth.
> 
> This patch introduces a config option to allow server operators
> to control the zlib compression level.

Sounds good, queued, thanks.

> --- a/mercurial/hgweb/protocol.py
> +++ b/mercurial/hgweb/protocol.py
> @@ -69,17 +69,17 @@ class webproto(wireproto.abstractserverp
>      def redirect(self):
>          self.oldio = self.ui.fout, self.ui.ferr
>          self.ui.ferr = self.ui.fout = stringio()
>      def restore(self):
>          val = self.ui.fout.getvalue()
>          self.ui.ferr, self.ui.fout = self.oldio
>          return val
>      def groupchunks(self, cg):
> -        z = zlib.compressobj()
> +        z = zlib.compressobj(self.ui.configint('server', 'zliblevel', -1))

Any idea if untrusted hgrc should be allowed?


More information about the Mercurial-devel mailing list