From e261bedfae7f2eb192109b5fdd4113440fee7e22 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 30 May 2019 06:35:05 +0000 Subject: v2writable: short-circuit is_ancestor check on equality 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(+) (limited to 'lib') diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index fd93ac27..76844cd4 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 -- cgit v1.2.3-24-ge0c7