Skip to content

Commit 90b666d

Browse files
derrickstoleegitster
authored andcommitted
revision: trace topo-walk statistics
We trace statistics about the effectiveness of changed-path Bloom filters since 42e50e7 (revision.c: add trace2 stats around Bloom filter usage, 2020-04-06). Add similar tracing for the topo-walk algorithm that uses generation numbers to limit the walk size. This information can help investigate and describe benefits to heuristics and other changes. The information that is printed is in JSON format and can be formatted nicely to present as follows: { "count_explort_walked":2603, "count_indegree_walked":2603, "count_topo_walked":473 } Each of these values count the number of commits are visited by each of the three "stages" of the topo-walk as detailed in b454241 (revision.c: generation-based topo-order algorithm, 2018-11-01). Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71ca53e commit 90b666d

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)