Browse Source

pack-objects: move 'layer' into 'struct packing_data'

This reduces the size of 'struct object_entry' from 88 bytes
to 80 and therefore makes packing objects more efficient.

For example on a Linux repo with 12M objects,
`git pack-objects --all` needs extra 96MB memory even if the
layer feature is not used.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Christian Couder 7 years ago committed by Junio C Hamano
parent
commit
fe0ac2fb7f
  1. 4
      builtin/pack-objects.c
  2. 4
      delta-islands.c
  3. 6
      pack-objects.c
  4. 20
      pack-objects.h

4
builtin/pack-objects.c

@ -611,7 +611,7 @@ static inline void add_to_write_order(struct object_entry **wo, @@ -611,7 +611,7 @@ static inline void add_to_write_order(struct object_entry **wo,
unsigned int *endp,
struct object_entry *e)
{
if (e->filled || e->layer != write_layer)
if (e->filled || oe_layer(&to_pack, e) != write_layer)
return;
wo[(*endp)++] = e;
e->filled = 1;
@ -714,7 +714,7 @@ static void compute_layer_order(struct object_entry **wo, unsigned int *wo_end) @@ -714,7 +714,7 @@ static void compute_layer_order(struct object_entry **wo, unsigned int *wo_end)
* Finally all the rest in really tight order
*/
for (i = last_untagged; i < to_pack.nr_objects; i++) {
if (!objects[i].filled && objects[i].layer == write_layer)
if (!objects[i].filled && oe_layer(&to_pack, &objects[i]) == write_layer)
add_family_to_write_order(wo, wo_end, &objects[i]);
}
}

4
delta-islands.c

@ -488,13 +488,13 @@ int compute_pack_layers(struct packing_data *to_pack) @@ -488,13 +488,13 @@ int compute_pack_layers(struct packing_data *to_pack)
struct object_entry *entry = &to_pack->objects[i];
khiter_t pos = kh_get_sha1(island_marks, entry->idx.oid.hash);

entry->layer = 1;
oe_set_layer(to_pack, entry, 1);

if (pos < kh_end(island_marks)) {
struct island_bitmap *bitmap = kh_value(island_marks, pos);

if (island_bitmap_get(bitmap, island_counter_core))
entry->layer = 0;
oe_set_layer(to_pack, entry, 0);
}
}


6
pack-objects.c

@ -163,6 +163,9 @@ struct object_entry *packlist_alloc(struct packing_data *pdata, @@ -163,6 +163,9 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,

if (pdata->tree_depth)
REALLOC_ARRAY(pdata->tree_depth, pdata->nr_alloc);

if (pdata->layer)
REALLOC_ARRAY(pdata->layer, pdata->nr_alloc);
}

new_entry = pdata->objects + pdata->nr_objects++;
@ -181,5 +184,8 @@ struct object_entry *packlist_alloc(struct packing_data *pdata, @@ -181,5 +184,8 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
if (pdata->tree_depth)
pdata->tree_depth[pdata->nr_objects - 1] = 0;

if (pdata->layer)
pdata->layer[pdata->nr_objects - 1] = 0;

return new_entry;
}

20
pack-objects.h

@ -101,8 +101,6 @@ struct object_entry { @@ -101,8 +101,6 @@ struct object_entry {
unsigned no_try_delta:1;
unsigned in_pack_type:TYPE_BITS; /* could be delta */

unsigned char layer;

unsigned preferred_base:1; /*
* we do not pack this, but is available
* to be used as the base object to delta
@ -147,6 +145,7 @@ struct packing_data { @@ -147,6 +145,7 @@ struct packing_data {

/* delta islands */
unsigned int *tree_depth;
unsigned char *layer;
};

void prepare_packing_data(struct packing_data *pdata);
@ -369,4 +368,21 @@ static inline void oe_set_tree_depth(struct packing_data *pack, @@ -369,4 +368,21 @@ static inline void oe_set_tree_depth(struct packing_data *pack,
pack->tree_depth[e - pack->objects] = tree_depth;
}

static inline unsigned char oe_layer(struct packing_data *pack,
struct object_entry *e)
{
if (!pack->layer)
return 0;
return pack->layer[e - pack->objects];
}

static inline void oe_set_layer(struct packing_data *pack,
struct object_entry *e,
unsigned char layer)
{
if (!pack->layer)
ALLOC_ARRAY(pack->layer, pack->nr_objects);
pack->layer[e - pack->objects] = layer;
}

#endif

Loading…
Cancel
Save