Skip to content

Commit 647982b

Browse files
Eric Wonggitster
authored andcommitted
delta-islands: free island_marks and bitmaps
On my mirror of linux.git forkgroup with 780 islands, this saves nearly 4G of heap memory in pack-objects. This savings only benefits delta island users of pack bitmaps, as the process would otherwise be exiting anyways. However, there's probably not many delta island users, but the majority of delta island users would also be pack bitmaps users. Signed-off-by: Eric Wong <[email protected]> Helped-by: Ævar Arnfjörð Bjarmason <[email protected]> Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 844ede3 commit 647982b

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

builtin/pack-objects.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,10 @@ static struct object_entry **compute_write_order(void)
929929
*/
930930
for_each_tag_ref(mark_tagged, NULL);
931931

932-
if (use_delta_islands)
932+
if (use_delta_islands) {
933933
max_layers = compute_pack_layers(&to_pack);
934+
free_island_marks();
935+
}
934936

935937
ALLOC_ARRAY(wo, to_pack.nr_objects);
936938
wo_end = 0;

delta-islands.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,20 @@ void propagate_island_marks(struct commit *commit)
513513
}
514514
}
515515

516+
void free_island_marks(void)
517+
{
518+
struct island_bitmap *bitmap;
519+
520+
kh_foreach_value(island_marks, bitmap, {
521+
if (!--bitmap->refcount)
522+
free(bitmap);
523+
});
524+
kh_destroy_oid_map(island_marks);
525+
526+
/* detect use-after-free with a an address which is never valid: */
527+
island_marks = (void *)-1;
528+
}
529+
516530
int compute_pack_layers(struct packing_data *to_pack)
517531
{
518532
uint32_t i;

delta-islands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ void resolve_tree_islands(struct repository *r,
1414
void load_delta_islands(struct repository *r, int progress);
1515
void propagate_island_marks(struct commit *commit);
1616
int compute_pack_layers(struct packing_data *to_pack);
17+
void free_island_marks(void);
1718

1819
#endif /* DELTA_ISLANDS_H */

0 commit comments

Comments
 (0)