From: Eric Wong Date: Sun, 9 Jun 2024 20:05:23 +0000 (+0000) Subject: gzip_filter: use zlib DEF_MEM_LEVEL for gzip X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4fedc5caff06583aa3fe81ce0c0bf8fdcffa4d9b;p=thirdparty%2Fpublic-inbox.git gzip_filter: use zlib DEF_MEM_LEVEL for gzip Compress::Raw::Zlib uses MAX_MEM_LEVEL by default which deviates fom the zlib default. Since the zlib default is good enough for git, nginx and varnish: it's good enough for our use. This change reduces maximum zlib memory use by 1/3. There's also a new note explaining why gzip happens in Perl instead of varnish || nginx. --- diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm index 8b630f251..a2e82a2d3 100644 --- a/lib/PublicInbox/GzipFilter.pm +++ b/lib/PublicInbox/GzipFilter.pm @@ -11,6 +11,8 @@ # async_eml callbacks only run when a blob arrives from git. # # We continue to support getline+close for generic PSGI servers. +# Note: we favor gzip in Perl (as opposed to nginx || varnish) to +# reduce IPC memory traffic package PublicInbox::GzipFilter; use strict; use parent qw(Exporter); @@ -21,7 +23,9 @@ use PublicInbox::GitAsyncCat; use Carp qw(carp); our @EXPORT_OK = qw(gzf_maybe); -my %OPT = (-WindowBits => 15 + 16, -AppendOutput => 1); +# Compress::Raw::Zlib uses MAX_MEM_LEVEL (9) while zlib DEF_MEM_LEVEL is 8; +# choose the zlib default because C:R:Z is excessive. +my %OPT = (-WindowBits => 15 + 16, -AppendOutput => 1, -MemLevel => 8); my @GZIP_HDRS = qw(Vary Accept-Encoding Content-Encoding gzip); sub new { bless {}, shift } # qspawn filter