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

Re: [PATCH] commit-graph: don't show progress percentages while expanding reachable commits

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 22, 2019, 14:36 UTC
Message-ID
<87imwbc6x8.fsf@evledraar.gmail.com>
In-Reply-To
<87k1grc7al.fsf@evledraar.gmail.com>
On Fri, Mar 22 2019, Ævar Arnfjörð Bjarmason wrote:
Show 50 quoted lines
> On Fri, Mar 22 2019, SZEDER Gábor wrote:
>
>> On Fri, Mar 22, 2019 at 12:11:26PM +0100, Ævar Arnfjörð Bjarmason wrote:
>>>
>>> On Fri, Mar 22 2019, SZEDER Gábor wrote:
>>>
>>> > Commit 49bbc57a57 (commit-graph write: emit a percentage for all
>>> > progress, 2019-01-19) was a bit overeager when it added progress
>>> > percentages to the "Expanding reachable commits in commit graph" phase
>>> > as well, because most of the time the number of commits that phase has
>>> > to iterate over is not known in advance and grows significantly, and,
>>> > consequently, we end up with nonsensical numbers:
>>> >
>>> >   $ git commit-graph write --reachable
>>> >   Expanding reachable commits in commit graph: 138606% (824706/595), done.
>>> >   [...]
>>> >
>>> >   $ git rev-parse v5.0 | git commit-graph write --stdin-commits
>>> >   Expanding reachable commits in commit graph: 81264400% (812644/1), done.
>>> >   [...]
>>> >
>>> > Therefore, don't show progress percentages in the "Expanding reachable
>>> > commits in commit graph" phase.
>>>
>>> There's indeed a bug here as your examples show, but there *are* cases
>>> where it's correct, as the commit message for my patch on "master" shows
>>> there's cases where we correctly.
>>>
>>> So this "fixes" things by always removing the progress, why not instead
>>> pass down the state to close_reachable() about what we're walking over,
>>> so we can always show progress, or at least in some cases?
>>
>> The cases where it does display correct percentages are exceptional,
>> and doesn't worth the effort to try to find out whether ther current
>> operation happens to be such a case.
>
> It's the "write" entry point without arguments that displays the correct
> progress. So not exceptional, but yeah, it's not what we use on "gc".
>
> In any case, the problem is that sometimes we've walked the full set of
> commits already, and some other times we haven't.
>
> So in cases where we have we can show progress, and as a TODO (I think
> this came up in previous discussions), we could do better if we had a
> approximate_commit_count().
>
> In any case, the below fix seems correct to me, but I haven't poked it
> much. It *does* suffer from a theoretical race with the progress bar
> similar to d9b1b309cf ("commit-graph write: show progress for object
> search", 2019-01-19), but I work around it in the same way:

So double brainfart there, I meant "race with new objects being added/removed", but ....

Show 30 quoted lines
> diff --git a/commit-graph.c b/commit-graph.c
> index 47e9be0a3a..0fab3d8b2b 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -693,7 +693,8 @@ static void add_missing_parents(struct packed_oid_list *oids, struct commit *com
>  	}
>  }
>
> -static void close_reachable(struct packed_oid_list *oids, int report_progress)
> +static void close_reachable(struct packed_oid_list *oids, int report_progress,
> +			    uint64_t oids_count_for_progress)
>  {
>  	int i;
>  	struct commit *commit;
> @@ -717,7 +718,8 @@ static void close_reachable(struct packed_oid_list *oids, int report_progress)
>  	 */
>  	if (report_progress)
>  		progress = start_delayed_progress(
> -			_("Expanding reachable commits in commit graph"), oids->nr);
> +			_("Expanding reachable commits in commit graph"),
> +			oids_count_for_progress);
>  	for (i = 0; i < oids->nr; i++) {
>  		display_progress(progress, i + 1);
>  		commit = lookup_commit(the_repository, &oids->list[i]);
> @@ -725,6 +727,8 @@ static void close_reachable(struct packed_oid_list *oids, int report_progress)
>  		if (commit && !parse_commit(commit))
>  			add_missing_parents(oids, commit);
>  	}
> +	if (oids->nr < oids_count_for_progress)
> +		display_progress(progress, oids_count_for_progress);

...that race exists for the approximate_object_count case in d9b1b309cf because in the time between approximate_object_count() and our second walk via for_each_packed_object() the packs may have changed (e.g. concurrent "git push").

But this won't happen in this case, because we already know the commits we want to seed from, and the only thing that will "change" is that we haven't walked the parents of some of those commits when we e.g. seed from just HEAD.

