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, URIBL_BLOCKED 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 810471F97F for ; Thu, 30 May 2019 06:52:28 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] v2writable: short-circuit is_ancestor check on equality Date: Thu, 30 May 2019 06:52:27 +0000 Message-Id: <20190530065227.17641-5-e@80x24.org> In-Reply-To: <20190530065227.17641-1-e@80x24.org> References: <20190530065227.17641-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We don't need to use git to check ancestry if object IDs match on a string comparison. This saves 100ms or so and brings down the ~0.5s no-op time on lore.kernel.org/lkml down to ~0.4s. --- lib/PublicInbox/V2Writable.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index fd93ac2..76844cd 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -831,6 +831,12 @@ sub log_range ($$$$$) { return $tip; # all of it }; + # fast equality check to avoid (v)fork+execve overhead + if ($cur eq $tip) { + $sync->{ranges}->[$i] = undef; + return; + } + my $range = "$cur..$tip"; $pr->("$i.git checking contiguity... ") if $pr; if (is_ancestor($git, $cur, $tip)) { # common case -- EW