]> granicus.if.org Git - git/commitdiff
revision.c: reduce object database queries
authorDerrick Stolee <dstolee@microsoft.com>
Sun, 25 Feb 2018 01:34:56 +0000 (20:34 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Feb 2018 23:04:52 +0000 (15:04 -0800)
In mark_parents_uninteresting(), we check for the existence of an
object file to see if we should treat a commit as parsed. The result
is to set the "parsed" bit on the commit.

Modify the condition to only check has_object_file() if the result
would change the parsed bit.

When a local branch is different from its upstream ref, "git status"
will compute ahead/behind counts. This uses paint_down_to_common()
and hits mark_parents_uninteresting(). On a copy of the Linux repo
with a local instance of "master" behind the remote branch
"origin/master" by ~60,000 commits, we find the performance of
"git status" went from 1.42 seconds to 1.32 seconds, for a relative
difference of -7.0%.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 771d079f6edca39f8fa0d28db9bf697a99deeea6..29f82ccfe651ab123b5ca2b6074a39f2ef9e047c 100644 (file)
@@ -110,7 +110,8 @@ void mark_parents_uninteresting(struct commit *commit)
                         * it is popped next time around, we won't be trying
                         * to parse it and get an error.
                         */
-                       if (!has_object_file(&commit->object.oid))
+                       if (!commit->object.parsed &&
+                           !has_object_file(&commit->object.oid))
                                commit->object.parsed = 1;
 
                        if (commit->object.flags & UNINTERESTING)