git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 2/5] Add delta-islands.{c,h}

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 24, 2018, 16:47 UTC
Message-ID
<xmqqpnzczila.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180722054836.28935-3-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
Show 5 quoted lines
> From: Jeff King <peff@peff.net>
>
> Hosting providers that allow users to "fork" existing
> repos want as much as possible those forks to use a
> small amount of disk space.

"... want those forks to consume as little amount of disk space as possible?" Or perhaps "... want those forks to share as much disk space as possible"?

> Using alternates to keep all the objects from all the forks into a
> unique central repo is way to do that, but ...

s/is way to/is a way to/, I guess, but that makes it sound as if the series invented a way to share objects without using alternates.

Show 11 quoted lines
> it 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.
>
> 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.

I think another paragraph between the above two is needed to briefly outline the central idea (which would make it clear why that is called "delta islands") is called for. Perhaps

	Because the inefficiency primarily arises when an object is
	delitified against another object that does not exist in the
	same fork, we partion 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.

or something along that line. Perhaps that would even make the last paragraph unnecessary.

Show 15 quoted lines
> +struct island_bitmap {
> +	uint32_t refcount;
> +	uint32_t bits[];
> +};
> +
> +static uint32_t island_bitmap_size;
> +
> +/*
> + * Allocate a new bitmap; if "old" is not NULL, the new bitmap will be a copy
> + * of "old". Otherwise, the new bitmap is empty.
> + */
> +static struct island_bitmap *island_bitmap_new(const struct island_bitmap *old)
> +{
> +	size_t size = sizeof(struct island_bitmap) + (island_bitmap_size * 4);
> +	struct island_bitmap *b = xcalloc(1, size);
Is one of the variants of flex array macros applicable here?
Show 43 quoted lines
> +	if (old)
> +		memcpy(b, old, size);
> +
> +	b->refcount = 1;
> +	return b;
> +}
> +
> +static void island_bitmap_or(struct island_bitmap *a, const struct island_bitmap *b)
> +{
> +	uint32_t i;
> +
> +	for (i = 0; i < island_bitmap_size; ++i)
> +		a->bits[i] |= b->bits[i];
> +}
> +
> +static int island_bitmap_is_subset(struct island_bitmap *self,
> +		struct island_bitmap *super)
> +{
> +	uint32_t i;
> +
> +	if (self == super)
> +		return 1;
> +
> +	for (i = 0; i < island_bitmap_size; ++i) {
> +		if ((self->bits[i] & super->bits[i]) != self->bits[i])
> +			return 0;
> +	}
> +
> +	return 1;
> +}
> +#define ISLAND_BITMAP_BLOCK(x) (x / 32)
> +#define ISLAND_BITMAP_MASK(x) (1 << (x % 32))
> +
> +static void island_bitmap_set(struct island_bitmap *self, uint32_t i)
> +{
> +	self->bits[ISLAND_BITMAP_BLOCK(i)] |= ISLAND_BITMAP_MASK(i);
> +}
> +
> +static int island_bitmap_get(struct island_bitmap *self, uint32_t i)
> +{
> +	return (self->bits[ISLAND_BITMAP_BLOCK(i)] & ISLAND_BITMAP_MASK(i)) != 0;
> +}
> +

Not necessarily a complaint, but do we need another implementation of bitmap here, or the compressed bitmap used for the pack bitmap is unsuited for the purpose of this thing (e.g. perhaps it is overkill, as we won't be shooting for saving disk footprint of a bitmap that we are not going to save on disk anyway)?

Show 30 quoted lines
> +static int cmp_tree_depth(const void *va, const void *vb)
> +{
> +	struct object_entry *a = *(struct object_entry **)va;
> +	struct object_entry *b = *(struct object_entry **)vb;
> +	return a->tree_depth - b->tree_depth;
> +}
> +
> +void resolve_tree_islands(int progress, struct packing_data *to_pack)
> +{
> +	struct progress *progress_state = NULL;
> +	struct object_entry **todo;
> +	int nr = 0;
> +	int i;
> +
> +	if (!island_marks)
> +		return;
> +
> +	/*
> +	 * We process only trees, as commits and tags have already been handled
> +	 * (and passed their marks on to root trees, as well. We must make sure
> +	 * to process them in descending tree-depth order so that marks
> +	 * propagate down the tree properly, even if a sub-tree is found in
> +	 * multiple parent trees.
> +	 */
> +	todo = xmalloc(to_pack->nr_objects * sizeof(*todo));
> +	for (i = 0; i < to_pack->nr_objects; i++) {
> +		if (oe_type(&to_pack->objects[i]) == OBJ_TREE)
> +			todo[nr++] = &to_pack->objects[i];
> +	}
> +	qsort(todo, nr, sizeof(*todo), cmp_tree_depth);

Hmph, at this stage nobody actually seems to set tree_depth; I am wondering how a tree that is at the root in one commit but appears as a subdirectory in another commit is handled by this code.

> +static regex_t *island_regexes;
> +static unsigned int island_regexes_alloc, island_regexes_nr;
> +static const char *core_island_name;

Are these (and the bitmap & hashtable) something that "everything in the_repository" folks would come in and nuke as global variables? I haven't thought deeply about it, but these smell like that there would be one set of such in-core variables per one in-core object store plus refs (i.e. repository instance).

Previous: Duy NguyenNext: Jeff King
Message 13 of 37 in “Add delta islands support”
  1. 0/5 Add delta islands supportChristian Couder, Jul 22, 2018
  2. 1/5 packfile: make get_delta_base() non staticChristian Couder, Jul 22, 2018
  3. Junio C HamanoJul 24, 2018
  4. Jeff KingJul 27, 2018
  5. 2/5 Add delta-islands.{c,h}Christian Couder, Jul 22, 2018
  6. Duy NguyenJul 22, 2018
  7. Christian CouderJul 22, 2018
  8. Christian CouderAug 5, 2018
  9. Jeff KingAug 6, 2018
  10. Duy NguyenAug 6, 2018
  11. Christian CouderAug 6, 2018
  12. Duy NguyenAug 6, 2018
  13. Junio C HamanoJul 24, 2018
  14. Jeff KingJul 27, 2018
  15. Jeff KingJul 27, 2018
  16. 4/5 repack: add delta-islands supportChristian Couder, Jul 22, 2018
  17. 5/5 t: add t9930-delta-islands.shChristian Couder, Jul 22, 2018
  18. Jeff KingJul 24, 2018
  19. 3/5 pack-objects: add delta-islands supportChristian Couder, Jul 22, 2018
  20. Duy NguyenJul 22, 2018
  21. Christian CouderAug 5, 2018
  22. Stefan BellerJul 23, 2018
  23. Jeff KingJul 24, 2018
  24. Stefan BellerJul 24, 2018
  25. Jeff KingJul 27, 2018
  26. Stefan BellerJul 27, 2018
  27. Jeff KingJul 28, 2018
  28. Christian CouderJul 28, 2018
  29. Junio C HamanoJul 24, 2018
  30. Junio C HamanoJul 24, 2018
  31. Christian CouderAug 5, 2018
  32. Christian CouderAug 6, 2018
  33. Jeff KingAug 6, 2018
  34. Jeff KingJul 24, 2018
  35. Junio C HamanoJul 24, 2018
  36. Jeff KingJul 24, 2018
  37. Johannes SchindelinJul 26, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.