]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: don't show progress percentages while expanding reachable commits
authorSZEDER Gábor <szeder.dev@gmail.com>
Sat, 7 Sep 2019 05:01:33 +0000 (01:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Sep 2019 17:56:43 +0000 (10:56 -0700)
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.
  [...]

Even worse, because the percentage grows so quickly, the progress code
outputs much more often than it should (because it ticks every second,
or every 1%), slowing the whole process down. My time for "git
commit-graph write --reachable" on linux.git went from 13.463s to
12.521s with this patch, ~7% savings.

Therefore, don't show progress percentages in the "Expanding reachable
commits in commit graph" phase.

Note that the current code does sometimes do the right thing, if we
picked up all commits initially (e.g., omitting "--reachable" in a
fully-packed repository would get the correct count without any parent
traversal). So it may be possible to come up with a way to tell when we
could use a percentage here. But in the meantime, let's make sure we
robustly avoid printing nonsense.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c

index fe954ab5f845e65bc5cad987308aeb6598f2fd24..6e3b9afa74588382fad7a1439588caaaf4183006 100644 (file)
@@ -1049,7 +1049,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
        if (ctx->report_progress)
                ctx->progress = start_delayed_progress(
                                        _("Expanding reachable commits in commit graph"),
-                                       ctx->oids.nr);
+                                       0);
        for (i = 0; i < ctx->oids.nr; i++) {
                display_progress(ctx->progress, i + 1);
                commit = lookup_commit(ctx->r, &ctx->oids.list[i]);