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,AWL,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 258A41FD50 for ; Fri, 10 Jan 2020 09:14:20 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/5] git: ->modified uses cat_async Date: Fri, 10 Jan 2020 09:14:17 +0000 Message-Id: <20200110091419.12340-4-e@yhbt.net> In-Reply-To: <20200110091419.12340-1-e@yhbt.net> References: <20200110091419.12340-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While v1 inboxes are typically only a single branch, coderepos will have many branches and being able to pipeline requests to "git cat-file --batch" can help us mask seek times. --- lib/PublicInbox/Git.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 2aaf1866..9d0f660b 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -339,6 +339,15 @@ sub commit_title ($$) { ($$buf =~ /\r?\n\r?\n([^\r\n]+)\r?\n?/)[0] } +sub extract_cmt_time { + my ($bref, undef, undef, undef, $modified) = @_; + + if ($$bref =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm) { + my $cmt_time = $1 + 0; + $$modified = $cmt_time if $cmt_time > $$modified; + } +} + # returns the modified time of a git repo, same as the "modified" field # of a grokmirror manifest sub modified ($) { @@ -346,14 +355,13 @@ sub modified ($) { my $modified = 0; my $fh = popen($self, qw(rev-parse --branches)); defined $fh or return $modified; + cat_async_begin($self); local $/ = "\n"; foreach my $oid (<$fh>) { chomp $oid; - my $buf = cat_file($self, $oid) or next; - $$buf =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm or next; - my $cmt_time = $1 + 0; - $modified = $cmt_time if $cmt_time > $modified; + cat_async($self, $oid, \&extract_cmt_time, \$modified); } + cat_async_wait($self); $modified || time; }