Skip to content

Commit 02feca7

Browse files
committed
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
2 parents df26861 + 90b666d commit 02feca7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

revision.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,6 +3308,26 @@ struct topo_walk_info {
33083308
struct author_date_slab author_date;
33093309
};
33103310

3311+
static int topo_walk_atexit_registered;
3312+
static unsigned int count_explore_walked;
3313+
static unsigned int count_indegree_walked;
3314+
static unsigned int count_topo_walked;
3315+
3316+
static void trace2_topo_walk_statistics_atexit(void)
3317+
{
3318+
struct json_writer jw = JSON_WRITER_INIT;
3319+
3320+
jw_object_begin(&jw, 0);
3321+
jw_object_intmax(&jw, "count_explore_walked", count_explore_walked);
3322+
jw_object_intmax(&jw, "count_indegree_walked", count_indegree_walked);
3323+
jw_object_intmax(&jw, "count_topo_walked", count_topo_walked);
3324+
jw_end(&jw);
3325+
3326+
trace2_data_json("topo_walk", the_repository, "statistics", &jw);
3327+
3328+
jw_release(&jw);
3329+
}
3330+
33113331
static inline void test_flag_and_insert(struct prio_queue *q, struct commit *c, int flag)
33123332
{
33133333
if (c->object.flags & flag)
@@ -3329,6 +3349,8 @@ static void explore_walk_step(struct rev_info *revs)
33293349
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
33303350
return;
33313351

3352+
count_explore_walked++;
3353+
33323354
if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
33333355
record_author_date(&info->author_date, c);
33343356

@@ -3367,6 +3389,8 @@ static void indegree_walk_step(struct rev_info *revs)
33673389
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
33683390
return;
33693391

3392+
count_indegree_walked++;
3393+
33703394
explore_to_depth(revs, commit_graph_generation(c));
33713395

33723396
for (p = c->parents; p; p = p->next) {
@@ -3476,6 +3500,11 @@ static void init_topo_walk(struct rev_info *revs)
34763500
*/
34773501
if (revs->sort_order == REV_SORT_IN_GRAPH_ORDER)
34783502
prio_queue_reverse(&info->topo_queue);
3503+
3504+
if (trace2_is_enabled() && !topo_walk_atexit_registered) {
3505+
atexit(trace2_topo_walk_statistics_atexit);
3506+
topo_walk_atexit_registered = 1;
3507+
}
34793508
}
34803509

34813510
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)
35023531
oid_to_hex(&commit->object.oid));
35033532
}
35043533

3534+
count_topo_walked++;
3535+
35053536
for (p = commit->parents; p; p = p->next) {
35063537
struct commit *parent = p->item;
35073538
int *pi;

0 commit comments

Comments
 (0)