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

Gregory Szorc gregory.szorc at gmail.com
Sun Aug 14 17:36:03 EDT 2016


On Mon, Aug 8, 2016 at 6:45 AM, Yuya Nishihara <yuya at tcha.org> wrote:

> 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?
>

I can go both ways on this. However, I'm inclined to say "no" because
setting the compression level very high or disabling it could make a CPU or
network usage increase significantly. I think server operators would want
to retain control over this setting for that reason.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160814/6a9469b7/attachment.html>


More information about the Mercurial-devel mailing list