Skip to content

Commit e3dfddb

Browse files
Martin KoeglerJunio C Hamano
authored andcommitted
builtin-pack-object: cache small deltas
Signed-off-by: Martin Koegler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 074b2ee commit e3dfddb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Documentation/config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ pack.deltaCacheSize::
572572
gitlink:git-pack-objects[1].
573573
A value of 0 means no limit. Defaults to 0.
574574

575+
pack.deltaCacheLimit::
576+
The maxium size of a delta, that is cached in
577+
gitlink:git-pack-objects[1]. Defaults to 1000.
578+
575579
pull.octopus::
576580
The default merge strategy to use when pulling multiple branches
577581
at once.

builtin-pack-objects.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static int pack_compression_seen;
7979

8080
static unsigned long delta_cache_size = 0;
8181
static unsigned long max_delta_cache_size = 0;
82+
static unsigned long cache_max_small_delta_size = 1000;
8283

8384
/*
8485
* The object names in objects array are hashed with this hashtable,
@@ -1403,6 +1404,9 @@ static int delta_cacheable(struct unpacked *trg, struct unpacked *src,
14031404
if (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)
14041405
return 0;
14051406

1407+
if (delta_size < cache_max_small_delta_size)
1408+
return 1;
1409+
14061410
/* cache delta, if objects are large enough compared to delta size */
14071411
if ((src_size >> 20) + (trg_size >> 21) > (delta_size >> 10))
14081412
return 1;
@@ -1654,6 +1658,10 @@ static int git_pack_config(const char *k, const char *v)
16541658
max_delta_cache_size = git_config_int(k, v);
16551659
return 0;
16561660
}
1661+
if (!strcmp(k, "pack.deltacachelimit")) {
1662+
cache_max_small_delta_size = git_config_int(k, v);
1663+
return 0;
1664+
}
16571665
return git_default_config(k, v);
16581666
}
16591667

0 commit comments

Comments
 (0)