Skip to content

Commit 13158b9

Browse files
committed
Merge branch 'jk/promisor-optim'
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
2 parents 311531c + c1fa951 commit 13158b9

File tree

12 files changed

+27
-15
lines changed

12 files changed

+27
-15
lines changed

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static int fsck_cache_tree(struct cache_tree *it)
725725

726726
static void mark_object_for_connectivity(const struct object_id *oid)
727727
{
728-
struct object *obj = lookup_unknown_object(oid);
728+
struct object *obj = lookup_unknown_object(the_repository, oid);
729729
obj->flags |= HAS_OBJ;
730730
}
731731

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ static void add_objects_in_unpacked_packs(void)
33863386

33873387
for (i = 0; i < p->num_objects; i++) {
33883388
nth_packed_object_id(&oid, p, i);
3389-
o = lookup_unknown_object(&oid);
3389+
o = lookup_unknown_object(the_repository, &oid);
33903390
if (!(o->flags & OBJECT_ADDED))
33913391
mark_in_pack_object(o, p, &in_pack);
33923392
o->flags |= OBJECT_ADDED;

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ static void one_remote_ref(const char *refname)
14361436
* may be required for updating server info later.
14371437
*/
14381438
if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
1439-
obj = lookup_unknown_object(&ref->old_oid);
1439+
obj = lookup_unknown_object(the_repository, &ref->old_oid);
14401440
fprintf(stderr, " fetch %s for %s\n",
14411441
oid_to_hex(&ref->old_oid), refname);
14421442
add_fetch_request(obj);

object.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,11 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
177177
}
178178
}
179179

180-
struct object *lookup_unknown_object(const struct object_id *oid)
180+
struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid)
181181
{
182-
struct object *obj = lookup_object(the_repository, oid);
182+
struct object *obj = lookup_object(r, oid);
183183
if (!obj)
184-
obj = create_object(the_repository, oid,
185-
alloc_object_node(the_repository));
184+
obj = create_object(r, oid, alloc_object_node(r));
186185
return obj;
187186
}
188187

object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
145145
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);
146146

147147
/** Returns the object, with potentially excess memory allocated. **/
148-
struct object *lookup_unknown_object(const struct object_id *oid);
148+
struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid);
149149

150150
struct object_list *object_list_insert(struct object *item,
151151
struct object_list **list_p);

packfile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,6 +2247,7 @@ static int add_promisor_object(const struct object_id *oid,
22472247
return 0;
22482248
while (tree_entry_gently(&desc, &entry))
22492249
oidset_insert(set, &entry.oid);
2250+
free_tree_buffer(tree);
22502251
} else if (obj->type == OBJ_COMMIT) {
22512252
struct commit *commit = (struct commit *) obj;
22522253
struct commit_list *parents = commit->parents;

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
337337

338338
enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
339339
{
340-
struct object *o = lookup_unknown_object(name);
340+
struct object *o = lookup_unknown_object(the_repository, name);
341341

342342
if (o->type == OBJ_NONE) {
343343
int type = oid_object_info(the_repository, name, NULL);

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3271,7 +3271,7 @@ static int mark_uninteresting(const struct object_id *oid,
32713271
void *cb)
32723272
{
32733273
struct rev_info *revs = cb;
3274-
struct object *o = parse_object(revs->repo, oid);
3274+
struct object *o = lookup_unknown_object(revs->repo, oid);
32753275
o->flags |= UNINTERESTING | SEEN;
32763276
return 0;
32773277
}

t/helper/test-example-decorate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
2626
* Add 2 objects, one with a non-NULL decoration and one with a NULL
2727
* decoration.
2828
*/
29-
one = lookup_unknown_object(&one_oid);
30-
two = lookup_unknown_object(&two_oid);
29+
one = lookup_unknown_object(the_repository, &one_oid);
30+
two = lookup_unknown_object(the_repository, &two_oid);
3131
ret = add_decoration(&n, one, &decoration_a);
3232
if (ret)
3333
BUG("when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
5656
ret = lookup_decoration(&n, two);
5757
if (ret != &decoration_b)
5858
BUG("lookup should return added declaration");
59-
three = lookup_unknown_object(&three_oid);
59+
three = lookup_unknown_object(the_repository, &three_oid);
6060
ret = lookup_decoration(&n, three);
6161
if (ret)
6262
BUG("lookup for unknown object should return NULL");

t/perf/p5600-partial-clone.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,16 @@ test_perf 'checkout of result' '
2323
git -C worktree checkout -f
2424
'
2525

26+
test_perf 'fsck' '
27+
git -C bare.git fsck
28+
'
29+
30+
test_perf 'count commits' '
31+
git -C bare.git rev-list --all --count
32+
'
33+
34+
test_perf 'count non-promisor commits' '
35+
git -C bare.git rev-list --all --count --exclude-promisor-objects
36+
'
37+
2638
test_done

0 commit comments

Comments
 (0)