]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
gzip_filter: use zlib DEF_MEM_LEVEL for gzip
authorEric Wong <e@80x24.org>
Sun, 9 Jun 2024 20:05:23 +0000 (20:05 +0000)
committerEric Wong <e@80x24.org>
Mon, 10 Jun 2024 06:45:06 +0000 (06:45 +0000)
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.

lib/PublicInbox/GzipFilter.pm

index 8b630f251af5dac0e0b72f4007a1043ef9b6b62a..a2e82a2d374257408f315addb11c6a203d5fa334 100644 (file)
@@ -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