1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-24 04:56:09 +02:00

Merge branch 'jk/promisor-optim' into next

Handling of "promisor packs" that allows certain objects to be
missing and lazily retrievable has been optimized (a bit).

* jk/promisor-optim:
  revision: avoid parsing with --exclude-promisor-objects
  lookup_unknown_object(): take a repository argument
  is_promisor_object(): free tree buffer after parsing
This commit is contained in:
Junio C Hamano 2021-04-15 13:38:09 -07:00
commit 41f303ef9b
12 changed files with 27 additions and 15 deletions

View File

@ -725,7 +725,7 @@ static int fsck_cache_tree(struct cache_tree *it)
static void mark_object_for_connectivity(const struct object_id *oid) static void mark_object_for_connectivity(const struct object_id *oid)
{ {
struct object *obj = lookup_unknown_object(oid); struct object *obj = lookup_unknown_object(the_repository, oid);
obj->flags |= HAS_OBJ; obj->flags |= HAS_OBJ;
} }

View File

@ -3386,7 +3386,7 @@ static void add_objects_in_unpacked_packs(void)
for (i = 0; i < p->num_objects; i++) { for (i = 0; i < p->num_objects; i++) {
nth_packed_object_id(&oid, p, i); nth_packed_object_id(&oid, p, i);
o = lookup_unknown_object(&oid); o = lookup_unknown_object(the_repository, &oid);
if (!(o->flags & OBJECT_ADDED)) if (!(o->flags & OBJECT_ADDED))
mark_in_pack_object(o, p, &in_pack); mark_in_pack_object(o, p, &in_pack);
o->flags |= OBJECT_ADDED; o->flags |= OBJECT_ADDED;

View File

@ -1436,7 +1436,7 @@ static void one_remote_ref(const char *refname)
* may be required for updating server info later. * may be required for updating server info later.
*/ */
if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) { if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
obj = lookup_unknown_object(&ref->old_oid); obj = lookup_unknown_object(the_repository, &ref->old_oid);
fprintf(stderr, " fetch %s for %s\n", fprintf(stderr, " fetch %s for %s\n",
oid_to_hex(&ref->old_oid), refname); oid_to_hex(&ref->old_oid), refname);
add_fetch_request(obj); add_fetch_request(obj);

View File

@ -177,12 +177,11 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
} }
} }
struct object *lookup_unknown_object(const struct object_id *oid) struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid)
{ {
struct object *obj = lookup_object(the_repository, oid); struct object *obj = lookup_object(r, oid);
if (!obj) if (!obj)
obj = create_object(the_repository, oid, obj = create_object(r, oid, alloc_object_node(r));
alloc_object_node(the_repository));
return obj; return obj;
} }

View File

@ -145,7 +145,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p); struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
/** Returns the object, with potentially excess memory allocated. **/ /** Returns the object, with potentially excess memory allocated. **/
struct object *lookup_unknown_object(const struct object_id *oid); struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid);
struct object_list *object_list_insert(struct object *item, struct object_list *object_list_insert(struct object *item,
struct object_list **list_p); struct object_list **list_p);

View File

@ -2247,6 +2247,7 @@ static int add_promisor_object(const struct object_id *oid,
return 0; return 0;
while (tree_entry_gently(&desc, &entry)) while (tree_entry_gently(&desc, &entry))
oidset_insert(set, &entry.oid); oidset_insert(set, &entry.oid);
free_tree_buffer(tree);
} else if (obj->type == OBJ_COMMIT) { } else if (obj->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *) obj; struct commit *commit = (struct commit *) obj;
struct commit_list *parents = commit->parents; struct commit_list *parents = commit->parents;

2
refs.c
View File

@ -337,7 +337,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
enum peel_status peel_object(const struct object_id *name, struct object_id *oid) enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
{ {
struct object *o = lookup_unknown_object(name); struct object *o = lookup_unknown_object(the_repository, name);
if (o->type == OBJ_NONE) { if (o->type == OBJ_NONE) {
int type = oid_object_info(the_repository, name, NULL); int type = oid_object_info(the_repository, name, NULL);

View File

@ -3271,7 +3271,7 @@ static int mark_uninteresting(const struct object_id *oid,
void *cb) void *cb)
{ {
struct rev_info *revs = cb; struct rev_info *revs = cb;
struct object *o = parse_object(revs->repo, oid); struct object *o = lookup_unknown_object(revs->repo, oid);
o->flags |= UNINTERESTING | SEEN; o->flags |= UNINTERESTING | SEEN;
return 0; return 0;
} }

View File

@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
* Add 2 objects, one with a non-NULL decoration and one with a NULL * Add 2 objects, one with a non-NULL decoration and one with a NULL
* decoration. * decoration.
*/ */
one = lookup_unknown_object(&one_oid); one = lookup_unknown_object(the_repository, &one_oid);
two = lookup_unknown_object(&two_oid); two = lookup_unknown_object(the_repository, &two_oid);
ret = add_decoration(&n, one, &decoration_a); ret = add_decoration(&n, one, &decoration_a);
if (ret) if (ret)
BUG("when adding a brand-new object, NULL should be returned"); BUG("when adding a brand-new object, NULL should be returned");
@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
ret = lookup_decoration(&n, two); ret = lookup_decoration(&n, two);
if (ret != &decoration_b) if (ret != &decoration_b)
BUG("lookup should return added declaration"); BUG("lookup should return added declaration");
three = lookup_unknown_object(&three_oid); three = lookup_unknown_object(the_repository, &three_oid);
ret = lookup_decoration(&n, three); ret = lookup_decoration(&n, three);
if (ret) if (ret)
BUG("lookup for unknown object should return NULL"); BUG("lookup for unknown object should return NULL");

View File

@ -23,4 +23,16 @@ test_perf 'checkout of result' '
git -C worktree checkout -f git -C worktree checkout -f
' '
test_perf 'fsck' '
git -C bare.git fsck
'
test_perf 'count commits' '
git -C bare.git rev-list --all --count
'
test_perf 'count non-promisor commits' '
git -C bare.git rev-list --all --count --exclude-promisor-objects
'
test_done test_done

View File

@ -1153,7 +1153,7 @@ static void receive_needs(struct upload_pack_data *data,
static int mark_our_ref(const char *refname, const char *refname_full, static int mark_our_ref(const char *refname, const char *refname_full,
const struct object_id *oid) const struct object_id *oid)
{ {
struct object *o = lookup_unknown_object(oid); struct object *o = lookup_unknown_object(the_repository, oid);
if (ref_is_hidden(refname, refname_full)) { if (ref_is_hidden(refname, refname_full)) {
o->flags |= HIDDEN_REF; o->flags |= HIDDEN_REF;

View File

@ -298,7 +298,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
error("Could not interpret response from server '%s' as something to pull", target[i]); error("Could not interpret response from server '%s' as something to pull", target[i]);
goto done; goto done;
} }
if (process(walker, lookup_unknown_object(&oids[i]))) if (process(walker, lookup_unknown_object(the_repository, &oids[i])))
goto done; goto done;
} }