-my %OUT_OPT = (
- # nnrpd (INN) and Compress::Raw::Zlib favor MemLevel=9,
- # but the zlib C library and git use MemLevel=8
- # as the default. Using 8 drops our memory use with 10K
- # TLS clients from 1.8 GB to 1.2 GB, but...
- # FIXME: sometimes clients fail with 8, so we use 9
- # -MemLevel => 9,
-
- # needs more testing, nothing obviously different in terms of memory
- -Bufsize => 65536,
+# global deflate context and buffer
+my $zbuf = \(my $buf = '');
+my $zout;
+{
+ my $err;
+ ($zout, $err) = Compress::Raw::Zlib::Deflate->new(
+ # nnrpd (INN) and Compress::Raw::Zlib favor MemLevel=9,
+ # the zlib C library and git use MemLevel=8 as the default
+ # -MemLevel => 9,
+ -Bufsize => 65536, # same as nnrpd
+ -WindowBits => -15, # RFC 1951
+ -AppendOutput => 1,
+ );
+ $err == Z_OK or die "Failed to initialize zlib deflate stream: $err";
+}