diff mbox series

[2/8] commit-graph.c: show progress of finding reachable commits

Message ID 5bdbeaf374b6050670f800fcdd3b54ddd0750754.1588641176.git.me@ttaylorr.com (mailing list archive)
State New, archived
Headers show
Series commit-graph: drop CHECK_OIDS, peel in callers | expand

Commit Message

Taylor Blau May 5, 2020, 1:13 a.m. UTC
When 'git commit-graph write --reachable' is invoked, the commit-graph
machinery calls 'for_each_ref()' to discover the set of reachable
commits.

Right now the 'add_ref_to_set' callback is not doing anything other than
adding an OID to the set of known-reachable OIDs. In a subsequent
commit, 'add_ref_to_set' will presumptively peel references. This
operation should be fast for repositories with an up-to-date
'$GIT_DIR/packed-refs', but may be slow in the general case.

So that it doesn't appear that 'git commit-graph write' is idling with
'--reachable' in the slow case, add a progress meter to provide some
output in the meantime.

In general, we don't expect a progress meter to appear at all, since
peeling references with a 'packed-refs' file is quick. If it's slow and
we do show a progress meter, the subsequent 'fill_oids_from_commits()'
will be fast, since all of the calls to
'lookup_commit_reference_gently()' will be no-ops.

Both progress meters are delayed, so it is unlikely that more than one
will appear. In either case, this intermediate state will go away in a
handful of patches, at which point there will be at most one progress
meter.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 commit-graph.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Derrick Stolee May 5, 2020, 11:50 a.m. UTC | #1
On 5/4/2020 9:13 PM, Taylor Blau wrote:
> When 'git commit-graph write --reachable' is invoked, the commit-graph
> machinery calls 'for_each_ref()' to discover the set of reachable
> commits.
> 
> Right now the 'add_ref_to_set' callback is not doing anything other than
> adding an OID to the set of known-reachable OIDs. In a subsequent
> commit, 'add_ref_to_set' will presumptively peel references. This
> operation should be fast for repositories with an up-to-date
> '$GIT_DIR/packed-refs', but may be slow in the general case.
> 
> So that it doesn't appear that 'git commit-graph write' is idling with
> '--reachable' in the slow case, add a progress meter to provide some
> output in the meantime.
> 
> In general, we don't expect a progress meter to appear at all, since
> peeling references with a 'packed-refs' file is quick. If it's slow and
> we do show a progress meter, the subsequent 'fill_oids_from_commits()'
> will be fast, since all of the calls to
> 'lookup_commit_reference_gently()' will be no-ops.
> 
> Both progress meters are delayed, so it is unlikely that more than one
> will appear. In either case, this intermediate state will go away in a
> handful of patches, at which point there will be at most one progress
> meter.
> 
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
>  commit-graph.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/commit-graph.c b/commit-graph.c
> index 00da281f39..8f61256b0a 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -1320,6 +1320,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
>  
>  struct refs_cb_data {
>  	struct oidset *commits;
> +	struct progress *progress;
>  };
>  
>  static int add_ref_to_set(const char *refname,
> @@ -1328,6 +1329,8 @@ static int add_ref_to_set(const char *refname,
>  {
>  	struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
>  
> +	display_progress(data->progress, oidset_size(data->commits) + 1);
> +
>  	oidset_insert(data->commits, oid);
>  	return 0;
>  }
> @@ -1342,12 +1345,17 @@ int write_commit_graph_reachable(struct object_directory *odb,
>  
>  	memset(&data, 0, sizeof(data));
>  	data.commits = &commits;
> +	if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
> +		data.progress = start_delayed_progress(
> +			_("Finding reachable commits"), 0);

Is this the right phrase to use? This seems too close to the progress
indicator "Expanding reachable commits in commit graph" which is walking
commits.

An alternative could be: "Collecting referenced commits"

Outside of this string, I have no complaints. I also don't feel too
strongly about the string, either.

Thanks,
-Stolee
Taylor Blau May 5, 2020, 4:13 p.m. UTC | #2
On Tue, May 05, 2020 at 07:50:50AM -0400, Derrick Stolee wrote:
> On 5/4/2020 9:13 PM, Taylor Blau wrote:
> > When 'git commit-graph write --reachable' is invoked, the commit-graph
> > machinery calls 'for_each_ref()' to discover the set of reachable
> > commits.
> >
> > Right now the 'add_ref_to_set' callback is not doing anything other than
> > adding an OID to the set of known-reachable OIDs. In a subsequent
> > commit, 'add_ref_to_set' will presumptively peel references. This
> > operation should be fast for repositories with an up-to-date
> > '$GIT_DIR/packed-refs', but may be slow in the general case.
> >
> > So that it doesn't appear that 'git commit-graph write' is idling with
> > '--reachable' in the slow case, add a progress meter to provide some
> > output in the meantime.
> >
> > In general, we don't expect a progress meter to appear at all, since
> > peeling references with a 'packed-refs' file is quick. If it's slow and
> > we do show a progress meter, the subsequent 'fill_oids_from_commits()'
> > will be fast, since all of the calls to
> > 'lookup_commit_reference_gently()' will be no-ops.
> >
> > Both progress meters are delayed, so it is unlikely that more than one
> > will appear. In either case, this intermediate state will go away in a
> > handful of patches, at which point there will be at most one progress
> > meter.
> >
> > Signed-off-by: Taylor Blau <me@ttaylorr.com>
> > ---
> >  commit-graph.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/commit-graph.c b/commit-graph.c
> > index 00da281f39..8f61256b0a 100644
> > --- a/commit-graph.c
> > +++ b/commit-graph.c
> > @@ -1320,6 +1320,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
> >
> >  struct refs_cb_data {
> >  	struct oidset *commits;
> > +	struct progress *progress;
> >  };
> >
> >  static int add_ref_to_set(const char *refname,
> > @@ -1328,6 +1329,8 @@ static int add_ref_to_set(const char *refname,
> >  {
> >  	struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
> >
> > +	display_progress(data->progress, oidset_size(data->commits) + 1);
> > +
> >  	oidset_insert(data->commits, oid);
> >  	return 0;
> >  }
> > @@ -1342,12 +1345,17 @@ int write_commit_graph_reachable(struct object_directory *odb,
> >
> >  	memset(&data, 0, sizeof(data));
> >  	data.commits = &commits;
> > +	if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
> > +		data.progress = start_delayed_progress(
> > +			_("Finding reachable commits"), 0);
>
> Is this the right phrase to use? This seems too close to the progress
> indicator "Expanding reachable commits in commit graph" which is walking
> commits.
>
> An alternative could be: "Collecting referenced commits"

That's a great suggestion. I'll apply that locally. For what it's worth,
I don't feel that strongly about it either, but it's not hard to change
;).

> Outside of this string, I have no complaints. I also don't feel too
> strongly about the string, either.
>
> Thanks,
> -Stolee

Thanks,
Taylor
diff mbox series

Patch

diff --git a/commit-graph.c b/commit-graph.c
index 00da281f39..8f61256b0a 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1320,6 +1320,7 @@  static void compute_bloom_filters(struct write_commit_graph_context *ctx)
 
 struct refs_cb_data {
 	struct oidset *commits;
+	struct progress *progress;
 };
 
 static int add_ref_to_set(const char *refname,
@@ -1328,6 +1329,8 @@  static int add_ref_to_set(const char *refname,
 {
 	struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
 
+	display_progress(data->progress, oidset_size(data->commits) + 1);
+
 	oidset_insert(data->commits, oid);
 	return 0;
 }
@@ -1342,12 +1345,17 @@  int write_commit_graph_reachable(struct object_directory *odb,
 
 	memset(&data, 0, sizeof(data));
 	data.commits = &commits;
+	if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
+		data.progress = start_delayed_progress(
+			_("Finding reachable commits"), 0);
 
 	for_each_ref(add_ref_to_set, &data);
 	result = write_commit_graph(odb, NULL, &commits,
 				    flags, split_opts);
 
 	oidset_clear(&commits);
+	if (data.progress)
+		stop_progress(&data.progress);
 	return result;
 }