1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 20:36:09 +02:00

commit-graph write: add "Writing out" progress output

Add progress output to be shown when we're writing out the
commit-graph, this adds to the output already added in 7b0f229222
("commit-graph write: add progress output", 2018-09-17).

As noted in that commit most of the progress output isn't displayed on
small repositories, but before this change we'd noticeably hang for
2-3 seconds at the end on medium sized repositories such as linux.git.

Now we'll instead show output like this, and reduce the
human-observable times at which we're not producing progress output:

    $ ~/g/git/git --exec-path=$HOME/g/git -C ~/g/2015-04-03-1M-git commit-graph write
    Finding commits for commit graph: 13064614, done.
    Expanding reachable commits in commit graph: 1000447, done.
    Computing commit graph generation numbers: 100% (1000447/1000447), done.
    Writing out commit graph: 100% (3001341/3001341), done.

This "Writing out" number is 3x or 4x the number of commits, depending
on the graph we're processing. A later change will make this explicit
to the user.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2019-01-19 21:21:15 +01:00 committed by Junio C Hamano
parent 857ba928a4
commit 53035c4f0b

View File

@ -430,7 +430,9 @@ struct tree *get_commit_tree_in_graph(struct repository *r, const struct commit
static void write_graph_chunk_fanout(struct hashfile *f,
struct commit **commits,
int nr_commits)
int nr_commits,
struct progress *progress,
uint64_t *progress_cnt)
{
int i, count = 0;
struct commit **list = commits;
@ -444,6 +446,7 @@ static void write_graph_chunk_fanout(struct hashfile *f,
while (count < nr_commits) {
if ((*list)->object.oid.hash[0] != i)
break;
display_progress(progress, ++*progress_cnt);
count++;
list++;
}
@ -453,12 +456,16 @@ static void write_graph_chunk_fanout(struct hashfile *f,
}
static void write_graph_chunk_oids(struct hashfile *f, int hash_len,
struct commit **commits, int nr_commits)
struct commit **commits, int nr_commits,
struct progress *progress,
uint64_t *progress_cnt)
{
struct commit **list = commits;
int count;
for (count = 0; count < nr_commits; count++, list++)
for (count = 0; count < nr_commits; count++, list++) {
display_progress(progress, ++*progress_cnt);
hashwrite(f, (*list)->object.oid.hash, (int)hash_len);
}
}
static const unsigned char *commit_to_sha1(size_t index, void *table)
@ -468,7 +475,9 @@ static const unsigned char *commit_to_sha1(size_t index, void *table)
}
static void write_graph_chunk_data(struct hashfile *f, int hash_len,
struct commit **commits, int nr_commits)
struct commit **commits, int nr_commits,
struct progress *progress,
uint64_t *progress_cnt)
{
struct commit **list = commits;
struct commit **last = commits + nr_commits;
@ -478,6 +487,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
struct commit_list *parent;
int edge_value;
uint32_t packedDate[2];
display_progress(progress, ++*progress_cnt);
parse_commit(*list);
hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
@ -539,7 +549,9 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
static void write_graph_chunk_extra_edges(struct hashfile *f,
struct commit **commits,
int nr_commits)
int nr_commits,
struct progress *progress,
uint64_t *progress_cnt)
{
struct commit **list = commits;
struct commit **last = commits + nr_commits;
@ -547,6 +559,9 @@ static void write_graph_chunk_extra_edges(struct hashfile *f,
while (list < last) {
int num_parents = 0;
display_progress(progress, ++*progress_cnt);
for (parent = (*list)->parents; num_parents < 3 && parent;
parent = parent->next)
num_parents++;
@ -768,6 +783,7 @@ void write_commit_graph(const char *obj_dir,
int num_extra_edges;
struct commit_list *parent;
struct progress *progress = NULL;
uint64_t progress_cnt = 0;
if (!commit_graph_compatible(the_repository))
return;
@ -943,11 +959,16 @@ void write_commit_graph(const char *obj_dir,
hashwrite(f, chunk_write, 12);
}
write_graph_chunk_fanout(f, commits.list, commits.nr);
write_graph_chunk_oids(f, GRAPH_OID_LEN, commits.list, commits.nr);
write_graph_chunk_data(f, GRAPH_OID_LEN, commits.list, commits.nr);
if (report_progress)
progress = start_delayed_progress(
_("Writing out commit graph"),
num_chunks * commits.nr);
write_graph_chunk_fanout(f, commits.list, commits.nr, progress, &progress_cnt);
write_graph_chunk_oids(f, GRAPH_OID_LEN, commits.list, commits.nr, progress, &progress_cnt);
write_graph_chunk_data(f, GRAPH_OID_LEN, commits.list, commits.nr, progress, &progress_cnt);
if (num_extra_edges)
write_graph_chunk_extra_edges(f, commits.list, commits.nr);
write_graph_chunk_extra_edges(f, commits.list, commits.nr, progress, &progress_cnt);
stop_progress(&progress);
close_commit_graph(the_repository);
finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);