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

Re: [PATCH v2 5/5] commit-reach: stale commits may prune generation further

From
Taylor Blau <me@ttaylorr.com>
Date
Feb 3, 2021, 15:59 UTC
Message-ID
<YBrISQ/5/pJKgGGZ@nand.local>
In-Reply-To
<14f0974c987215bd36e91450c1a6ebc6d5732121.1612183647.git.gitgitgadget@gmail.com>
On Mon, Feb 01, 2021 at 12:47:27PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 9 quoted lines
> From: Derrick Stolee <dstolee@microsoft.com>
> Note that these are only modest improvements for the case where the two
> independent commits are not in the commit-graph (not until v5.10). All
> algorithms get faster as more commits are indexed, which is not a
> surprise. However, the cost of walking extra commits is more and more
> prevalent in relative terms as more commits are indexed. Finally, the
> last case allows us to jump to the minimum generation between the last
> two commits (that are actually independent) so we greatly reduce the
> cost in that case.
Very nice. The explanation and implementation makes sense to me.
Show 29 quoted lines
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
>  commit-reach.c | 28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/commit-reach.c b/commit-reach.c
> index d3a6e2bdd04..c2e0747fea4 100644
> --- a/commit-reach.c
> +++ b/commit-reach.c
> @@ -237,15 +237,27 @@ static int remove_redundant_with_gen(struct repository *r,
>  {
>  	int i, count_non_stale = 0, count_still_independent = cnt;
>  	timestamp_t min_generation = GENERATION_NUMBER_INFINITY;
> -	struct commit **walk_start;
> +	struct commit **walk_start, **sorted;
>  	size_t walk_start_nr = 0, walk_start_alloc = cnt;
> +	int min_gen_pos = 0;
> +
> +	/*
> +	 * Sort the input by generation number, ascending. This allows
> +	 * us to increase the "min_generation" limit when we discover
> +	 * the commit with lowest generation is STALE. The index
> +	 * min_gen_pos points to the current position within 'array'
> +	 * that is not yet known to be STALE.
> +	 */
> +	ALLOC_ARRAY(sorted, cnt);
> +	COPY_ARRAY(sorted, array, cnt);
> +	QSORT(sorted, cnt, compare_commits_by_gen);
> +	min_generation = commit_graph_generation(sorted[0]);

This line caught my eye, but we return early in commit-reach.c:reduce_heads() before even calling remove_redundant() (which itself calls remove_redundant_with_gen()), so it's always OK to assume that we have at least one element in 'array'.

This patch and the others in v2 all look good to me.

Thanks, Taylor

Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee
Message 25 of 35 in “Speed up remove_redundant()”
  1. 0/3 Speed up remove_redundant()Derrick Stolee via GitGitGadget, Jan 28, 2021
  2. 2/3 commit-reach: move compare_commits_by_genDerrick Stolee via GitGitGadget, Jan 28, 2021
  3. 1/3 commit-reach: use one walk in remove_redundant()Derrick Stolee via GitGitGadget, Jan 28, 2021
  4. Junio C HamanoJan 28, 2021
  5. René ScharfeJan 29, 2021
  6. Derrick StoleeJan 31, 2021
  7. Derrick StoleeJan 31, 2021
  8. Derrick StoleeJan 31, 2021
  9. Junio C HamanoJan 31, 2021
  10. Derrick StoleeFeb 1, 2021
  11. René ScharfeJan 29, 2021
  12. 3/3 commit-reach: use heuristic in remove_redundant()Derrick Stolee via GitGitGadget, Jan 28, 2021
  13. Junio C HamanoJan 28, 2021
  14. 0/5 Speed up remove_redundant()Derrick Stolee via GitGitGadget, Feb 1, 2021
  15. 1/5 commit-reach: reduce requirements for remove_redundant()Derrick Stolee via GitGitGadget, Feb 1, 2021
  16. Junio C HamanoFeb 1, 2021
  17. 3/5 commit-reach: move compare_commits_by_genDerrick Stolee via GitGitGadget, Feb 1, 2021
  18. 2/5 commit-reach: use one walk in remove_redundant()Derrick Stolee via GitGitGadget, Feb 1, 2021
  19. René Scharfe.Feb 1, 2021
  20. Derrick StoleeFeb 1, 2021
  21. 4/5 commit-reach: use heuristic in remove_redundant()Derrick Stolee via GitGitGadget, Feb 1, 2021
  22. Junio C HamanoFeb 1, 2021
  23. Derrick StoleeFeb 1, 2021
  24. 5/5 commit-reach: stale commits may prune generation furtherDerrick Stolee via GitGitGadget, Feb 1, 2021
  25. Taylor BlauFeb 3, 2021
  26. Derrick StoleeFeb 1, 2021
  27. Junio C HamanoFeb 18, 2021
  28. Derrick StoleeFeb 19, 2021
  29. Junio C HamanoFeb 20, 2021
  30. 0/5 Speed up remove_redundant()Derrick Stolee via GitGitGadget, Feb 19, 2021
  31. 1/5 commit-reach: reduce requirements for remove_redundant()Derrick Stolee via GitGitGadget, Feb 19, 2021
  32. 5/5 commit-reach: stale commits may prune generation furtherDerrick Stolee via GitGitGadget, Feb 19, 2021
  33. 4/5 commit-reach: use heuristic in remove_redundant()Derrick Stolee via GitGitGadget, Feb 19, 2021
  34. 3/5 commit-reach: move compare_commits_by_genDerrick Stolee via GitGitGadget, Feb 19, 2021
  35. 2/5 commit-reach: use one walk in remove_redundant()Derrick Stolee via GitGitGadget, Feb 19, 2021

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.