зеркало из https://github.com/microsoft/git.git
pack-objects: shrink z_delta_size field in struct object_entry
We only cache deltas when it's smaller than a certain limit. This limit defaults to 1000 but save its compressed length in a 64-bit field. Shrink that field down to 20 bits, so you can only cache 1MB deltas. Larger deltas must be recomputed at when the pack is written down. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
898eba5e63
Коммит
0cb3c1427a
|
@ -2459,7 +2459,8 @@ pack.deltaCacheLimit::
|
||||||
The maximum size of a delta, that is cached in
|
The maximum size of a delta, that is cached in
|
||||||
linkgit:git-pack-objects[1]. This cache is used to speed up the
|
linkgit:git-pack-objects[1]. This cache is used to speed up the
|
||||||
writing object phase by not having to recompute the final delta
|
writing object phase by not having to recompute the final delta
|
||||||
result once the best match for all objects is found. Defaults to 1000.
|
result once the best match for all objects is found.
|
||||||
|
Defaults to 1000. Maximum value is 65535.
|
||||||
|
|
||||||
pack.threads::
|
pack.threads::
|
||||||
Specifies the number of threads to spawn when searching for best
|
Specifies the number of threads to spawn when searching for best
|
||||||
|
|
|
@ -2099,12 +2099,19 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
|
||||||
* between writes at that moment.
|
* between writes at that moment.
|
||||||
*/
|
*/
|
||||||
if (entry->delta_data && !pack_to_stdout) {
|
if (entry->delta_data && !pack_to_stdout) {
|
||||||
entry->z_delta_size = do_compress(&entry->delta_data,
|
unsigned long size;
|
||||||
entry->delta_size);
|
|
||||||
cache_lock();
|
size = do_compress(&entry->delta_data, entry->delta_size);
|
||||||
delta_cache_size -= entry->delta_size;
|
if (size < (1U << OE_Z_DELTA_BITS)) {
|
||||||
delta_cache_size += entry->z_delta_size;
|
entry->z_delta_size = size;
|
||||||
cache_unlock();
|
cache_lock();
|
||||||
|
delta_cache_size -= entry->delta_size;
|
||||||
|
delta_cache_size += entry->z_delta_size;
|
||||||
|
cache_unlock();
|
||||||
|
} else {
|
||||||
|
FREE_AND_NULL(entry->delta_data);
|
||||||
|
entry->z_delta_size = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we made n a delta, and if n is already at max
|
/* if we made n a delta, and if n is already at max
|
||||||
|
@ -3087,6 +3094,11 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
|
||||||
depth, (1 << OE_DEPTH_BITS) - 1);
|
depth, (1 << OE_DEPTH_BITS) - 1);
|
||||||
depth = (1 << OE_DEPTH_BITS) - 1;
|
depth = (1 << OE_DEPTH_BITS) - 1;
|
||||||
}
|
}
|
||||||
|
if (cache_max_small_delta_size >= (1U << OE_Z_DELTA_BITS)) {
|
||||||
|
warning(_("pack.deltaCacheLimit is too high, forcing %d"),
|
||||||
|
(1U << OE_Z_DELTA_BITS) - 1);
|
||||||
|
cache_max_small_delta_size = (1U << OE_Z_DELTA_BITS) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
argv_array_push(&rp, "pack-objects");
|
argv_array_push(&rp, "pack-objects");
|
||||||
if (thin) {
|
if (thin) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define OE_DFS_STATE_BITS 2
|
#define OE_DFS_STATE_BITS 2
|
||||||
#define OE_DEPTH_BITS 12
|
#define OE_DEPTH_BITS 12
|
||||||
#define OE_IN_PACK_BITS 10
|
#define OE_IN_PACK_BITS 10
|
||||||
|
#define OE_Z_DELTA_BITS 20
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* State flags for depth-first search used for analyzing delta cycles.
|
* State flags for depth-first search used for analyzing delta cycles.
|
||||||
|
@ -77,7 +78,7 @@ struct object_entry {
|
||||||
*/
|
*/
|
||||||
void *delta_data; /* cached delta (uncompressed) */
|
void *delta_data; /* cached delta (uncompressed) */
|
||||||
unsigned long delta_size; /* delta data size (uncompressed) */
|
unsigned long delta_size; /* delta data size (uncompressed) */
|
||||||
unsigned long z_delta_size; /* delta data size (compressed) */
|
unsigned z_delta_size:OE_Z_DELTA_BITS;
|
||||||
unsigned type_:TYPE_BITS;
|
unsigned type_:TYPE_BITS;
|
||||||
unsigned in_pack_type:TYPE_BITS; /* could be delta */
|
unsigned in_pack_type:TYPE_BITS; /* could be delta */
|
||||||
unsigned type_valid:1;
|
unsigned type_valid:1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче