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

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

From
Taylor Blau <me@ttaylorr.com>
Date
May 6, 2020, 00:07 UTC
Message-ID
<cb56a9a73b961c7d61b4c7dc6f49bd07f05d66e4.1588723544.git.me@ttaylorr.com>
In-Reply-To
<cover.1588723543.git.me@ttaylorr.com>

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..d0397f2a23 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(
+			_("Collecting referenced 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;
 }
 
-- 
2.26.0.113.ge9739cdccc
Previous: Taylor BlauNext: Taylor Blau
Message 30 of 59 in “commit-graph: drop CHECK_OIDS, peel in callers”
  1. 0/8 commit-graph: drop CHECK_OIDS, peel in callersTaylor Blau, May 5, 2020
  2. 1/8 commit-graph.c: extract 'refs_cb_data'Taylor Blau, May 5, 2020
  3. 2/8 commit-graph.c: show progress of finding reachable commitsTaylor Blau, May 5, 2020
  4. Derrick StoleeMay 5, 2020
  5. Taylor BlauMay 5, 2020
  6. 3/8 commit-graph.c: peel refs in 'add_ref_to_set'Taylor Blau, May 5, 2020
  7. Jeff KingMay 7, 2020
  8. Taylor BlauMay 13, 2020
  9. Jeff KingMay 13, 2020
  10. 4/8 builtin/commit-graph.c: extract 'read_one_commit()'Taylor Blau, May 5, 2020
  11. Jeff KingMay 7, 2020
  12. Taylor BlauMay 13, 2020
  13. 5/8 builtin/commit-graph.c: dereference tags in builtinTaylor Blau, May 5, 2020
  14. Derrick StoleeMay 5, 2020
  15. Taylor BlauMay 5, 2020
  16. Jeff KingMay 7, 2020
  17. 6/8 commit-graph.c: simplify 'fill_oids_from_commits'Taylor Blau, May 5, 2020
  18. Derrick StoleeMay 5, 2020
  19. Jeff KingMay 7, 2020
  20. 7/8 t5318: reorder test below 'graph_read_expect'Taylor Blau, May 5, 2020
  21. 8/8 commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flagTaylor Blau, May 5, 2020
  22. Derrick StoleeMay 5, 2020
  23. Taylor BlauMay 5, 2020
  24. Jeff KingMay 7, 2020
  25. Taylor BlauMay 13, 2020
  26. Derrick StoleeMay 5, 2020
  27. Taylor BlauMay 5, 2020
  28. 0/8 commit-graph: drop CHECK_OIDS, peel in callersTaylor Blau, May 6, 2020
  29. 1/8 commit-graph.c: extract 'refs_cb_data'Taylor Blau, May 6, 2020
  30. 2/8 commit-graph.c: show progress of finding reachable commitsTaylor Blau, May 6, 2020
  31. 3/8 commit-graph.c: peel refs in 'add_ref_to_set'Taylor Blau, May 6, 2020
  32. 4/8 builtin/commit-graph.c: extract 'read_one_commit()'Taylor Blau, May 6, 2020
  33. 5/8 builtin/commit-graph.c: dereference tags in builtinTaylor Blau, May 6, 2020
  34. 6/8 commit-graph.c: simplify 'fill_oids_from_commits'Taylor Blau, May 6, 2020
  35. 7/8 t5318: reorder test below 'graph_read_expect'Taylor Blau, May 6, 2020
  36. 8/8 commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flagTaylor Blau, May 6, 2020
  37. Jeff KingMay 7, 2020
  38. 0/8 commit-graph: drop CHECK_OIDS, peel in callersTaylor Blau, May 13, 2020
  39. 1/8 commit-graph.c: extract 'refs_cb_data'Taylor Blau, May 13, 2020
  40. 2/8 commit-graph.c: show progress of finding reachable commitsTaylor Blau, May 13, 2020
  41. 3/8 commit-graph.c: peel refs in 'add_ref_to_set'Taylor Blau, May 13, 2020
  42. 4/8 builtin/commit-graph.c: extract 'read_one_commit()'Taylor Blau, May 13, 2020
  43. Jeff KingMay 14, 2020
  44. Taylor BlauMay 14, 2020
  45. Junio C HamanoMay 14, 2020
  46. Taylor BlauMay 18, 2020
  47. 5/8 builtin/commit-graph.c: dereference tags in builtinTaylor Blau, May 13, 2020
  48. Jeff KingMay 14, 2020
  49. Taylor BlauMay 14, 2020
  50. commit-graph: fix "Collecting commits from input" progress lineSZEDER Gábor, Jul 10, 2020
  51. Taylor BlauJul 10, 2020
  52. SZEDER GáborJul 15, 2020
  53. Derrick StoleeJul 15, 2020
  54. Junio C HamanoJul 15, 2020
  55. 6/8 commit-graph.c: simplify 'fill_oids_from_commits'Taylor Blau, May 13, 2020
  56. 7/8 t5318: reorder test below 'graph_read_expect'Taylor Blau, May 13, 2020
  57. 8/8 commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flagTaylor Blau, May 13, 2020
  58. Jeff KingMay 14, 2020
  59. Jeff KingMay 14, 2020

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.