multi-pack-index: repack batches below --batch-size
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 11 Aug 2020 15:30:18 +0000 (15:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Aug 2020 21:05:26 +0000 (14:05 -0700)
commit1eb22c7dd803fc05513fde0bd96befeb8c725e05
treea9a3c9fd0f1f6f659dee8dec832480dd311e897c
parent4f0a8be78499454eac3985b6e7e144b8376ab0a5
multi-pack-index: repack batches below --batch-size

The --batch-size=<size> option of 'git multi-pack-index repack' is
intended to limit the amount of work done by the repack. In the case of
a large repository, this command should repack a number of small
pack-files but leave the large pack-files alone. Most often, the
repository has one large pack-file from a 'git clone' operation and
number of smaller pack-files from incremental 'git fetch' operations.

The issue with '--batch-size' is that it also _prevents_ the repack from
happening if the expected size of the resulting pack-file is too small.
This was intended as a way to avoid frequent churn of small pack-files,
but it has mostly caused confusion when a repository is of "medium"
size. That is, not enormous like the Windows OS repository, but also not
so small that this incremental repack isn't valuable.

The solution presented here is to collect pack-files for repack if their
expected size is smaller than the batch-size parameter until either the
total expected size exceeds the batch-size or all pack-files are
considered. If there are at least two pack-files, then these are
combined to a new pack-file whose size should not be too much larger
than the batch-size.

This new strategy should succeed in keeping the number of pack-files
small in these "medium" size repositories. The concern about churn is
likely not interesting, as the real control over that is the frequency
in which the repack command is run.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-multi-pack-index.txt
midx.c
t/t5319-multi-pack-index.sh