]> Sergey Matveev's repositories - public-inbox.git/commitdiff
qspawn: workaround Perl 5.16.3 leak, re-enable Deflater
authorEric Wong <e@80x24.org>
Fri, 27 Sep 2019 21:01:01 +0000 (21:01 +0000)
committerEric Wong <e@80x24.org>
Fri, 27 Sep 2019 21:04:48 +0000 (21:04 +0000)
The httpd-supplied write callback is the leak culprit under Perl
5.16.3.  undef-ing it immediately after use keeps a repeated
"git fetch" loop from monotonically increasing memory and FD use
on the Perl shipped with RHEL/CentOS 7.x.

Other endpoints tested showed no increase in memory use under
constant load with "ab -HAccept-Encoding:gzip -k", including the
async psgi_qx code path used by $INBOX_URL/$OBJECT_ID/s/ via
SolverGit module.

lib/PublicInbox/Qspawn.pm
script/public-inbox-httpd

index 5a300644fe3df0b3ad49d5d22b904eef77e89385..cb3dc516304d74e70467c8ba0aac43e8d0004c66 100644 (file)
@@ -281,6 +281,10 @@ sub psgi_return {
                                                                $buf, $filter);
                        $wcb->($r);
                }
+
+               # Workaround a leak under Perl 5.16.3 when combined with
+               # Plack::Middleware::Deflater:
+               $wcb = undef;
        };
        $limiter ||= $def_limiter ||= PublicInbox::Qspawn::Limiter->new(32);
        my $start_cb = sub { # may run later, much later...
index 9b869f906032ed8e090f60d3c92ca62792ab47de..b2464f4efc0d31be9909c872c3969353e33768c6 100755 (executable)
@@ -24,13 +24,7 @@ my $refresh = sub {
                my $www = PublicInbox::WWW->new;
                $www->preload;
                $app = builder {
-                       # Perl 5.16.3 leaks in our "push" response code path
-                       # (e.g. Qspawn) due to something in
-                       # Plack::Util::response_cb, regardless of whether the
-                       # client is sending Accept-Encoding:gzip requests.
-                       # perl5180delta documents many leak fixes, so assume
-                       # 5.18+ is safe for now and bump the check as-need:
-                       $] >= 5.018000 and eval {
+                       eval {
                                enable 'Deflater',
                                        content_type => [ qw(
                                                text/html