mirror of
https://github.com/git/git.git
synced 2024-11-18 19:13:58 +01:00
8805ccac40
The object parsing code builds a generic "this object references that object" because doing a full connectivity check for fsck requires it. However, nothing else really needs it, and it's quite expensive for git-rev-list that can have tons of objects in flight. So, exactly like the commit buffer save thing, add a global flag to disable it, and use it in git-rev-list. Before: $ /usr/bin/time git-rev-list --objects v2.6.12..HEAD | wc -l 12.28user 0.29system 0:12.57elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+26718minor)pagefaults 0swaps 59124 After this change: $ /usr/bin/time git-rev-list --objects v2.6.12..HEAD | wc -l 10.33user 0.18system 0:10.54elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+18509minor)pagefaults 0swaps 59124 and note how the number of pages touched by git-rev-list for this particular object list has shrunk from 26,718 (104 MB) to 18,509 (72 MB). Calculating the total object difference between two git revisions is still clearly the most expensive git operation (both in memory and CPU time), but it's now less than 40% of what it used to be. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
#ifndef OBJECT_H
|
|
#define OBJECT_H
|
|
|
|
struct object_list {
|
|
struct object *item;
|
|
struct object_list *next;
|
|
const char *name;
|
|
};
|
|
|
|
struct object {
|
|
unsigned parsed : 1;
|
|
unsigned used : 1;
|
|
unsigned int flags;
|
|
unsigned char sha1[20];
|
|
const char *type;
|
|
struct object_list *refs;
|
|
void *util;
|
|
};
|
|
|
|
extern int track_object_refs;
|
|
extern int nr_objs;
|
|
extern struct object **objs;
|
|
|
|
/** Internal only **/
|
|
struct object *lookup_object(const unsigned char *sha1);
|
|
|
|
/** Returns the object, having looked it up as being the given type. **/
|
|
struct object *lookup_object_type(const unsigned char *sha1, const char *type);
|
|
|
|
void created_object(const unsigned char *sha1, struct object *obj);
|
|
|
|
/** Returns the object, having parsed it to find out what it is. **/
|
|
struct object *parse_object(const unsigned char *sha1);
|
|
|
|
/** Returns the object, with potentially excess memory allocated. **/
|
|
struct object *lookup_unknown_object(const unsigned char *sha1);
|
|
|
|
void add_ref(struct object *refer, struct object *target);
|
|
|
|
void mark_reachable(struct object *obj, unsigned int mask);
|
|
|
|
struct object_list *object_list_insert(struct object *item,
|
|
struct object_list **list_p);
|
|
|
|
void object_list_append(struct object *item,
|
|
struct object_list **list_p);
|
|
|
|
unsigned object_list_length(struct object_list *list);
|
|
|
|
int object_list_contains(struct object_list *list, struct object *obj);
|
|
|
|
#endif /* OBJECT_H */
|