pack-objects: use bitfield for object_entry::depth
Because of struct packing from now on we can only handle max depth 4095 (or even lower when new booleans are added in this struct). This should be ok since long delta chain will cause significant slow down anyway. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Apr 14, 2018 at 17:35 UTC
b5c0cbd8083f71e071207fca0d5434c6db6ff6c9
5 files changed
+15
-5
Documentation/config.txt
+1
@@ -2422,6 +2422,7 @@ pack.window::
2422
pack.depth::
2423
The maximum delta depth used by linkgit:git-pack-objects[1] when no
2424
maximum depth is given on the command line. Defaults to 50.
2425
+ Maximum value is 4095.
2426
2427
pack.windowMemory::
2428
The maximum size of memory that is consumed by each thread
Documentation/git-pack-objects.txt
+3
-1
@@ -96,7 +96,9 @@ base-name::
96
it too deep affects the performance on the unpacker
97
side, because delta data needs to be applied that many
98
times to get to the necessary object.
99
- The default value for --window is 10 and --depth is 50.
99
++
100
+The default value for --window is 10 and --depth is 50. The maximum
101
+depth is 4095.
102
103
--window-memory=<n>::
104
This option provides an additional limit on top of `--window`;
Documentation/git-repack.txt
+3
-1
@@ -90,7 +90,9 @@ other objects in that pack they already have locally.
90
space. `--depth` limits the maximum delta depth; making it too deep
91
affects the performance on the unpacker side, because delta data needs
92
to be applied that many times to get to the necessary object.
93
- The default value for --window is 10 and --depth is 50.
93
++
94
+The default value for --window is 10 and --depth is 50. The maximum
95
+depth is 4095.
96
97
--threads=<n>::
98
This option is passed through to `git pack-objects`.
builtin/pack-objects.c
+6
@@ -3068,6 +3068,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3068
if (pack_to_stdout != !base_name || argc)
3069
usage_with_options(pack_usage, pack_objects_options);
3070
3071
+ if (depth >= (1 << OE_DEPTH_BITS)) {
3072
+ warning(_("delta chain depth %d is too deep, forcing %d"),
3073
+ depth, (1 << OE_DEPTH_BITS) - 1);
3074
+ depth = (1 << OE_DEPTH_BITS) - 1;
3075
+ }
3076
+
3077
argv_array_push(&rp, "pack-objects");
3078
if (thin) {
3079
use_internal_rev_list = 1;
pack-objects.h
+2
-3
@@ -2,6 +2,7 @@
2
#define PACK_OBJECTS_H
3
4
#define OE_DFS_STATE_BITS 2
5
+#define OE_DEPTH_BITS 12
6
7
/*
8
* State flags for depth-first search used for analyzing delta cycles.
@@ -89,9 +90,7 @@ struct object_entry {
90
unsigned tagged:1; /* near the very tip of refs */
91
unsigned filled:1; /* assigned write-order */
92
unsigned dfs_state:OE_DFS_STATE_BITS;
92
-
93
- int depth;
94
-
93
+ unsigned depth:OE_DEPTH_BITS;
94
};
95
96
struct packing_data {