git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] roaring: introduce a new config option for roaring bitmaps

From
Abhradeep Chakraborty via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 19, 2022, 17:47 UTC
Message-ID
<683b0c625418278e4775978cb663edd03a113faa.1663609660.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1357.git.1663609659.gitgitgadget@gmail.com>
From: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>

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@ttaylorr.com>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
---
 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
Previous: Abhradeep Chakraborty via GitGitGadgetNext: Abhradeep Chakraborty via GitGitGadget
Message 3 of 25 in “[RFC] introduce Roaring bitmaps to Git”
  1. 0/5 [RFC] introduce Roaring bitmaps to GitAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  2. 1/5 reachability-bitmaps: add CRoaring library to GitAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  3. 4/5 roaring: introduce a new config option for roaring bitmapsAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  4. 2/5 roaring.[ch]: apply Git specific changes to the roaring APIAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  5. Derrick StoleeSep 19, 2022
  6. Junio C HamanoSep 19, 2022
  7. Derrick StoleeSep 20, 2022
  8. Abhradeep ChakrabortySep 20, 2022
  9. Junio C HamanoSep 21, 2022
  10. Abhradeep ChakrabortySep 20, 2022
  11. 3/5 roaring: teach Git to write roaring bitmapsAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  12. Junio C HamanoSep 30, 2022
  13. Abhradeep ChakrabortySep 30, 2022
  14. Abhradeep ChakrabortyOct 30, 2022
  15. Derrick StoleeOct 30, 2022
  16. Abhradeep ChakrabortyOct 31, 2022
  17. Junio C HamanoOct 31, 2022
  18. C99 -> C11 or C17? (was: [PATCH 3/5] roaring: teach Git to write roaring bitmaps)Ævar Arnfjörð Bjarmason, Oct 31, 2022
  19. rsbecker@nexbridge.comOct 31, 2022
  20. Abhradeep ChakrabortyNov 1, 2022
  21. 5/5 roaring: teach Git to read roaring bitmapsAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  22. Derrick StoleeSep 19, 2022
  23. Abhradeep ChakrabortySep 20, 2022
  24. Taylor BlauSep 20, 2022
  25. Abhradeep ChakrabortySep 21, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.