But when oids_count_for_progress is >0 here we've walked all the commits we found in the relevant packs already, it's not possible that they've gained new parents in the interim, so this "oids->nr < oids_count_for_progress" case here is pointless cargo-culting.

Show 23 quoted lines
>  	stop_progress(&progress);
>
>  	if (report_progress)
> @@ -829,6 +833,7 @@ void write_commit_graph(const char *obj_dir,
>  	uint64_t progress_cnt = 0;
>  	struct strbuf progress_title = STRBUF_INIT;
>  	unsigned long approx_nr_objects;
> +	uint64_t oids_count_for_progress = 0;
>
>  	if (!commit_graph_compatible(the_repository))
>  		return;
> @@ -934,9 +939,10 @@ void write_commit_graph(const char *obj_dir,
>  		if (oids.progress_done < approx_nr_objects)
>  			display_progress(oids.progress, approx_nr_objects);
>  		stop_progress(&oids.progress);
> +		oids_count_for_progress = oids.nr;
>  	}
>
> -	close_reachable(&oids, report_progress);
> +	close_reachable(&oids, report_progress, oids_count_for_progress);
>
>  	if (report_progress)
>  		progress = start_delayed_progress(
Previous: Ævar Arnfjörð BjarmasonNext: SZEDER Gábor
Message 90 of 133 in “commit-graph: add progress output”
  1. 0/2 commit-graph: add progress outputÆvar Arnfjörð Bjarmason, Sep 4, 2018
  2. 2/2 commit-graph verify: add progress outputÆvar Arnfjörð Bjarmason, Sep 4, 2018
  3. Junio C HamanoSep 4, 2018
  4. 1/2 commit-graph write: add progress outputÆvar Arnfjörð Bjarmason, Sep 4, 2018
  5. Eric SunshineSep 4, 2018
  6. Junio C HamanoSep 4, 2018
  7. Derrick StoleeSep 5, 2018
  8. Ævar Arnfjörð BjarmasonSep 5, 2018
  9. Junio C HamanoSep 5, 2018
  10. Derrick StoleeSep 5, 2018
  11. Ævar Arnfjörð BjarmasonSep 7, 2018
  12. Ævar Arnfjörð BjarmasonSep 7, 2018
  13. Jeff KingSep 7, 2018
  14. Derrick StoleeSep 7, 2018
  15. Derrick StoleeSep 5, 2018
  16. Ævar Arnfjörð BjarmasonSep 7, 2018
  17. Derrick StoleeSep 7, 2018
  18. Derrick StoleeSep 5, 2018
  19. 0/2 commit-graph: add progress outputÆvar Arnfjörð Bjarmason, Sep 7, 2018
  20. Junio C HamanoSep 11, 2018
  21. 1/2 commit-graph write: add progress outputÆvar Arnfjörð Bjarmason, Sep 7, 2018
  22. Derrick StoleeSep 21, 2018
  23. Junio C HamanoSep 21, 2018
  24. Junio C HamanoSep 21, 2018
  25. 2/2 commit-graph verify: add progress outputÆvar Arnfjörð Bjarmason, Sep 7, 2018
  26. Duy NguyenSep 16, 2018
  27. 0/2 commit-graph: add progress outputÆvar Arnfjörð Bjarmason, Sep 17, 2018
  28. 1/2 commit-graph write: add progress outputÆvar Arnfjörð Bjarmason, Sep 17, 2018
  29. SZEDER GáborOct 10, 2018
  30. Ævar Arnfjörð BjarmasonOct 10, 2018
  31. SZEDER GáborOct 10, 2018
  32. Ævar Arnfjörð BjarmasonOct 10, 2018
  33. Ævar Arnfjörð BjarmasonOct 11, 2018
  34. SZEDER GáborOct 15, 2018
  35. Junio C HamanoOct 12, 2018
  36. Ævar Arnfjörð BjarmasonOct 12, 2018
  37. Derrick StoleeOct 12, 2018
  38. SZEDER GáborOct 15, 2018
  39. SZEDER GáborNov 19, 2018
  40. commit-graph: split up close_reachable() progress outputÆvar Arnfjörð Bjarmason, Nov 19, 2018
  41. Derrick StoleeNov 19, 2018
  42. SZEDER GáborNov 19, 2018
  43. 0/6 commit-graph write: progress output improvementsÆvar Arnfjörð Bjarmason, Nov 20, 2018
  44. 1/6 commit-graph write: rephrase confusing progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  45. 2/6 commit-graph write: add more progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  46. SZEDER GáborNov 20, 2018
  47. 0/6 commit-graph write: progress output improvementsÆvar Arnfjörð Bjarmason, Nov 20, 2018
  48. 1/6 commit-graph write: rephrase confusing progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  49. 2/6 commit-graph write: add more progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  50. SZEDER GáborNov 20, 2018
  51. 3/6 commit-graph write: show progress for object searchÆvar Arnfjörð Bjarmason, Nov 20, 2018
  52. 4/6 commit-graph write: add more describing progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  53. 5/6 commit-graph write: remove empty line for readabilityÆvar Arnfjörð Bjarmason, Nov 20, 2018
  54. 6/6 commit-graph write: add even more progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  55. SZEDER Gábor, Nov 21, 2018
  56. 1/2 commit-graph: rename 'num_extra_edges' variable to 'num_large_edges'SZEDER Gábor, Nov 21, 2018
  57. Junio C HamanoNov 21, 2018
  58. Derrick StoleeNov 21, 2018
  59. 0/2 commit-graph: minor cleanup and optimizationSZEDER Gábor, Jan 18, 2019
  60. 1/2 commit-graph: rename "large edges" to "extra edges"SZEDER Gábor, Jan 18, 2019
  61. 2/2 commit-graph: don't call write_graph_chunk_large_edges() unnecessarilySZEDER Gábor, Jan 18, 2019
  62. Martin ÅgrenJan 19, 2019
  63. Junio C HamanoJan 18, 2019
  64. 2/2 commit-graph: don't call write_graph_chunk_large_edges() unnecessarilySZEDER Gábor, Nov 21, 2018
  65. Derrick StoleeNov 21, 2018
  66. 00/10 commit-graph write: progress output improvementsÆvar Arnfjörð Bjarmason, Nov 22, 2018
  67. 00/10 commit-graph write: progress output improvementsÆvar Arnfjörð Bjarmason, Nov 22, 2018
  68. 01/10 commit-graph: rename 'num_extra_edges' variable to 'num_large_edges'Ævar Arnfjörð Bjarmason, Nov 22, 2018
  69. 0/9 commit-graph write: progress output improvementsÆvar Arnfjörð Bjarmason, Jan 16, 2019
  70. Junio C HamanoJan 19, 2019
  71. 00/10 commit-graph write: progress output improvementsÆvar Arnfjörð Bjarmason, Jan 19, 2019
  72. Derrick StoleeJan 22, 2019
  73. Junio C HamanoJan 23, 2019
  74. Junio C HamanoJan 22, 2019
  75. 01/10 commit-graph write: use pack order when finding commitsÆvar Arnfjörð Bjarmason, Jan 19, 2019
  76. 02/10 commit-graph: rename "large edges" to "extra edges"Ævar Arnfjörð Bjarmason, Jan 19, 2019
  77. 03/10 commit-graph: don't call write_graph_chunk_large_edges() unnecessarilyÆvar Arnfjörð Bjarmason, Jan 19, 2019
  78. 03/10 commit-graph: don't call write_graph_chunk_extra_edges() unnecessarilySZEDER Gábor, Jan 23, 2019
  79. 04/10 commit-graph write: add "Writing out" progress outputÆvar Arnfjörð Bjarmason, Jan 19, 2019
  80. 05/10 commit-graph write: more descriptive "writing out" outputÆvar Arnfjörð Bjarmason, Jan 19, 2019
  81. 06/10 commit-graph write: show progress for object searchÆvar Arnfjörð Bjarmason, Jan 19, 2019
  82. 08/10 commit-graph write: remove empty line for readabilityÆvar Arnfjörð Bjarmason, Jan 19, 2019
  83. 07/10 commit-graph write: add more descriptive progress outputÆvar Arnfjörð Bjarmason, Jan 19, 2019
  84. 09/10 commit-graph write: add itermediate progressÆvar Arnfjörð Bjarmason, Jan 19, 2019
  85. 10/10 commit-graph write: emit a percentage for all progressÆvar Arnfjörð Bjarmason, Jan 19, 2019
  86. commit-graph: don't show progress percentages while expanding reachable commitsSZEDER Gábor, Mar 22, 2019
  87. Ævar Arnfjörð BjarmasonMar 22, 2019
  88. SZEDER GáborMar 22, 2019
  89. Ævar Arnfjörð BjarmasonMar 22, 2019
  90. Ævar Arnfjörð BjarmasonMar 22, 2019
  91. SZEDER GáborMar 22, 2019
  92. Ævar Arnfjörð BjarmasonMar 22, 2019
  93. SZEDER GáborMar 22, 2019
  94. SZEDER GáborMar 22, 2019
  95. Ævar Arnfjörð BjarmasonMar 22, 2019
  96. 1/9 commit-graph: rename 'num_extra_edges' variable to 'num_large_edges'Ævar Arnfjörð Bjarmason, Jan 16, 2019
  97. 2/9 commit-graph: don't call write_graph_chunk_large_edges() unnecessarilyÆvar Arnfjörð Bjarmason, Jan 16, 2019
  98. 3/9 commit-graph write: add "Writing out" progress outputÆvar Arnfjörð Bjarmason, Jan 16, 2019
  99. SZEDER GáborJan 18, 2019
  100. 4/9 commit-graph write: more descriptive "writing out" outputÆvar Arnfjörð Bjarmason, Jan 16, 2019
  101. 5/9 commit-graph write: show progress for object searchÆvar Arnfjörð Bjarmason, Jan 16, 2019
  102. 6/9 commit-graph write: add more descriptive progress outputÆvar Arnfjörð Bjarmason, Jan 16, 2019
  103. 7/9 commit-graph write: remove empty line for readabilityÆvar Arnfjörð Bjarmason, Jan 16, 2019
  104. 8/9 commit-graph write: add itermediate progressÆvar Arnfjörð Bjarmason, Jan 16, 2019
  105. 9/9 commit-graph write: emit a percentage for all progressÆvar Arnfjörð Bjarmason, Jan 16, 2019
  106. commit-graph write: use pack order when finding commitsÆvar Arnfjörð Bjarmason, Jan 17, 2019
  107. Derrick StoleeJan 17, 2019
  108. Derrick StoleeJan 17, 2019
  109. 02/10 commit-graph: don't call write_graph_chunk_large_edges() unnecessarilyÆvar Arnfjörð Bjarmason, Nov 22, 2018
  110. 03/10 commit-graph write: rephrase confusing progress outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  111. 05/10 commit-graph write: more descriptive "writing out" outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  112. 04/10 commit-graph write: add "Writing out" progress outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  113. 06/10 commit-graph write: show progress for object searchÆvar Arnfjörð Bjarmason, Nov 22, 2018
  114. 07/10 commit-graph write: add more descriptive progress outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  115. 08/10 commit-graph write: remove empty line for readabilityÆvar Arnfjörð Bjarmason, Nov 22, 2018
  116. 09/10 commit-graph write: add itermediate progressÆvar Arnfjörð Bjarmason, Nov 22, 2018
  117. 10/10 commit-graph write: emit a percentage for all progressÆvar Arnfjörð Bjarmason, Nov 22, 2018
  118. Eric SunshineNov 22, 2018
  119. 01/10 commit-graph: rename 'num_extra_edges' variable to 'num_large_edges'Ævar Arnfjörð Bjarmason, Nov 22, 2018
  120. 03/10 commit-graph write: rephrase confusing progress outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  121. 02/10 commit-graph: don't call write_graph_chunk_large_edges() unnecessarilyÆvar Arnfjörð Bjarmason, Nov 22, 2018
  122. 04/10 commit-graph write: add "Writing out" progress outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  123. 05/10 commit-graph write: more descriptive "writing out" outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  124. 06/10 commit-graph write: show progress for object searchÆvar Arnfjörð Bjarmason, Nov 22, 2018
  125. 07/10 commit-graph write: add more descriptive progress outputÆvar Arnfjörð Bjarmason, Nov 22, 2018
  126. 08/10 commit-graph write: remove empty line for readabilityÆvar Arnfjörð Bjarmason, Nov 22, 2018
  127. 09/10 commit-graph write: add itermediate progressÆvar Arnfjörð Bjarmason, Nov 22, 2018
  128. 10/10 commit-graph write: emit a percentage for all progressÆvar Arnfjörð Bjarmason, Nov 22, 2018
  129. 3/6 commit-graph write: show progress for object searchÆvar Arnfjörð Bjarmason, Nov 20, 2018
  130. 4/6 commit-graph write: add more describing progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  131. 5/6 commit-graph write: remove empty line for readabilityÆvar Arnfjörð Bjarmason, Nov 20, 2018
  132. 6/6 commit-graph write: add even more progress outputÆvar Arnfjörð Bjarmason, Nov 20, 2018
  133. 2/2 commit-graph verify: add progress outputÆvar Arnfjörð Bjarmason, Sep 17, 2018

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.