Skip to contentSkip to conversation

more miscellaneous Bloom filter improvements

PATCH Superseded Taylor Blau 7 participants 117 messages Aug 3, 2020 – Sep 6, 2020 Documentation Page 2 of 2

lore
Share & tools
lore
#113 lore raw

PATCH v4 13/14 commit-graph: rename 'split_commit_graph_opts'

In reply to Taylor Blau

In the subsequent commit, additional options will be added to the commit-graph API which have nothing to do with splitting.

Rename the 'split_commit_graph_opts' structure to the more-generic 'commit_graph_opts' to encompass both. Likewise, rename the 'flags' member to instead be 'split_flags' to clarify that it only has to do with the behavior implied by '--split'.

---
 builtin/commit-graph.c | 20 ++++++++++----------
 commit-graph.c         | 40 ++++++++++++++++++++--------------------
 commit-graph.h         |  8 ++++----
 make: *** [Makefile    |  0
 4 files changed, 34 insertions(+), 34 deletions(-)
 create mode 100644 make: *** [Makefile
builtin/commit-graph.c +10 -10
index ba5584463f..f3243bd982 100644
@@ -119,7 +119,7 @@ static int graph_verify(int argc, const char **argv)
 }
 
 extern int read_replace_refs;
-static struct split_commit_graph_opts split_opts;
+static struct commit_graph_opts write_opts;
 
 static int write_option_parse_split(const struct option *opt, const char *arg,
 				    int unset)
@@ -187,24 +187,24 @@ static int graph_write(int argc, const char **argv)
 		OPT_BOOL(0, "changed-paths", &opts.enable_changed_paths,
 			N_("enable computation for changed paths")),
 		OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
-		OPT_CALLBACK_F(0, "split", &split_opts.flags, NULL,
+		OPT_CALLBACK_F(0, "split", &write_opts.split_flags, NULL,
 			N_("allow writing an incremental commit-graph file"),
 			PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
 			write_option_parse_split),
-		OPT_INTEGER(0, "max-commits", &split_opts.max_commits,
+		OPT_INTEGER(0, "max-commits", &write_opts.max_commits,
 			N_("maximum number of commits in a non-base split commit-graph")),
-		OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple,
+		OPT_INTEGER(0, "size-multiple", &write_opts.size_multiple,
 			N_("maximum ratio between two levels of a split commit-graph")),
-		OPT_EXPIRY_DATE(0, "expire-time", &split_opts.expire_time,
+		OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time,
 			N_("only expire files older than a given date-time")),
 		OPT_END(),
 	};
 
 	opts.progress = isatty(2);
 	opts.enable_changed_paths = -1;
-	split_opts.size_multiple = 2;
-	split_opts.max_commits = 0;
-	split_opts.expire_time = 0;
+	write_opts.size_multiple = 2;
+	write_opts.max_commits = 0;
+	write_opts.expire_time = 0;
 
 	trace2_cmd_mode("write");
 
@@ -232,7 +232,7 @@ static int graph_write(int argc, const char **argv)
 	odb = find_odb(the_repository, opts.obj_dir);
 
 	if (opts.reachable) {
-		if (write_commit_graph_reachable(odb, flags, &split_opts))
+		if (write_commit_graph_reachable(odb, flags, &write_opts))
 			return 1;
 		return 0;
 	}
@@ -261,7 +261,7 @@ static int graph_write(int argc, const char **argv)
 			       opts.stdin_packs ? &pack_indexes : NULL,
 			       opts.stdin_commits ? &commits : NULL,
 			       flags,
-			       &split_opts))
+			       &write_opts))
 		result = 1;
 
 cleanup:
