]> git.ipfire.org Git - thirdparty/git.git/commit - midx.c
midx: implement midx_repack()
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 10 Jun 2019 23:35:27 +0000 (16:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2019 17:34:40 +0000 (10:34 -0700)
commitce1e4a105b4ff2457f2537bc703863175f9195c9
tree7022bb86e3ea51bc634d3435b93ad1eb663b87e7
parent2af890bb28013ae9edf8f5de7873fac849d39c32
midx: implement midx_repack()

To repack with a non-zero batch-size, first sort all pack-files by
their modified time. Second, walk those pack-files from oldest
to newest, compute their expected size, and add the packs to a list
if they are smaller than the given batch-size. Stop when the total
expected size is at least the batch size.

If the batch size is zero, select all packs in the multi-pack-index.

Finally, collect the objects from the multi-pack-index that are in
the selected packs and send them to 'git pack-objects'. Write a new
multi-pack-index that includes the new pack.

Using a batch size of zero is very similar to a standard 'git repack'
command, except that we do not delete the old packs and instead rely
on the new multi-pack-index to prevent new processes from reading the
old packs. This does not disrupt other Git processes that are currently
reading the old packs based on the old multi-pack-index.

While first designing a 'git multi-pack-index repack' operation, I
started by collecting the batches based on the actual size of the
objects instead of the size of the pack-files. This allows repacking
a large pack-file that has very few referencd objects. However, this
came at a significant cost of parsing pack-files instead of simply
reading the multi-pack-index and getting the file information for
the pack-files. The "expected size" version provides similar
behavior, but could skip a pack-file if the average object size is
much larger than the actual size of the referenced objects, or
can create a large pack if the actual size of the referenced objects
is larger than the expected size.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c
t/t5319-multi-pack-index.sh