@matheusbsbs / matheus-bagliano / commits / a82d07e5e6
Fork 0

[PATCH] fetch.c: Make process() look at each object only once

The process() function is very often called multiple times for the same object (because lots of trees refer to the same blobs), but did not have a fast check for this, therefore a lot of useless calls to has_sha1_file() and parse_object() were made before discovering that nothing needs to be done. This patch adds the SEEN flag which is used in process() to make it look at each object only once. When testing git-local-fetch on the repository of GIT, this gives a 14x improvement in CPU usage (mainly because the redundant calls to parse_object() are now avoided - parse_object() always unpacks and parses the object data, even if it was already parsed before). Signed-off-by: Sergey Vlasov <vsu@altlinux.ru> Signed-off-by: Junio C Hamano <junkio@cox.net>

Sergey Vlasov committed Sep 21, 2005 at 20:33 UTC a82d07e5e61a9aef38d70277a5b27588a939c5ce
1 file changed +5
fetch.c
+5
@@ -58,6 +58,7 @@ static int process_tree(struct tree *tree)
58 #define TO_FETCH 2U
59 #define TO_SCAN 4U
60 #define SCANNED 8U
61 +#define SEEN 16U
62
63 static struct commit_list *complete = NULL;
64
@@ -134,6 +135,10 @@ static int process_object(struct object *obj)
135
136 static int process(struct object *obj)
137 {
138 + if (obj->flags & SEEN)
139 + return 0;
140 + obj->flags |= SEEN;
141 +
142 if (has_sha1_file(obj->sha1)) {
143 parse_object(obj->sha1);
144 /* We already have it, so we should scan it now. */