Skip to content

Commit b5c0cbd

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c6804a commit b5c0cbd

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

Documentation/config.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,7 @@ pack.window::
24222422
pack.depth::
24232423
The maximum delta depth used by linkgit:git-pack-objects[1] when no
24242424
maximum depth is given on the command line. Defaults to 50.
2425+
Maximum value is 4095.
24252426

24262427
pack.windowMemory::
24272428
The maximum size of memory that is consumed by each thread

Documentation/git-pack-objects.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ base-name::
9696
it too deep affects the performance on the unpacker
9797
side, because delta data needs to be applied that many
9898
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.
100102

101103
--window-memory=<n>::
102104
This option provides an additional limit on top of `--window`;

Documentation/git-repack.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ other objects in that pack they already have locally.
9090
space. `--depth` limits the maximum delta depth; making it too deep
9191
affects the performance on the unpacker side, because delta data needs
9292
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.
9496

9597
--threads=<n>::
9698
This option is passed through to `git pack-objects`.

builtin/pack-objects.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
30683068
if (pack_to_stdout != !base_name || argc)
30693069
usage_with_options(pack_usage, pack_objects_options);
30703070

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+
30713077
argv_array_push(&rp, "pack-objects");
30723078
if (thin) {
30733079
use_internal_rev_list = 1;

pack-objects.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define PACK_OBJECTS_H
33

44
#define OE_DFS_STATE_BITS 2
5+
#define OE_DEPTH_BITS 12
56

67
/*
78
* State flags for depth-first search used for analyzing delta cycles.
@@ -89,9 +90,7 @@ struct object_entry {
8990
unsigned tagged:1; /* near the very tip of refs */
9091
unsigned filled:1; /* assigned write-order */
9192
unsigned dfs_state:OE_DFS_STATE_BITS;
92-
93-
int depth;
94-
93+
unsigned depth:OE_DEPTH_BITS;
9594
};
9695

9796
struct packing_data {

0 commit comments

Comments
 (0)