From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B5D1F1F466 for ; Thu, 26 Sep 2019 01:50:38 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] ds: workaround a memory leak in Perl 5.16.x Date: Thu, 26 Sep 2019 01:50:37 +0000 Message-Id: <20190926015038.29770-2-e@80x24.org> In-Reply-To: <20190926015038.29770-1-e@80x24.org> References: <20190926015038.29770-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The perl-5.16.3-294.el7_6 RPM package on RHEL/CentOS 7 is affected by a memory leak in Perl when calling `ref' on blessed references. This resulted in a very slow leak that manifests more quickly with a nonstop "git fetch" loop. Use Scalar::Util::blessed to work around the issue. Tested overnight on a CentOS 7 VM. cf. https://rt.perl.org/Public/Bug/Display.html?id=114340 --- lib/PublicInbox/DS.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 30a9641..7f7cb85 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -24,6 +24,7 @@ use parent qw(Exporter); our @EXPORT_OK = qw(now msg_more); use warnings; use 5.010_001; +use Scalar::Util qw(blessed); use PublicInbox::Syscall qw(:epoll); use PublicInbox::Tmpfile; @@ -178,10 +179,12 @@ sub next_tick () { my $q = $nextq; $nextq = []; for (@$q) { - if (ref($_) eq 'CODE') { - $_->(); - } else { + # we avoid "ref" on blessed refs to workaround a Perl 5.16.3 leak: + # https://rt.perl.org/Public/Bug/Display.html?id=114340 + if (blessed($_)) { $_->event_step; + } else { + $_->(); } } } -- EW