From: Abhradeep Chakraborty <chakrabortyabhradeep79@xxxxxxxxx> Though Git can write roaring bitmaps, there is still no way (e.g. configurations) to control the writing of roaring bitmaps. Introduce `pack.useroaringbitmap` option to control the writing of roaring bitmaps. Mentored-by: Taylor Blau <me@xxxxxxxxxxxx> Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@xxxxxxxxx> Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@xxxxxxxxx> --- builtin/multi-pack-index.c | 5 +++++ builtin/pack-objects.c | 7 ++++++- midx.c | 7 +++++++ midx.h | 1 + pack-bitmap.h | 7 +++---- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index 9b126d6ce0e..9e221dd7cc9 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -80,6 +80,11 @@ static struct option *add_common_options(struct option *prev) static int git_multi_pack_index_write_config(const char *var, const char *value, void *cb UNUSED) { + if (!strcmp(var, "pack.useroaringbitmap")) { + if (git_config_bool(var, value)) + opts.flags |= MIDX_WRITE_ROARING_BITMAP; + } + if (!strcmp(var, "pack.writebitmaphashcache")) { if (git_config_bool(var, value)) opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 3658c05cafc..439c5572c18 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -228,7 +228,7 @@ static enum { WRITE_BITMAP_QUIET, WRITE_BITMAP_TRUE, } write_bitmap_index; -static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE; +static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE | BITMAP_SET_EWAH_BITMAP; static int exclude_promisor_objects; @@ -1258,6 +1258,7 @@ static void write_pack_file(void) hash_to_hex(hash)); if (write_bitmap_index) { + bitmap_writer_init_bm_type(write_bitmap_options); bitmap_writer_set_checksum(hash); bitmap_writer_build_type_index( &to_pack, written_list, nr_written); @@ -3143,6 +3144,10 @@ static int git_pack_config(const char *k, const char *v, void *cb) cache_max_small_delta_size = git_config_int(k, v); return 0; } + if (!strcmp(k, "pack.useroaringbitmap")) { + if (git_config_bool(k, v)) + write_bitmap_options |= BITMAP_SET_ROARING_BITMAP; + } if (!strcmp(k, "pack.writebitmaphashcache")) { if (git_config_bool(k, v)) write_bitmap_options |= BITMAP_OPT_HASH_CACHE; diff --git a/midx.c b/midx.c index c27d0e5f151..b80db2239a8 100644 --- a/midx.c +++ b/midx.c @@ -1112,10 +1112,16 @@ static int write_midx_bitmap(const char *midx_name, { int ret, i; uint16_t options = 0; + unsigned version = 0; struct pack_idx_entry **index; char *bitmap_name = xstrfmt("%s-%s.bitmap", midx_name, hash_to_hex(midx_hash)); + if (flags & MIDX_WRITE_ROARING_BITMAP) + version |= BITMAP_SET_ROARING_BITMAP; + else + version |= BITMAP_SET_EWAH_BITMAP; + if (flags & MIDX_WRITE_BITMAP_HASH_CACHE) options |= BITMAP_OPT_HASH_CACHE; @@ -1131,6 +1137,7 @@ static int write_midx_bitmap(const char *midx_name, for (i = 0; i < pdata->nr_objects; i++) index[i] = &pdata->objects[i].idx; + bitmap_writer_init_bm_type(version); bitmap_writer_show_progress(flags & MIDX_PROGRESS); bitmap_writer_build_type_index(pdata, index, pdata->nr_objects); diff --git a/midx.h b/midx.h index 5578cd7b835..c0b19b93c9c 100644 --- a/midx.h +++ b/midx.h @@ -48,6 +48,7 @@ struct multi_pack_index { #define MIDX_WRITE_BITMAP (1 << 2) #define MIDX_WRITE_BITMAP_HASH_CACHE (1 << 3) #define MIDX_WRITE_BITMAP_LOOKUP_TABLE (1 << 4) +#define MIDX_WRITE_ROARING_BITMAP (1 << 5) const unsigned char *get_midx_checksum(struct multi_pack_index *m); void get_midx_filename(struct strbuf *out, const char *object_dir); diff --git a/pack-bitmap.h b/pack-bitmap.h index 7d71deca023..6103e0d57e7 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -30,9 +30,6 @@ struct bitmap_disk_header { #define NEEDS_BITMAP (1u<<22) -#define BITMAP_SET_EWAH_BITMAP 0x1 -#define BITMAP_SET_ROARING_BITMAP (1 << 1) - /* * The width in bytes of a single triplet in the lookup table * extension: @@ -44,7 +41,9 @@ struct bitmap_disk_header { enum pack_bitmap_opts { BITMAP_OPT_FULL_DAG = 0x1, - BITMAP_OPT_HASH_CACHE = 0x4, + BITMAP_SET_EWAH_BITMAP = 0x2, + BITMAP_SET_ROARING_BITMAP = 0x4, + BITMAP_OPT_HASH_CACHE = 0x8, BITMAP_OPT_LOOKUP_TABLE = 0x10, }; -- gitgitgadget