From 99bf115c879af7e38ef0ca9596fc9db1d6598d5f Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 8 May 2018 12:37:24 -0700 Subject: repository: introduce parsed objects field Convert the existing global cache for parsed objects (obj_hash) into repository-specific parsed object caches. Existing code that uses obj_hash are modified to use the parsed object cache of the_repository; future patches will use the parsed object caches of other repositories. Another future use case for a pool of objects is ease of memory management in revision walking: If we can free the rev-list related memory early in pack-objects (e.g. part of repack operation) then it could lower memory pressure significantly when running on large repos. While this has been discussed on the mailing list lately, this series doesn't implement this. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'object.h') diff --git a/object.h b/object.h index f13f85b2a9..cecda7da37 100644 --- a/object.h +++ b/object.h @@ -1,6 +1,14 @@ #ifndef OBJECT_H #define OBJECT_H +struct parsed_object_pool { + struct object **obj_hash; + int nr_objs, obj_hash_size; +}; + +struct parsed_object_pool *parsed_object_pool_new(void); +void parsed_object_pool_clear(struct parsed_object_pool *o); + struct object_list { struct object *item; struct object_list *next; -- cgit v1.2.3 From 68f95d382b51b134b138c91f94adb8d9ef2f557a Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 8 May 2018 12:37:25 -0700 Subject: object: add repository argument to create_object Add a repository argument to allow the callers of create_object to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. Signed-off-by: Jonathan Nieder Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'object.h') diff --git a/object.h b/object.h index cecda7da37..2cb0b24108 100644 --- a/object.h +++ b/object.h @@ -93,7 +93,8 @@ extern struct object *get_indexed_object(unsigned int); */ struct object *lookup_object(const unsigned char *sha1); -extern void *create_object(const unsigned char *sha1, void *obj); +#define create_object(r, s, o) create_object_##r(s, o) +extern void *create_object_the_repository(const unsigned char *sha1, void *obj); void *object_as_type(struct object *obj, enum object_type type, int quiet); -- cgit v1.2.3 From 341e45e46bba094ef1274957ef5891f43e91b344 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 8 May 2018 12:37:35 -0700 Subject: object: allow create_object to handle arbitrary repositories Reviewed-by: Jonathan Tan Signed-off-by: Jonathan Nieder Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'object.h') diff --git a/object.h b/object.h index 2cb0b24108..b41d7a3acc 100644 --- a/object.h +++ b/object.h @@ -93,8 +93,7 @@ extern struct object *get_indexed_object(unsigned int); */ struct object *lookup_object(const unsigned char *sha1); -#define create_object(r, s, o) create_object_##r(s, o) -extern void *create_object_the_repository(const unsigned char *sha1, void *obj); +extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj); void *object_as_type(struct object *obj, enum object_type type, int quiet); -- cgit v1.2.3 From 14ba97f81c7b94e10d591b363688a073023f332d Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 15 May 2018 14:48:42 -0700 Subject: alloc: allow arbitrary repositories for alloc functions We have to convert all of the alloc functions at once, because alloc_report uses a funky macro for reporting. It is better for the sake of mechanical conversion to convert multiple functions at once rather than changing the structure of the reporting function. We record all memory allocation in alloc.c, and free them in clear_alloc_state, which is called for all repositories except the_repository. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'object.h') diff --git a/object.h b/object.h index b41d7a3acc..7916edb4ed 100644 --- a/object.h +++ b/object.h @@ -4,6 +4,14 @@ struct parsed_object_pool { struct object **obj_hash; int nr_objs, obj_hash_size; + + /* TODO: migrate alloc_states to mem-pool? */ + struct alloc_state *blob_state; + struct alloc_state *tree_state; + struct alloc_state *commit_state; + struct alloc_state *tag_state; + struct alloc_state *object_state; + unsigned commit_count; }; struct parsed_object_pool *parsed_object_pool_new(void); -- cgit v1.2.3