mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
Merge branch 'ds/trace2-topo-walk'
The topological walk codepath is covered by new trace2 stats. * ds/trace2-topo-walk: revision: trace topo-walk statistics
This commit is contained in:
commit
02feca721e
31
revision.c
31
revision.c
|
@ -3308,6 +3308,26 @@ struct topo_walk_info {
|
||||||
struct author_date_slab author_date;
|
struct author_date_slab author_date;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int topo_walk_atexit_registered;
|
||||||
|
static unsigned int count_explore_walked;
|
||||||
|
static unsigned int count_indegree_walked;
|
||||||
|
static unsigned int count_topo_walked;
|
||||||
|
|
||||||
|
static void trace2_topo_walk_statistics_atexit(void)
|
||||||
|
{
|
||||||
|
struct json_writer jw = JSON_WRITER_INIT;
|
||||||
|
|
||||||
|
jw_object_begin(&jw, 0);
|
||||||
|
jw_object_intmax(&jw, "count_explore_walked", count_explore_walked);
|
||||||
|
jw_object_intmax(&jw, "count_indegree_walked", count_indegree_walked);
|
||||||
|
jw_object_intmax(&jw, "count_topo_walked", count_topo_walked);
|
||||||
|
jw_end(&jw);
|
||||||
|
|
||||||
|
trace2_data_json("topo_walk", the_repository, "statistics", &jw);
|
||||||
|
|
||||||
|
jw_release(&jw);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void test_flag_and_insert(struct prio_queue *q, struct commit *c, int flag)
|
static inline void test_flag_and_insert(struct prio_queue *q, struct commit *c, int flag)
|
||||||
{
|
{
|
||||||
if (c->object.flags & flag)
|
if (c->object.flags & flag)
|
||||||
|
@ -3329,6 +3349,8 @@ static void explore_walk_step(struct rev_info *revs)
|
||||||
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
|
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
count_explore_walked++;
|
||||||
|
|
||||||
if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
|
if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
|
||||||
record_author_date(&info->author_date, c);
|
record_author_date(&info->author_date, c);
|
||||||
|
|
||||||
|
@ -3367,6 +3389,8 @@ static void indegree_walk_step(struct rev_info *revs)
|
||||||
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
|
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
count_indegree_walked++;
|
||||||
|
|
||||||
explore_to_depth(revs, commit_graph_generation(c));
|
explore_to_depth(revs, commit_graph_generation(c));
|
||||||
|
|
||||||
for (p = c->parents; p; p = p->next) {
|
for (p = c->parents; p; p = p->next) {
|
||||||
|
@ -3476,6 +3500,11 @@ static void init_topo_walk(struct rev_info *revs)
|
||||||
*/
|
*/
|
||||||
if (revs->sort_order == REV_SORT_IN_GRAPH_ORDER)
|
if (revs->sort_order == REV_SORT_IN_GRAPH_ORDER)
|
||||||
prio_queue_reverse(&info->topo_queue);
|
prio_queue_reverse(&info->topo_queue);
|
||||||
|
|
||||||
|
if (trace2_is_enabled() && !topo_walk_atexit_registered) {
|
||||||
|
atexit(trace2_topo_walk_statistics_atexit);
|
||||||
|
topo_walk_atexit_registered = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct commit *next_topo_commit(struct rev_info *revs)
|
static struct commit *next_topo_commit(struct rev_info *revs)
|
||||||
|
@ -3502,6 +3531,8 @@ static void expand_topo_walk(struct rev_info *revs, struct commit *commit)
|
||||||
oid_to_hex(&commit->object.oid));
|
oid_to_hex(&commit->object.oid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count_topo_walked++;
|
||||||
|
|
||||||
for (p = commit->parents; p; p = p->next) {
|
for (p = commit->parents; p; p = p->next) {
|
||||||
struct commit *parent = p->item;
|
struct commit *parent = p->item;
|
||||||
int *pi;
|
int *pi;
|
||||||
|
|
Loading…
Reference in a new issue