Commit c8d521fa authored by Jeff King's avatar Jeff King Committed by Junio C Hamano

Add delta-islands.{c,h}

Hosting providers that allow users to "fork" existing
repos want those forks to share as much disk space as

Alternates are an existing solution to keep all the
objects from all the forks into a unique central repo,
but this can have some drawbacks. Especially when
packing the central repo, deltas will be created
between objects from different forks.

This can make cloning or fetching a fork much slower
and much more CPU intensive as Git might have to
compute new deltas for many objects to avoid sending
objects from a different fork.

Because the inefficiency primarily arises when an
object is deltified against another object that does
not exist in the same fork, we partition objects into
sets that appear in the same fork, and define
"delta islands". When finding delta base, we do not
allow an object outside the same island to be
considered as its base.

So "delta islands" is a way to store objects from
different forks in the same repo and packfile without
having deltas between objects from different forks.

This patch implements the delta islands mechanism in
"delta-islands.{c,h}", but does not yet make use of it.

A few new fields are added in 'struct object_entry'
in "pack-objects.h" though.

The documentation will follow in a patch that actually
uses delta islands in "builtin/pack-objects.c".
Signed-off-by: 's avatarJeff King <>
Signed-off-by: Christian Couder's avatarChristian Couder <>
Signed-off-by: 's avatarJunio C Hamano <>
parent 1d89318c
......@@ -841,6 +841,7 @@ LIB_OBJS += csum-file.o
LIB_OBJS += ctype.o
LIB_OBJS += date.o
LIB_OBJS += decorate.o
LIB_OBJS += delta-islands.o
LIB_OBJS += diffcore-break.o
LIB_OBJS += diffcore-delta.o
LIB_OBJS += diffcore-order.o
This diff is collapsed.
int island_delta_cmp(const struct object_id *a, const struct object_id *b);
int in_same_island(const struct object_id *, const struct object_id *);
void resolve_tree_islands(int progress, struct packing_data *to_pack);
void load_delta_islands(void);
void propagate_island_marks(struct commit *commit);
int compute_pack_layers(struct packing_data *to_pack);
#endif /* DELTA_ISLANDS_H */
......@@ -100,6 +100,10 @@ struct object_entry {
unsigned type_:TYPE_BITS;
unsigned no_try_delta:1;
unsigned in_pack_type:TYPE_BITS; /* could be delta */
unsigned int tree_depth; /* should be repositioned for packing? */
unsigned char layer;
unsigned preferred_base:1; /*
* we do not pack this, but is available
* to be used as the base object to delta
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment