Skip to content

Commit 76f14b7

Browse files
Abhra303ttaylorr
authored andcommitted
pack-bitmap-write: learn pack.writeBitmapLookupTable and add tests
Teach Git to provide a way for users to enable/disable bitmap lookup table extension by providing a config option named 'writeBitmapLookupTable'. Default is false. Also add test to verify writting of lookup table. Mentored-by: Taylor Blau <[email protected]> Co-Mentored-by: Kaartic Sivaraam <[email protected]> Co-Authored-by: Taylor Blau <[email protected]> Signed-off-by: Abhradeep Chakraborty <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 93eb41e commit 76f14b7

File tree

9 files changed

+733
-583
lines changed

9 files changed

+733
-583
lines changed

Documentation/config/pack.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ When writing a multi-pack reachability bitmap, no new namehashes are
164164
computed; instead, any namehashes stored in an existing bitmap are
165165
permuted into their appropriate location when writing a new bitmap.
166166

167+
pack.writeBitmapLookupTable::
168+
When true, Git will include a "lookup table" section in the
169+
bitmap index (if one is written). This table is used to defer
170+
loading individual bitmaps as late as possible. This can be
171+
beneficial in repositories that have relatively large bitmap
172+
indexes. Defaults to false.
173+
167174
pack.writeReverseIndex::
168175
When true, git will write a corresponding .rev file (see:
169176
link:../technical/pack-format.html[Documentation/technical/pack-format.txt])

builtin/multi-pack-index.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ static int git_multi_pack_index_write_config(const char *var, const char *value,
8787
opts.flags &= ~MIDX_WRITE_BITMAP_HASH_CACHE;
8888
}
8989

90+
if (!strcmp(var, "pack.writebitmaplookuptable")) {
91+
if (git_config_bool(var, value))
92+
opts.flags |= MIDX_WRITE_BITMAP_LOOKUP_TABLE;
93+
else
94+
opts.flags &= ~MIDX_WRITE_BITMAP_LOOKUP_TABLE;
95+
}
96+
9097
/*
9198
* We should never make a fall-back call to 'git_default_config', since
9299
* this was already called in 'cmd_multi_pack_index()'.

builtin/pack-objects.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,6 +3148,14 @@ static int git_pack_config(const char *k, const char *v, void *cb)
31483148
else
31493149
write_bitmap_options &= ~BITMAP_OPT_HASH_CACHE;
31503150
}
3151+
3152+
if (!strcmp(k, "pack.writebitmaplookuptable")) {
3153+
if (git_config_bool(k, v))
3154+
write_bitmap_options |= BITMAP_OPT_LOOKUP_TABLE;
3155+
else
3156+
write_bitmap_options &= ~BITMAP_OPT_LOOKUP_TABLE;
3157+
}
3158+
31513159
if (!strcmp(k, "pack.usebitmaps")) {
31523160
use_bitmap_index_default = git_config_bool(k, v);
31533161
return 0;

midx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,9 @@ static int write_midx_bitmap(const char *midx_name,
10701070
if (flags & MIDX_WRITE_BITMAP_HASH_CACHE)
10711071
options |= BITMAP_OPT_HASH_CACHE;
10721072

1073+
if (flags & MIDX_WRITE_BITMAP_LOOKUP_TABLE)
1074+
options |= BITMAP_OPT_LOOKUP_TABLE;
1075+
10731076
/*
10741077
* Build the MIDX-order index based on pdata.objects (which is already
10751078
* in MIDX order; c.f., 'midx_pack_order_cmp()' for the definition of

midx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct multi_pack_index {
4747
#define MIDX_WRITE_REV_INDEX (1 << 1)
4848
#define MIDX_WRITE_BITMAP (1 << 2)
4949
#define MIDX_WRITE_BITMAP_HASH_CACHE (1 << 3)
50+
#define MIDX_WRITE_BITMAP_LOOKUP_TABLE (1 << 4)
5051

5152
const unsigned char *get_midx_checksum(struct multi_pack_index *m);
5253
void get_midx_filename(struct strbuf *out, const char *object_dir);

0 commit comments

Comments
 (0)