config: let feature.experimental imply gc.cruftPacks=true
We are interested in exploring whether gc.cruftPacks=true should become the default value. To determine whether it is safe to do so, let's encourage more users to try it out. Users who have set feature.experimental=true have already volunteered to try new and possibly-breaking config changes, so let's try this new default with that set of users. Signed-off-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Emily Shaffer committed
Oct 26, 2022 at 17:32 UTC
c695592850a3b4b7857fc11721cbc7d2b332f41e
5 files changed
+63
-2
Documentation/config/feature.txt
+3
@@ -14,6 +14,9 @@ feature.experimental::
14
+
15
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
16
skipping more commits at a time, reducing the number of round trips.
17
++
18
+* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
19
+garbage collection, preventing loose object explosions.
20
21
feature.manyFiles::
22
Enable config options that optimize for repos with many files in the
builtin/gc.c
+5
-2
@@ -42,7 +42,7 @@ static const char * const builtin_gc_usage[] = {
42
43
static int pack_refs = 1;
44
static int prune_reflogs = 1;
45
-static int cruft_packs = 0;
45
+static int cruft_packs = -1;
46
static int aggressive_depth = 50;
47
static int aggressive_window = 250;
48
static int gc_auto_threshold = 6700;
@@ -600,6 +600,10 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
600
if (prune_expire && parse_expiry_date(prune_expire, &dummy))
601
die(_("failed to parse prune expiry value %s"), prune_expire);
602
603
+ prepare_repo_settings(the_repository);
604
+ if (cruft_packs < 0)
605
+ cruft_packs = the_repository->settings.gc_cruft_packs;
606
+
607
if (aggressive) {
608
strvec_push(&repack, "-f");
609
if (aggressive_depth > 0)
@@ -711,7 +715,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
715
clean_pack_garbage();
716
}
717
714
- prepare_repo_settings(the_repository);
718
if (the_repository->settings.gc_write_commit_graph == 1)
719
write_commit_graph_reachable(the_repository->objects->odb,
720
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
repo-settings.c
+1
@@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
43
/* Defaults modified by feature.* */
44
if (experimental) {
45
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
46
+ r->settings.gc_cruft_packs = 1;
47
}
48
if (manyfiles) {
49
r->settings.index_version = 4;
repository.h
+1
@@ -33,6 +33,7 @@ struct repo_settings {
33
int commit_graph_generation_version;
34
int commit_graph_read_changed_paths;
35
int gc_write_commit_graph;
36
+ int gc_cruft_packs;
37
int fetch_write_commit_graph;
38
int command_requires_full_index;
39
int sparse_index;
t/t6500-gc.sh
+53
@@ -221,6 +221,11 @@ assert_cruft_packs () {
221
done <packs
222
}
223
224
+assert_no_cruft_packs () {
225
+ find .git/objects/pack -name "*.mtimes" >mtimes &&
226
+ test_must_be_empty mtimes
227
+}
228
+
229
test_expect_success 'gc --cruft generates a cruft pack' '
230
test_when_finished "rm -fr crufts" &&
231
git init crufts &&
@@ -245,6 +250,54 @@ test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
250
)
251
'
252
253
+test_expect_success 'feature.experimental=true generates a cruft pack' '
254
+ git init crufts &&
255
+ test_when_finished "rm -fr crufts" &&
256
+ (
257
+ cd crufts &&
258
+
259
+ prepare_cruft_history &&
260
+ git -c feature.experimental=true gc &&
261
+ assert_cruft_packs
262
+ )
263
+'
264
+
265
+test_expect_success 'feature.experimental=false allows explicit cruft packs' '
266
+ git init crufts &&
267
+ test_when_finished "rm -fr crufts" &&
268
+ (
269
+ cd crufts &&
270
+
271
+ prepare_cruft_history &&
272
+ git -c gc.cruftPacks=true -c feature.experimental=false gc &&
273
+ assert_cruft_packs
274
+ )
275
+'
276
+
277
+test_expect_success 'feature.experimental=true can be overridden' '
278
+ git init crufts &&
279
+ test_when_finished "rm -fr crufts" &&
280
+ (
281
+ cd crufts &&
282
+
283
+ prepare_cruft_history &&
284
+ git -c feature.expiremental=true -c gc.cruftPacks=false gc &&
285
+ assert_no_cruft_packs
286
+ )
287
+'
288
+
289
+test_expect_success 'feature.experimental=false avoids cruft packs by default' '
290
+ git init crufts &&
291
+ test_when_finished "rm -fr crufts" &&
292
+ (
293
+ cd crufts &&
294
+
295
+ prepare_cruft_history &&
296
+ git -c feature.experimental=false gc &&
297
+ assert_no_cruft_packs
298
+ )
299
+'
300
+
301
run_and_wait_for_auto_gc () {
302
# We read stdout from gc for the side effect of waiting until the
303
# background gc process exits, closing its fd 9. Furthermore, the