commit-graph.c +20 -20
index 68ffa6ec35..33fcf01a7a 100644
@@ -1012,7 +1012,7 @@ struct write_commit_graph_context {
 		 changed_paths:1,
 		 order_by_pack:1;
 
-	const struct split_commit_graph_opts *split_opts;
+	const struct commit_graph_opts *opts;
 	size_t total_bloom_filter_data_size;
 	const struct bloom_filter_settings *bloom_settings;
 
@@ -1353,8 +1353,8 @@ static void close_reachable(struct write_commit_graph_context *ctx)
 {
 	int i;
 	struct commit *commit;
-	enum commit_graph_split_flags flags = ctx->split_opts ?
-		ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
+	enum commit_graph_split_flags flags = ctx->opts ?
+		ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
 
 	if (ctx->report_progress)
 		ctx->progress = start_delayed_progress(
@@ -1554,7 +1554,7 @@ static int add_ref_to_set(const char *refname,
 
 int write_commit_graph_reachable(struct object_directory *odb,
 				 enum commit_graph_write_flags flags,
-				 const struct split_commit_graph_opts *split_opts)
+				 const struct commit_graph_opts *opts)
 {
 	struct oidset commits = OIDSET_INIT;
 	struct refs_cb_data data;
@@ -1571,7 +1571,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
 	stop_progress(&data.progress);
 
 	result = write_commit_graph(odb, NULL, &commits,
-				    flags, split_opts);
+				    flags, opts);
 
 	oidset_clear(&commits);
 	return result;
@@ -1686,8 +1686,8 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
 static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
 {
 	uint32_t i;
-	enum commit_graph_split_flags flags = ctx->split_opts ?
-		ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
+	enum commit_graph_split_flags flags = ctx->opts ?
+		ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
 
 	ctx->num_extra_edges = 0;
 	if (ctx->report_progress)
@@ -1973,13 +1973,13 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
 	int max_commits = 0;
 	int size_mult = 2;
 
-	if (ctx->split_opts) {
-		max_commits = ctx->split_opts->max_commits;
+	if (ctx->opts) {
+		max_commits = ctx->opts->max_commits;
 
-		if (ctx->split_opts->size_multiple)
-			size_mult = ctx->split_opts->size_multiple;
+		if (ctx->opts->size_multiple)
+			size_mult = ctx->opts->size_multiple;
 
-		flags = ctx->split_opts->flags;
+		flags = ctx->opts->split_flags;
 	}
 
 	g = ctx->r->objects->commit_graph;
@@ -2157,8 +2157,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 	size_t dirnamelen;
 	timestamp_t expire_time = time(NULL);
 
-	if (ctx->split_opts && ctx->split_opts->expire_time)
-		expire_time = ctx->split_opts->expire_time;
+	if (ctx->opts && ctx->opts->expire_time)
+		expire_time = ctx->opts->expire_time;
 	if (!ctx->split) {
 		char *chain_file_name = get_chain_filename(ctx->odb);
 		unlink(chain_file_name);
@@ -2209,7 +2209,7 @@ int write_commit_graph(struct object_directory *odb,
 		       struct string_list *pack_indexes,
 		       struct oidset *commits,
 		       enum commit_graph_write_flags flags,
-		       const struct split_commit_graph_opts *split_opts)
+		       const struct commit_graph_opts *opts)
 {
 	struct write_commit_graph_context *ctx;
 	uint32_t i, count_distinct = 0;
@@ -2226,7 +2226,7 @@ int write_commit_graph(struct object_directory *odb,
 	ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
 	ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
 	ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
-	ctx->split_opts = split_opts;
+	ctx->opts = opts;
 	ctx->total_bloom_filter_data_size = 0;
 
 	bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
@@ -2274,15 +2274,15 @@ int write_commit_graph(struct object_directory *odb,
 			}
 		}
 
-		if (ctx->split_opts)
-			replace = ctx->split_opts->flags & COMMIT_GRAPH_SPLIT_REPLACE;
+		if (ctx->opts)
+			replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
 	}
 
 	ctx->approx_nr_objects = approximate_object_count();
 	ctx->oids.alloc = ctx->approx_nr_objects / 32;
 
-	if (ctx->split && split_opts && ctx->oids.alloc > split_opts->max_commits)
-		ctx->oids.alloc = split_opts->max_commits;
+	if (ctx->split && opts && ctx->oids.alloc > opts->max_commits)
+		ctx->oids.alloc = opts->max_commits;
 
 	if (ctx->append) {
 		prepare_commit_graph_one(ctx->r, ctx->odb);
commit-graph.h +4 -4
index 9afb1477d5..fe798a4047 100644
@@ -115,11 +115,11 @@ enum commit_graph_split_flags {
 	COMMIT_GRAPH_SPLIT_REPLACE          = 2
 };
 
-struct split_commit_graph_opts {
+struct commit_graph_opts {
 	int size_multiple;
 	int max_commits;
 	timestamp_t expire_time;
-	enum commit_graph_split_flags flags;
+	enum commit_graph_split_flags split_flags;
 };
 
 /*
@@ -130,12 +130,12 @@ struct split_commit_graph_opts {
  */
 int write_commit_graph_reachable(struct object_directory *odb,
 				 enum commit_graph_write_flags flags,
-				 const struct split_commit_graph_opts *split_opts);
+				 const struct commit_graph_opts *opts);
 int write_commit_graph(struct object_directory *odb,
 		       struct string_list *pack_indexes,
 		       struct oidset *commits,
 		       enum commit_graph_write_flags flags,
-		       const struct split_commit_graph_opts *split_opts);
+		       const struct commit_graph_opts *opts);
 
 #define COMMIT_GRAPH_VERIFY_SHALLOW	(1 << 0)
 
make: *** [Makefile new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.27.0.2918.gc99a27ff8f
#115 lore raw

PATCH v4 14/14 builtin/commit-graph.c: introduce '--max-new-filters=<n>'

In reply to Taylor Blau

Introduce a command-line flag and configuration variable to fill in the 'max_new_filters' variable introduced two patches ago.

The command-line option '--max-new-filters' takes precedence over 'commitGraph.maxNewFilters', which is the default value. '--no-max-new-filters' can also be provided, which sets the value back to '-1', indicating that an unlimited number of new Bloom filters may be generated. (OPT_INTEGER only allows setting the '--no-' variant back to '0', hence a custom callback was used instead).

---
 Documentation/config/commitgraph.txt |  4 +++
 Documentation/git-commit-graph.txt   |  6 ++++
 bloom.c                              | 13 +++++---
 builtin/commit-graph.c               | 39 ++++++++++++++++++++++--
 commit-graph.c                       | 27 ++++++++++++++---
 commit-graph.h                       |  4 ++-
 t/t4216-log-bloom.sh                 | 44 ++++++++++++++++++++++++++++
 7 files changed, 125 insertions(+), 12 deletions(-)
Documentation/config/commitgraph.txt +4 -0
index cff0797b54..4582c39fc4 100644
@@ -1,3 +1,7 @@
+commitGraph.maxNewFilters::
+	Specifies the default value for the `--max-new-filters` option of `git
+	commit-graph write` (c.f., linkgit:git-commit-graph[1]).
+
 commitGraph.readChangedPaths::
 	If true, then git will use the changed-path Bloom filters in the
 	commit-graph file (if it exists, and they are present). Defaults to
Documentation/git-commit-graph.txt +6 -0
index 17405c73a9..81a2e65903 100644
@@ -67,6 +67,12 @@ this option is given, future commit-graph writes will automatically assume
 that this option was intended. Use `--no-changed-paths` to stop storing this
 data.
 +
+With the `--max-new-filters=<n>` option, generate at most `n` new Bloom
+filters (if `--changed-paths` is specified). If `n` is `-1`, no limit is
+enforced. Commits whose filters are not calculated are stored as a
+length zero Bloom filter, and their bit is marked in the `BFXL` chunk.
+Overrides the `commitGraph.maxNewFilters` configuration.
++
 With the `--split[=<strategy>]` option, write the commit-graph as a
 chain of multiple commit-graph files stored in
 `<dir>/info/commit-graphs`. Commit-graph layers are merged based on the
bloom.c +9 -4
index ed54e96e57..34503898ac 100644
@@ -197,16 +197,21 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
 
 	if (!filter->data) {
 		load_commit_graph_info(r, c);
-		if (commit_graph_position(c) != COMMIT_NOT_FROM_GRAPH &&
-			load_bloom_filter_from_graph(r->objects->commit_graph, filter, c))
-				return filter;
+		if (commit_graph_position(c) != COMMIT_NOT_FROM_GRAPH)
+			load_bloom_filter_from_graph(r->objects->commit_graph, filter, c);
 	}
 
-	if (filter->data)
+	if (filter->data && filter->len)
 		return filter;
 	if (!compute_if_not_present)
 		return NULL;
 
+	if (filter && !filter->len &&
+	    get_bloom_filter_large_in_graph(r->objects->commit_graph, c,
+					    settings->max_changed_paths))
+		return filter;
+
+
 	repo_diff_setup(r, &diffopt);
 	diffopt.flags.recursive = 1;
 	diffopt.detect_rename = 0;
builtin/commit-graph.c +36 -3
index f3243bd982..e7a1539b08 100644
@@ -13,7 +13,8 @@ static char const * const builtin_commit_graph_usage[] = {
 	N_("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]"),
 	N_("git commit-graph write [--object-dir <objdir>] [--append] "
 	   "[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
-	   "[--changed-paths] [--[no-]progress] <split options>"),
+	   "[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress] "
+	   "<split options>"),
 	NULL
 };
 
@@ -25,7 +26,8 @@ static const char * const builtin_commit_graph_verify_usage[] = {
 static const char * const builtin_commit_graph_write_usage[] = {
 	N_("git commit-graph write [--object-dir <objdir>] [--append] "
 	   "[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
-	   "[--changed-paths] [--[no-]progress] <split options>"),
+	   "[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress] "
+	   "<split options>"),
 	NULL
 };
 
@@ -162,6 +164,23 @@ static int read_one_commit(struct oidset *commits, struct progress *progress,
 	return 0;
 }
 
+static int write_option_max_new_filters(const struct option *opt,
+					const char *arg,
+					int unset)
+{
+	int *to = opt->value;
+	if (unset)
+		*to = -1;
+	else {
+		const char *s;
+		*to = strtol(arg, (char **)&s, 10);
+		if (*s)
+			return error(_("%s expects a numerical value"),
+				     optname(opt, opt->flags));
+	}
+	return 0;
+}
+
 static int graph_write(int argc, const char **argv)
 {
 	struct string_list pack_indexes = STRING_LIST_INIT_NODUP;
@@ -197,6 +216,9 @@ static int graph_write(int argc, const char **argv)
 			N_("maximum ratio between two levels of a split commit-graph")),
 		OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time,
 			N_("only expire files older than a given date-time")),
+		OPT_CALLBACK_F(0, "max-new-filters", &write_opts.max_new_filters,
+			NULL, N_("maximum number of changed-path Bloom filters to compute"),
+			0, write_option_max_new_filters),
 		OPT_END(),
 	};
 
@@ -205,6 +227,7 @@ static int graph_write(int argc, const char **argv)
 	write_opts.size_multiple = 2;
 	write_opts.max_commits = 0;
 	write_opts.expire_time = 0;
+	write_opts.max_new_filters = -1;
 
 	trace2_cmd_mode("write");
 
@@ -270,6 +293,16 @@ static int graph_write(int argc, const char **argv)
 	return result;
 }
 
+static int git_commit_graph_config(const char *var, const char *value, void *cb)
+{
+	if (!strcmp(var, "commitgraph.maxnewfilters")) {
+		write_opts.max_new_filters = git_config_int(var, value);
+		return 0;
+	}
+
+	return git_default_config(var, value, cb);
+}
+
 int cmd_commit_graph(int argc, const char **argv, const char *prefix)
 {
 	static struct option builtin_commit_graph_options[] = {
@@ -283,7 +316,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
 		usage_with_options(builtin_commit_graph_usage,
 				   builtin_commit_graph_options);
 
-	git_config(git_default_config, NULL);
+	git_config(git_commit_graph_config, &opts);
 	argc = parse_options(argc, argv, prefix,
 			     builtin_commit_graph_options,
 			     builtin_commit_graph_usage,
commit-graph.c +23 -4
index 33fcf01a7a..243c7253ff 100644
@@ -953,7 +953,8 @@ struct tree *get_commit_tree_in_graph(struct repository *r, const struct commit
 }
 
 int get_bloom_filter_large_in_graph(struct commit_graph *g,
-				    const struct commit *c)
+				    const struct commit *c,
+				    uint32_t max_changed_paths)
 {
 	uint32_t graph_pos;
 	if (!find_commit_in_graph(c, g, &graph_pos))
@@ -976,6 +977,17 @@ int get_bloom_filter_large_in_graph(struct commit_graph *g,
 
 	if (!g->bloom_large)
 		return 0;
+	if (g->bloom_filter_settings->max_changed_paths != max_changed_paths) {
+		/*
+		 * Force all commits which are subject to a different
+		 * 'max_changed_paths' limit to be recomputed from scratch.
+		 *
+		 * Note that this could likely be improved, but is ignored since
+		 * all real-world graphs set the maximum number of changed paths
+		 * at 512.
+		 */
+		return 0;
+	}
 	return bitmap_get(g->bloom_large, graph_pos - g->num_commits_in_base);
 }
 
@@ -1481,6 +1493,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
 	int i;
 	struct progress *progress = NULL;
 	int *sorted_commits;
+	int max_new_filters;
 
 	init_bloom_filters();
 	ctx->bloom_large = bitmap_word_alloc(ctx->commits.nr / BITS_IN_EWORD + 1);
@@ -1497,10 +1510,15 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
 		ctx->order_by_pack ? commit_pos_cmp : commit_gen_cmp,
 		&ctx->commits);
 
+	max_new_filters = ctx->opts && ctx->opts->max_new_filters >= 0 ?
+		ctx->opts->max_new_filters : ctx->commits.nr;
+
 	for (i = 0; i < ctx->commits.nr; i++) {
 		int pos = sorted_commits[i];
 		struct commit *c = ctx->commits.list[pos];
-		if (get_bloom_filter_large_in_graph(ctx->r->objects->commit_graph, c)) {
+		if (get_bloom_filter_large_in_graph(ctx->r->objects->commit_graph,
+						    c,
+						    ctx->bloom_settings->max_changed_paths)) {
 			bitmap_set(ctx->bloom_large, pos);
 			ctx->count_bloom_filter_known_large++;
 		} else {
@@ -1508,7 +1526,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
 			struct bloom_filter *filter = get_or_compute_bloom_filter(
 				ctx->r,
 				c,
-				1,
+				ctx->count_bloom_filter_computed < max_new_filters,
 				ctx->bloom_settings,
 				&computed);
 			if (computed) {
@@ -1518,7 +1536,8 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
 					ctx->count_bloom_filter_found_large++;
 				}
 			}
-			ctx->total_bloom_filter_data_size += sizeof(unsigned char) * filter->len;
+			if (filter)
+				ctx->total_bloom_filter_data_size += sizeof(unsigned char) * filter->len;
 		}
 		display_progress(progress, i + 1);
 	}
commit-graph.h +3 -1
index fe798a4047..eac4efc7a6 100644
@@ -52,7 +52,8 @@ struct tree *get_commit_tree_in_graph(struct repository *r,
 				      const struct commit *c);
 
 int get_bloom_filter_large_in_graph(struct commit_graph *g,
-				    const struct commit *c);
+				    const struct commit *c,
+				    uint32_t max_changed_paths);
 
 struct commit_graph {
 	const unsigned char *data;
@@ -120,6 +121,7 @@ struct commit_graph_opts {
 	int max_commits;
 	timestamp_t expire_time;
 	enum commit_graph_split_flags split_flags;
+	int max_new_filters;
 };
 
 /*
t/t4216-log-bloom.sh +44 -0

48 lines not on this page · raw message

Signature · 1 line
2.27.0.2918.gc99a27ff8f
#83 lore raw

Re: [PATCH v3 14/14] builtin/commit-graph.c: introduce '--max-new-filters=<n>'

In reply to Taylor Blau
Quoted 16 lines · Taylor Blau
Quoted 11 lines · SZEDER Gábor
Quoted 9 lines · Taylor Blau

Introduce a command-line flag and configuration variable to fill in the 'max_new_filters' variable introduced by the previous patch.

The command-line option '--max-new-filters' takes precedence over 'commitGraph.maxNewFilters', which is the default value. '--no-max-new-filters' can also be provided, which sets the value back to '-1', indicating that an unlimited number of new Bloom filters may be generated. (OPT_INTEGER only allows setting the '--no-' variant back to '0', hence a custom callback was used instead).

Quoted 3 lines

Forgot the most important thing: Why? Please explain in the commit message why this option is necesary, what problems does it solve, how it is supposed to interact with other options and why so.

Quoted 5 lines

This is already explained in detail in the patch 'commit-graph: add large-filters bitmap chunk', although there is an error in the quoted part of your email (which I wrote) which refers the reader to the previous patch. The patch I'm actually referring two is the twice-previous patch.

The proposed log message of that patch only briefly mentions what this option will do, and goes into detail about what problems it _causes_ and how that new chunk is supposed to solve _those_ problems. It does not explain what problems this new option is supposed to solve, and why would anyone want to use this option.

Quoted 4 lines

I'll fix that locally before re-sending.

Thanks,
Taylor

#116 lore raw
In reply to Taylor Blau
Quoted 2 lines · Taylor Blau

Things seem to have settled down since the review in v3, so I'm hoping that this is what will end up being queued.

I haven't paid close attention to this topic, but I took a close look at v4 and found nothing to improve. I'm happy with this version.

Thanks,
-Stolee

#114 lore raw

Re: [PATCH v4 13/14] commit-graph: rename 'split_commit_graph_opts'

In reply to Taylor Blau
Quoted 2 lines · Taylor Blau

In the subsequent commit, additional options will be added to the commit-graph API which have nothing to do with splitting.

I have no idea how 'make *** [Makefile' snuck into this, but it definitely shouldn't be there. Let's use the below version instead.

--- >8 ---

Subject: [PATCH] commit-graph: rename 'split_commit_graph_opts'

In the subsequent commit, additional options will be added to the commit-graph API which have nothing to do with splitting.

Rename the 'split_commit_graph_opts' structure to the more-generic 'commit_graph_opts' to encompass both. Likewise, rename the 'flags' member to instead be 'split_flags' to clarify that it only has to do with the behavior implied by '--split'.

---
 builtin/commit-graph.c | 20 ++++++++++----------
 commit-graph.c         | 40 ++++++++++++++++++++--------------------
 commit-graph.h         |  8 ++++----
 3 files changed, 34 insertions(+), 34 deletions(-)
builtin/commit-graph.c +10 -10
index ba5584463f..f3243bd982 100644
@@ -119,7 +119,7 @@ static int graph_verify(int argc, const char **argv)
 }
 
 extern int read_replace_refs;
-static struct split_commit_graph_opts split_opts;
+static struct commit_graph_opts write_opts;
 
 static int write_option_parse_split(const struct option *opt, const char *arg,
 				    int unset)
@@ -187,24 +187,24 @@ static int graph_write(int argc, const char **argv)
 		OPT_BOOL(0, "changed-paths", &opts.enable_changed_paths,
 			N_("enable computation for changed paths")),
 		OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
-		OPT_CALLBACK_F(0, "split", &split_opts.flags, NULL,
+		OPT_CALLBACK_F(0, "split", &write_opts.split_flags, NULL,
 			N_("allow writing an incremental commit-graph file"),
 			PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
 			write_option_parse_split),
-		OPT_INTEGER(0, "max-commits", &split_opts.max_commits,
+		OPT_INTEGER(0, "max-commits", &write_opts.max_commits,
 			N_("maximum number of commits in a non-base split commit-graph")),
-		OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple,
+		OPT_INTEGER(0, "size-multiple", &write_opts.size_multiple,
 			N_("maximum ratio between two levels of a split commit-graph")),
-		OPT_EXPIRY_DATE(0, "expire-time", &split_opts.expire_time,
+		OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time,
 			N_("only expire files older than a given date-time")),
 		OPT_END(),
 	};
 
 	opts.progress = isatty(2);
 	opts.enable_changed_paths = -1;
-	split_opts.size_multiple = 2;
-	split_opts.max_commits = 0;
-	split_opts.expire_time = 0;
+	write_opts.size_multiple = 2;
+	write_opts.max_commits = 0;
+	write_opts.expire_time = 0;
 
 	trace2_cmd_mode("write");
 
@@ -232,7 +232,7 @@ static int graph_write(int argc, const char **argv)
 	odb = find_odb(the_repository, opts.obj_dir);
 
 	if (opts.reachable) {
-		if (write_commit_graph_reachable(odb, flags, &split_opts))
+		if (write_commit_graph_reachable(odb, flags, &write_opts))
 			return 1;
 		return 0;
 	}
@@ -261,7 +261,7 @@ static int graph_write(int argc, const char **argv)
 			       opts.stdin_packs ? &pack_indexes : NULL,
 			       opts.stdin_commits ? &commits : NULL,
 			       flags,
-			       &split_opts))
+			       &write_opts))
 		result = 1;
 
 cleanup:
commit-graph.c +20 -20
index 68ffa6ec35..33fcf01a7a 100644
@@ -1012,7 +1012,7 @@ struct write_commit_graph_context {
 		 changed_paths:1,
 		 order_by_pack:1;
 
-	const struct split_commit_graph_opts *split_opts;
+	const struct commit_graph_opts *opts;
 	size_t total_bloom_filter_data_size;
 	const struct bloom_filter_settings *bloom_settings;
 
@@ -1353,8 +1353,8 @@ static void close_reachable(struct write_commit_graph_context *ctx)
 {
 	int i;
 	struct commit *commit;
-	enum commit_graph_split_flags flags = ctx->split_opts ?
-		ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
+	enum commit_graph_split_flags flags = ctx->opts ?
+		ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
 
 	if (ctx->report_progress)
 		ctx->progress = start_delayed_progress(
@@ -1554,7 +1554,7 @@ static int add_ref_to_set(const char *refname,
 
 int write_commit_graph_reachable(struct object_directory *odb,
 				 enum commit_graph_write_flags flags,
-				 const struct split_commit_graph_opts *split_opts)
+				 const struct commit_graph_opts *opts)
 {
 	struct oidset commits = OIDSET_INIT;
 	struct refs_cb_data data;
@@ -1571,7 +1571,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
 	stop_progress(&data.progress);
 
 	result = write_commit_graph(odb, NULL, &commits,
-				    flags, split_opts);
+				    flags, opts);
 
 	oidset_clear(&commits);
 	return result;
@@ -1686,8 +1686,8 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
 static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
 {
 	uint32_t i;
-	enum commit_graph_split_flags flags = ctx->split_opts ?
-		ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
+	enum commit_graph_split_flags flags = ctx->opts ?
+		ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
 
 	ctx->num_extra_edges = 0;
 	if (ctx->report_progress)
@@ -1973,13 +1973,13 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
 	int max_commits = 0;
 	int size_mult = 2;
 
-	if (ctx->split_opts) {
-		max_commits = ctx->split_opts->max_commits;
+	if (ctx->opts) {
+		max_commits = ctx->opts->max_commits;
 
-		if (ctx->split_opts->size_multiple)
-			size_mult = ctx->split_opts->size_multiple;
+		if (ctx->opts->size_multiple)
+			size_mult = ctx->opts->size_multiple;
 
-		flags = ctx->split_opts->flags;
+		flags = ctx->opts->split_flags;
 	}
 
 	g = ctx->r->objects->commit_graph;
@@ -2157,8 +2157,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 	size_t dirnamelen;
 	timestamp_t expire_time = time(NULL);
 
-	if (ctx->split_opts && ctx->split_opts->expire_time)
-		expire_time = ctx->split_opts->expire_time;
+	if (ctx->opts && ctx->opts->expire_time)
+		expire_time = ctx->opts->expire_time;
 	if (!ctx->split) {
 		char *chain_file_name = get_chain_filename(ctx->odb);
 		unlink(chain_file_name);
@@ -2209,7 +2209,7 @@ int write_commit_graph(struct object_directory *odb,
 		       struct string_list *pack_indexes,
 		       struct oidset *commits,
 		       enum commit_graph_write_flags flags,
-		       const struct split_commit_graph_opts *split_opts)
+		       const struct commit_graph_opts *opts)
 {
 	struct write_commit_graph_context *ctx;
 	uint32_t i, count_distinct = 0;
@@ -2226,7 +2226,7 @@ int write_commit_graph(struct object_directory *odb,
 	ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
 	ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
 	ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
-	ctx->split_opts = split_opts;
+	ctx->opts = opts;
 	ctx->total_bloom_filter_data_size = 0;
 
 	bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
@@ -2274,15 +2274,15 @@ int write_commit_graph(struct object_directory *odb,
 			}
 		}
 
-		if (ctx->split_opts)
-			replace = ctx->split_opts->flags & COMMIT_GRAPH_SPLIT_REPLACE;
+		if (ctx->opts)
+			replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
 	}
 
 	ctx->approx_nr_objects = approximate_object_count();
 	ctx->oids.alloc = ctx->approx_nr_objects / 32;
 
-	if (ctx->split && split_opts && ctx->oids.alloc > split_opts->max_commits)
-		ctx->oids.alloc = split_opts->max_commits;
+	if (ctx->split && opts && ctx->oids.alloc > opts->max_commits)
+		ctx->oids.alloc = opts->max_commits;
 
 	if (ctx->append) {
 		prepare_commit_graph_one(ctx->r, ctx->odb);
commit-graph.h +4 -4
index 9afb1477d5..fe798a4047 100644
@@ -115,11 +115,11 @@ enum commit_graph_split_flags {
 	COMMIT_GRAPH_SPLIT_REPLACE          = 2
 };
 
-struct split_commit_graph_opts {
+struct commit_graph_opts {
 	int size_multiple;
 	int max_commits;
 	timestamp_t expire_time;
-	enum commit_graph_split_flags flags;
+	enum commit_graph_split_flags split_flags;
 };
 
 /*
@@ -130,12 +130,12 @@ struct split_commit_graph_opts {
  */
 int write_commit_graph_reachable(struct object_directory *odb,
 				 enum commit_graph_write_flags flags,
-				 const struct split_commit_graph_opts *split_opts);
+				 const struct commit_graph_opts *opts);
 int write_commit_graph(struct object_directory *odb,
 		       struct string_list *pack_indexes,
 		       struct oidset *commits,
 		       enum commit_graph_write_flags flags,
-		       const struct split_commit_graph_opts *split_opts);
+		       const struct commit_graph_opts *opts);
 
 #define COMMIT_GRAPH_VERIFY_SHALLOW	(1 << 0)
 

--
2.27.0.2918.gc99a27ff8f

#110 lore raw

Re: [PATCH v4 11/14] csum-file.h: introduce 'hashwrite_be64()'

In reply to Taylor Blau

Am 04.09.20 um 00:46 schrieb Taylor Blau:

Quoted 55 lines

A small handful of writers who wish to encode 64-bit values in network order have worked around the lack of such a helper by calling the 32-bit variant twice.

The subsequent commit will add another caller who wants to write a 64-bit value. To ease their (and the existing caller's) pain, introduce a helper to do just that, and convert existing call-sites.

---
 commit-graph.c | 8 ++------
 csum-file.h    | 6 ++++++
 midx.c         | 3 +--
 3 files changed, 9 insertions(+), 8 deletions(-)
commit-graph.c +2 -6
index 35535f4192..01d791343a 100644
@@ -1791,12 +1791,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
 
 	chunk_offset = 8 + (num_chunks + 1) * GRAPH_CHUNKLOOKUP_WIDTH;
 	for (i = 0; i <= num_chunks; i++) {
-		uint32_t chunk_write[3];
-
-		chunk_write[0] = htonl(chunks[i].id);
-		chunk_write[1] = htonl(chunk_offset >> 32);
-		chunk_write[2] = htonl(chunk_offset & 0xffffffff);
-		hashwrite(f, chunk_write, 12);
+		hashwrite_be32(f, chunks[i].id);
+		hashwrite_be64(f, chunk_offset);
 
 		chunk_offset += chunks[i].size;
 	}
csum-file.h +6 -0
index f9cbd317fb..b026ec7766 100644
@@ -62,4 +62,10 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
 	hashwrite(f, &data, sizeof(data));
 }
 
+static inline void hashwrite_be64(struct hashfile *f, uint64_t data)
+{
+	hashwrite_be32(f, data >> 32);
+	hashwrite_be32(f, data & 0xffffffffUL);
+}
+
 #endif
midx.c +0 -0
index e9b2e1253a..32cc5fdc22 100644

midx.c static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off · line 793

Quoted 7 lines
midx.c +1 -2
@@ -789,8 +789,7 @@ static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off
 		if (!(offset >> 31))
 			continue;
 
-		hashwrite_be32(f, offset >> 32);
-		hashwrite_be32(f, offset & 0xffffffffUL);
+		hashwrite_be64(f, offset);
 		written += 2 * sizeof(uint32_t);

"2 * sizeof(uint32_t)" looks slightly out of sync with the hashwrite_be64() call now; "sizeof(uint64_t)" would be more fitting.

midx.c static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off · line 795

Quoted 3 lines
midx.c +0 -0
 		nr_large_offset--;
 

There's also this potential caller:

midx.c=802=static int write_midx_internal(const char *object_dir, struct multi_pack_index *m,

midx.c:981:             hashwrite_be32(f, chunk_ids[i]);
midx.c:982:             hashwrite_be32(f, chunk_offsets[i] >> 32);
midx.c:983:             hashwrite_be32(f, chunk_offsets[i]);

Not sure it's worth a reroll, though.

(I'd probably leave those conversions for a later series.)

René

#111 lore raw

Re: [PATCH v4 11/14] csum-file.h: introduce 'hashwrite_be64()'

Quoted 3 lines · René Scharfe

Am 04.09.20 um 00:46 schrieb Taylor Blau:
"2 * sizeof(uint32_t)" looks slightly out of sync with the hashwrite_be64() call now; "sizeof(uint64_t)" would be more fitting.

Yeah, agreed.

Quoted 6 lines
Quoted 3 lines

nr_large_offset--;

There's also this potential caller:

Quoted 8 lines

midx.c=802=static int write_midx_internal(const char *object_dir, struct multi_pack_index *m,

midx.c:981:             hashwrite_be32(f, chunk_ids[i]);
midx.c:982:             hashwrite_be32(f, chunk_offsets[i] >> 32);
midx.c:983:             hashwrite_be32(f, chunk_offsets[i]);

Not sure it's worth a reroll, though.

(I'd probably leave those conversions for a later series.)

Agreed. If we were earlier on, or there wasn't already a patch that I had swapped out for a manual fixup after sending this v4, I'd certainly fold these in, but I think at this point it's easier to apply this separately on top.

Thanks for pointing them out.

Quoted 1 line

René

Thanks,
Taylor

#96 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

In reply to Taylor Blau

Taylor Blau <[email protected]> writes:

[...]

Quoted 4 lines

While we're at it, instrument the new 'get_or_compute_bloom_filter()' with two counters in the 'write_commit_graph_context' struct which store the number of filters that we computed, and the number of those which were too large to store.

[...]

Quoted 6 lines
commit-graph.c +1 -0
@@ -1414,12 +1433,25 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
 		QSORT(sorted_commits, ctx->commits.nr, commit_gen_cmp);
 
 	for (i = 0; i < ctx->commits.nr; i++) {
+		int computed = 0;
 		struct commit *c = sorted_commits[i];

commit-graph.c static void compute_bloom_filters(struct write_commit_graph_context *ctx) · line 1446

Quoted 10 lines
commit-graph.c +9 -1
-		struct bloom_filter *filter = get_bloom_filter(ctx->r, c, 1);
+		struct bloom_filter *filter = get_or_compute_bloom_filter(
+			ctx->r,
+			c,
+			1,
+			&computed);
+		if (computed) {
+			ctx->count_bloom_filter_computed++;
+			if (filter && !filter->len)
+				ctx->count_bloom_filter_found_large++;

How do you distinguish between no changed paths stored because there were no changes (which should not count as *_found_large), and no changed paths stored because there were too many changes? If I remember it correctly in current implemetation both are represented as zero-length filter (no changed paths could have been represented as all zeros filter, too many changed paths could have been represented as all ones filter).

No changes to store in filter can happen not only with --allow-empty (e.g. via interactive rebase), but also with merge where all changes came from the second parent -- we are storing only changes to first parent, if I remember it correctly.

This is a minor issue, though.

commit-graph.c static void compute_bloom_filters(struct write_commit_graph_context *ctx) · line 1457

Quoted 11 lines
commit-graph.c +4 -0
+		}
 		ctx->total_bloom_filter_data_size += sizeof(unsigned char) * filter->len;
 		display_progress(progress, i + 1);
 	}
 
+	if (trace2_is_enabled())
+		trace2_bloom_filter_write_statistics(ctx);
+
 	free(sorted_commits);
 	stop_progress(&progress);
 }

Best,

Signature · 1 line
Jakub Narębski
#97 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 8 lines · Jakub Narębski

Taylor Blau <[email protected]> writes:
How do you distinguish between no changed paths stored because there were no changes (which should not count as *_found_large), and no changed paths stored because there were too many changes? If I remember it correctly in current implemetation both are represented as zero-length filter (no changed paths could have been represented as all zeros filter, too many changed paths could have been represented as all ones filter).

Right, once we get handed back a filter from 'get_or_compute_bloom_filter()', we can't distinguish between (a) a commit with too many changes to store in a single Bloom filter, and (b) a commit with no changes at all.

It's unfortunate that callers can't pick between the two, but this implementation is actually an improvement on the status-quo! Why? Because right now we'll see an "empty" Bloom filter and recompute it because it's "missing", only to discover that it has no changes.

With this patch, we'll say "this filter looks too large", and stop computing it, because we have already gone through the effort to compute it once (and marked it in the BFXL chunk).

Now, you could certainly argue that 'BFXL' could be called 'BFWC' ("Bloom filter was computed"), and then the "was this filter too large" check means that the commit was (a) marked in a BFWC chunk, and (b) has length zero. I'm not necessarily opposed, but I think that this is probably not worth it, since we're trying to disambiguate something that is inherently ambiguous. (That is, even with this new check, a length-zero would still be thought to be "too large", since it was computed, and has length 0).

Quoted 4 lines

No changes to store in filter can happen not only with --allow-empty (e.g. via interactive rebase), but also with merge where all changes came from the second parent -- we are storing only changes to first parent, if I remember it correctly.

Agreed. And yes, Bloom filters store changes only to their commit's first parent.

Quoted 1 line

This is a minor issue, though.

Thanks for raising it. I don't think that this is a show-stopper for this series.

Thanks,
Taylor

#98 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Hello,

Quoted 11 lines · Taylor Blau
Quoted 9 lines · Jakub Narębski

Taylor Blau <[email protected]> writes:

How do you distinguish between no changed paths stored because there were no changes (which should not count as *_found_large), and no changed paths stored because there were too many changes? If I remember it correctly in current implementation both are represented as zero-length filter (no changed paths could have been represented as all zeros filter, too many changed paths could have been represented as all ones filter).

Quoted 4 lines

Right, once we get handed back a filter from 'get_or_compute_bloom_filter()', we can't distinguish between (a) a commit with too many changes to store in a single Bloom filter, and (b) a commit with no changes at all.

We could change how we store either no-changes Bloom filter (as all zeros minimal size filter), or too-many-changes Bloom filter (as all ones, i.e. max unsigned value, minimal size filter). This change would not require to change any user of Bloom filter.

Quoted 8 lines

It's unfortunate that callers can't pick between the two, but this implementation is actually an improvement on the status-quo! Why? Because right now we'll see an "empty" Bloom filter and recompute it because it's "missing", only to discover that it has no changes.

With this patch, we'll say "this filter looks too large", and stop computing it, because we have already gone through the effort to compute it once (and marked it in the BFXL chunk).

Can we use this when computing trace2 values?

[...]

Quoted 4 lines
Quoted 1 line

This is a minor issue, though.

Thanks for raising it. I don't think that this is a show-stopper for this series.

I agree.

Best,

Signature · 1 line
Jakub Narębski
#99 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 8 lines · Jakub Narębski

Hello,

Quoted 4 lines · Taylor Blau

Right, once we get handed back a filter from 'get_or_compute_bloom_filter()', we can't distinguish between (a) a commit with too many changes to store in a single Bloom filter, and (b) a commit with no changes at all.

Quoted 4 lines

We could change how we store either no-changes Bloom filter (as all zeros minimal size filter), or too-many-changes Bloom filter (as all ones, i.e. max unsigned value, minimal size filter). This change would not require to change any user of Bloom filter.

I don't think that's true. Say that we changed the empty Bloom filter to be encoded as only having the most-significant bit set. First, we'd have to write a Bloom filter where we didn't have to before. But the real issue is that commit-graph files generated with new clients would suddenly be unreadable by old clients.

Quoted 11 lines
Quoted 9 lines

It's unfortunate that callers can't pick between the two, but this implementation is actually an improvement on the status-quo! Why? Because right now we'll see an "empty" Bloom filter and recompute it because it's "missing", only to discover that it has no changes.

With this patch, we'll say "this filter looks too large", and stop computing it, because we have already gone through the effort to compute it once (and marked it in the BFXL chunk).

Can we use this when computing trace2 values?

We could, but I don't think it's absolutely necessary. The test coverage in t4216 gives us enough confidence already.

Quoted 7 lines

[...]

Quoted 4 lines
Quoted 1 line

This is a minor issue, though.

Thanks for raising it. I don't think that this is a show-stopper for this series.

I agree.

Thanks for your input!

Quoted 3 lines

Best,
--
Jakub Narębski

Thanks,
Taylor

#100 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Hello,

Quoted 8 lines · Taylor Blau
Quoted 7 lines · Jakub Narębski
Quoted 5 lines · Taylor Blau

Right, once we get handed back a filter from 'get_or_compute_bloom_filter()', we can't distinguish between (a) a commit with too many changes to store in a single Bloom filter, and (b) a commit with no changes at all.

Quoted 8 lines
Quoted 4 lines

We could change how we store either no-changes Bloom filter (as all zeros minimal size filter), or too-many-changes Bloom filter (as all ones, i.e. max unsigned value, minimal size filter). This change would not require to change any user of Bloom filter.

I don't think that's true. Say that we changed the empty Bloom filter to be encoded as only having the most-significant bit set. First, we'd have to write a Bloom filter where we didn't have to before.

That's true.

Quoted 3 lines

But the real
issue is that commit-graph files generated with new clients would
suddenly be unreadable by old clients.

Actually it is, at least in the form that I have proposed. The Bloom filter which has all bits set to zero would for every possible path reply that the path is not in set. Old clients would therefore work without changes. Therefore this is good representation of no-changes Bloom filter.

The Bloom filter which has all bits set to one would for every possible path reply that the path is maybe in set. This is a good alternative representation of too-many-changes Bloom filter. Again, old clients would work without changes.

[...]

Best,

Signature · 1 line
Jakub Narębski
#101 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 11 lines · Jakub Narębski

Hello,

Quoted 2 lines · Taylor Blau

But the real issue is that commit-graph files generated with new clients would suddenly be unreadable by old clients.

Actually it is, at least in the form that I have proposed. The Bloom filter which has all bits set to zero would for every possible path reply that the path is not in set. Old clients would therefore work without changes. Therefore this is good representation of no-changes Bloom filter.

Quoted 4 lines

The Bloom filter which has all bits set to one would for every possible path reply that the path is maybe in set. This is a good alternative representation of too-many-changes Bloom filter. Again, old clients would work without changes.

That's a very interesting thought. To be honest, I'm not crazy about generating our own Bloom filters that have special meaning (i.e., that even though they are interpreted the same way as any other filter, they are specially-crafted to carry a certain meaning). Your proposal also means that commit-graph files are going to get bigger, which is something that you may or may not care about.

On the other hand, it does get rid of the BFXL chunk, which certainly isn't the most elegant thing.

I don't know. I think my biggest objection is the size: we use the BIDX chunk today to avoid having to write the length-zero Bloom filters; your scheme would force us to write every filter. On the other hand, we could continue to avoid writing length-zero filters, so long as the commit-graph indicates that it knows this optimization.

Stolee: what do you think?

Quoted 3 lines

Best,
--
Jakub Narębski

Thanks,
Taylor

#102 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 5 lines · Taylor Blau

I don't know. I think my biggest objection is the size: we use the BIDX chunk today to avoid having to write the length-zero Bloom filters; your scheme would force us to write every filter. On the other hand, we could continue to avoid writing length-zero filters, so long as the commit-graph indicates that it knows this optimization.

Thinking about it a little bit more, I'm pretty sure that this isn't as easy as it sounds. Say that we:

- continued to encode length-zero Bloom filters as equal adjacent entries in the BIDX, but reserve the length-zero filter for commits with no changed-paths, _or_ commits whose Bloom filters have not yet been computed

- write "too large" Bloom filters (i.e., commits with >= 512 changed paths in a diff to their first parent) as a non-empty Bloom filter with all bits set high.

I think we're still no better off today than before, because of the overloading in the length-zero Bloom filter. Because we would treat empty filters the same as ones that haven't been computed, we would recompute empty filters, and that would count against our '--max-new-filters' budget.

I don't see a non-convoluted way to split the overloaded length-zero case into something that is distinguishable without a format extension. By the way, I think that your idea is good, and that it would be workable without the existing structure of the BIDX chunk (which itself made sense at the time that it was written).

So, I really want your idea to work. But, I think that ultimately the BFXL chunk is a more straightforward path forward.

Thanks,
Taylor

#103 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 7 lines · Taylor Blau
Quoted 5 lines · Taylor Blau

I don't know. I think my biggest objection is the size: we use the BIDX chunk today to avoid having to write the length-zero Bloom filters; your scheme would force us to write every filter. On the other hand, we could continue to avoid writing length-zero filters, so long as the commit-graph indicates that it knows this optimization.

Quoted 7 lines

Thinking about it a little bit more, I'm pretty sure that this isn't as easy as it sounds. Say that we:

- continued to encode length-zero Bloom filters as equal adjacent entries in the BIDX, but reserve the length-zero filter for commits with no changed-paths, _or_ commits whose Bloom filters have not yet been computed

No, use zero-length filters for commits whose Bloom filters have not yet been computed, and use a one-byte all zero bits Bloom filter for commits with no modified paths.

And this is exactly what I proposed earlier.

Quoted 4 lines

- write "too large" Bloom filters (i.e., commits with >= 512 changed paths in a diff to their first parent) as a non-empty Bloom filter with all bits set high.

Quoted 8 lines

I think we're still no better off today than before, because of the overloading in the length-zero Bloom filter. Because we would treat empty filters the same as ones that haven't been computed, we would recompute empty filters, and that would count against our '--max-new-filters' budget.

I don't see a non-convoluted way to split the overloaded length-zero case into something that is distinguishable without a format extension.

See above, no format extension needed.

Quoted 10 lines

By the way, I think that your idea is good, and that it would be workable without the existing structure of the BIDX chunk (which itself made sense at the time that it was written).

So, I really want your idea to work. But, I think that ultimately the BFXL chunk is a more straightforward path forward.

Thanks,
Taylor

#104 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 16 lines · SZEDER Gábor
Quoted 7 lines · Taylor Blau
Quoted 5 lines · Taylor Blau

I don't know. I think my biggest objection is the size: we use the BIDX chunk today to avoid having to write the length-zero Bloom filters; your scheme would force us to write every filter. On the other hand, we could continue to avoid writing length-zero filters, so long as the commit-graph indicates that it knows this optimization.

Quoted 7 lines

Thinking about it a little bit more, I'm pretty sure that this isn't as easy as it sounds. Say that we:

- continued to encode length-zero Bloom filters as equal adjacent entries in the BIDX, but reserve the length-zero filter for commits with no changed-paths, _or_ commits whose Bloom filters have not yet been computed

Quoted 5 lines

No, use zero-length filters for commits whose Bloom filters have not yet been computed, and use a one-byte all zero bits Bloom filter for commits with no modified paths.

And this is exactly what I proposed earlier.

Fair enough, I bet that would work.

Junio, let's eject this series while I try to see if SZEDER's idea is workable.

Quoted 4 lines
Quoted 2 lines

I don't see a non-convoluted way to split the overloaded length-zero case into something that is distinguishable without a format extension.

See above, no format extension needed.

Where?

Thanks,
Taylor

#105 lore raw

Re: [PATCH v4 07/14] bloom: split 'get_bloom_filter()' in two

Quoted 6 lines · Taylor Blau
Quoted 1 line

And this is exactly what I proposed earlier.

Fair enough, I bet that would work.

Junio, let's eject this series while I try to see if SZEDER's idea is workable.

Thanks, I'll mark the topic as such for now.