diff options
author | Sergey Vlasov <vsu@altlinux.ru> | 2005-11-15 19:08:08 +0300 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-15 11:42:29 -0800 |
commit | 4a4e6fd74f7d4564ed43eaaf59b6bd70c1959f1a (patch) | |
tree | 505862d83f5f0ffae0a2d024e7d0bfb336ddf560 /server-info.c | |
parent | 545f229a4b43212e683ac63e5aa740324ac7799e (diff) | |
download | git-4a4e6fd74f7d4564ed43eaaf59b6bd70c1959f1a.tar.gz |
Rework object refs tracking to reduce memory usage
Store pointers to referenced objects in a variable sized array instead
of linked list. This cuts down memory usage of utilities which use
object references; e.g., git-fsck-objects --full on the git.git
repository consumes about 2 MB of memory tracked by Massif instead of
7 MB before the change. Object refs are still the biggest consumer of
memory (57%), but the malloc overhead for a single block instead of a
linked list is substantially smaller.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'server-info.c')
-rw-r--r-- | server-info.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/server-info.c b/server-info.c index 0cba8e19f7..e4006f0b5b 100644 --- a/server-info.c +++ b/server-info.c @@ -424,7 +424,6 @@ static void find_pack_info_one(int pack_ix) { unsigned char sha1[20]; struct object *o; - struct object_list *ref; int i; struct packed_git *p = info[pack_ix]->p; int num = num_packed_objects(p); @@ -437,8 +436,12 @@ static void find_pack_info_one(int pack_ix) die("corrupt pack file %s?", p->pack_name); if ((o = lookup_object(sha1)) == NULL) die("cannot parse %s", sha1_to_hex(sha1)); - for (ref = o->refs; ref; ref = ref->next) - ref->item->flags = 0; + if (o->refs) { + struct object_refs *refs = o->refs; + int j; + for (j = 0; j < refs->count; j++) + refs->ref[j]->flags = 0; + } o->flags = 0; } @@ -448,8 +451,12 @@ static void find_pack_info_one(int pack_ix) die("corrupt pack file %s?", p->pack_name); if ((o = lookup_object(sha1)) == NULL) die("cannot find %s", sha1_to_hex(sha1)); - for (ref = o->refs; ref; ref = ref->next) - ref->item->flags |= REFERENCED; + if (o->refs) { + struct object_refs *refs = o->refs; + int j; + for (j = 0; j < refs->count; j++) + refs->ref[j]->flags |= REFERENCED; + } o->flags |= INTERNAL; } @@ -460,8 +467,12 @@ static void find_pack_info_one(int pack_ix) die("cannot find %s", sha1_to_hex(sha1)); show(o, pack_ix); - for (ref = o->refs; ref; ref = ref->next) - show(ref->item, pack_ix); + if (o->refs) { + struct object_refs *refs = o->refs; + int j; + for (j = 0; j < refs->count; j++) + show(refs->ref[j], pack_ix); + } } } |