]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/gc.c: make `gc.cruftPacks` enabled by default
authorTaylor Blau <me@ttaylorr.com>
Tue, 18 Apr 2023 20:40:57 +0000 (16:40 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Apr 2023 21:56:48 +0000 (14:56 -0700)
Back in 5b92477f89 (builtin/gc.c: conditionally avoid pruning objects
via loose, 2022-05-20), `git gc` learned the `--cruft` option and
`gc.cruftPacks` configuration to opt-in to writing cruft packs when
collecting or pruning unreachable objects.

Cruft packs were introduced with the merge in a50036da1a (Merge branch
'tb/cruft-packs', 2022-06-03). They address the problem of "loose object
explosions", where Git will write out many individual loose objects when
there is a large number of unreachable objects that have not yet aged
past `--prune=<date>`.

Instead of keeping track of those unreachable yet recent objects via
their loose object file's mtime, cruft packs collect all unreachable
objects into a single pack with a corresponding `*.mtimes` file that
acts as a table to store the mtimes of all unreachable objects. This
prevents the need to store unreachable objects as loose as they age out
of the repository, and avoids the problem of loose object explosions.

Beyond avoiding loose object explosions, cruft packs also act as a more
efficient mechanism to store unreachable objects as they age out of a
repository. This is because pairs of similar unreachable objects serve
as delta bases for one another.

In 5b92477f89, the feature was introduced as experimental. Since then,
GitHub has been running these patches in every repository generating
hundreds of millions of cruft packs along the way. The feature is
battle-tested, and avoids many pathological cases such as above. Users
who either run `git gc` manually, or via `git maintenance` can benefit
from having cruft packs.

As such, enable cruft pack generation to take place by default (by
making `gc.cruftPacks` have the default of "true" rather than "false).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/feature.txt
Documentation/config/gc.txt
Documentation/git-gc.txt
Documentation/gitformat-pack.txt
builtin/gc.c
t/t6500-gc.sh

index e52bc6b858470c60f09f52d4f9d2b9f17135483c..17b4d39f894c12a32da93f69006b59b2434f0775 100644 (file)
@@ -14,9 +14,6 @@ feature.experimental::
 +
 * `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
 skipping more commits at a time, reducing the number of round trips.
-+
-* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
-garbage collection, preventing loose object explosions.
 
 feature.manyFiles::
        Enable config options that optimize for repos with many files in the
index 8d5353e9e00eeaf21499b8bce70039f0ffdc3d9f..7f95c866e1dee036adaeb94f68a5286bad669652 100644 (file)
@@ -84,7 +84,7 @@ gc.packRefs::
 gc.cruftPacks::
        Store unreachable objects in a cruft pack (see
        linkgit:git-repack[1]) instead of as loose objects. The default
-       is `false`.
+       is `true`.
 
 gc.pruneExpire::
        When 'git gc' is run, it will call 'prune --expire 2.weeks.ago'
index fef382a70fa693e2cd524ba397f912276e8c4c1f..90806fd26aa4ac0d1fef93d25384af3799818896 100644 (file)
@@ -54,9 +54,10 @@ other housekeeping tasks (e.g. rerere, working trees, reflog...) will
 be performed as well.
 
 
---cruft::
+--[no-]cruft::
        When expiring unreachable objects, pack them separately into a
-       cruft pack instead of storing them as loose objects.
+       cruft pack instead of storing them as loose objects. `--cruft`
+       is on by default.
 
 --prune=<date>::
        Prune loose objects older than date (default is 2 weeks ago,
index e06af02f211e7a7a8488d1470d7f76dd58e5989c..0c1be2dbe85caf3300a314c374dd12d54b7434a7 100644 (file)
@@ -611,8 +611,8 @@ result of repeatedly resetting the objects' mtimes to the present time.
 
 If you are GC-ing repositories in a mixed version environment, consider omitting
 the `--cruft` option when using linkgit:git-repack[1] and linkgit:git-gc[1], and
-leaving the `gc.cruftPacks` configuration unset until all writers understand
-cruft packs.
+setting the `gc.cruftPacks` configuration to "false" until all writers
+understand cruft packs.
 
 === Alternatives
 
index 53ef137e1d3e33d0ea5fbcc06472699b9894816a..ece01e966f026f5e3233bb8ee51f55c77ba072a6 100644 (file)
@@ -48,7 +48,7 @@ static const char * const builtin_gc_usage[] = {
 
 static int pack_refs = 1;
 static int prune_reflogs = 1;
-static int cruft_packs = -1;
+static int cruft_packs = 1;
 static int aggressive_depth = 50;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
@@ -608,10 +608,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
        if (prune_expire && parse_expiry_date(prune_expire, &dummy))
                die(_("failed to parse prune expiry value %s"), prune_expire);
 
-       prepare_repo_settings(the_repository);
-       if (cruft_packs < 0)
-               cruft_packs = the_repository->settings.gc_cruft_packs;
-
        if (aggressive) {
                strvec_push(&repack, "-f");
                if (aggressive_depth > 0)
index 3ba2ae514037ca455911c4f123ccebd318550efd..69509d0c11db655a12fc6ed20215ed25976c46eb 100755 (executable)
@@ -216,11 +216,9 @@ assert_no_cruft_packs () {
 }
 
 for argv in \
-       "gc --cruft" \
+       "gc" \
        "-c gc.cruftPacks=true gc" \
-       "-c gc.cruftPacks=false gc --cruft" \
-       "-c feature.experimental=true gc" \
-       "-c gc.cruftPacks=true -c feature.experimental=false gc"
+       "-c gc.cruftPacks=false gc --cruft"
 do
        test_expect_success "git $argv generates a cruft pack" '
                test_when_finished "rm -fr repo" &&
@@ -244,11 +242,9 @@ do
 done
 
 for argv in \
-       "gc" \
+       "gc --no-cruft" \
        "-c gc.cruftPacks=false gc" \
-       "-c gc.cruftPacks=true gc --no-cruft" \
-       "-c feature.expiremental=true -c gc.cruftPacks=false gc" \
-       "-c feature.experimental=false gc"
+       "-c gc.cruftPacks=true gc --no-cruft"
 do
        test_expect_success "git $argv does not generate a cruft pack" '
                test_when_finished "rm -fr repo" &&