]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: short-circuit is_ancestor check on equality
authorEric Wong <e@80x24.org>
Thu, 30 May 2019 06:35:05 +0000 (06:35 +0000)
committerEric Wong <e@80x24.org>
Thu, 30 May 2019 06:40:27 +0000 (06:40 +0000)
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

index fd93ac2732ee575c365bec3c6468466434e3acde..76844cd45a0f046b91a35263e9de046899f37f77 100644 (file)
@@ -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