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-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 802191FBF4 for ; Wed, 10 Jun 2020 07:05:23 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 23/82] git: async: flatten the inflight array Date: Wed, 10 Jun 2020 07:04:20 +0000 Message-Id: <20200610070519.18252-24-e@yhbt.net> In-Reply-To: <20200610070519.18252-1-e@yhbt.net> References: <20200610070519.18252-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Small array refs have considerable overhead in Perl, so reduce AV/SV overhead and instead allow the inflight array to grow twice as large. --- lib/PublicInbox/Git.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 8426cc7d6a7..e1d5c386e7e 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -18,7 +18,7 @@ use base qw(Exporter); our @EXPORT_OK = qw(git_unquote git_quote); use constant MAX_INFLIGHT => - ($^O eq 'linux' ? 4096 : POSIX::_POSIX_PIPE_BUF()) + (($^O eq 'linux' ? 4096 : POSIX::_POSIX_PIPE_BUF()) * 2) / 65; # SHA-256 hex size + "\n" in preparation for git using non-SHA1 @@ -135,8 +135,8 @@ sub read_cat_in_full ($$) { sub _cat_async_step ($$) { my ($self, $inflight) = @_; - my $pair = shift @$inflight or die 'BUG: inflight empty'; - my ($cb, $arg) = @$pair; + die 'BUG: inflight empty or odd' if scalar(@$inflight) < 2; + my ($cb, $arg) = splice(@$inflight, 0, 2); local $/ = "\n"; my $head = readline($self->{in}); $head =~ / missing$/ and return @@ -314,7 +314,7 @@ sub cat_async ($$$;$) { } print { $self->{out} } $oid, "\n" or fail($self, "write error: $!"); - push(@$inflight, [ $cb, $arg ]); + push(@$inflight, $cb, $arg); } sub extract_cmt_time {