pack-bitmap: extra trace2 information

Add some extra trace2 lines to capture the number of bitmap lookups that are hits versus misses, as well as the number of reachability roots that have bitmap coverage (versus those that do not). Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed May 23, 2024 at 17:27 UTC 25163f50a238087f5157e73eb645ddc5b2d133d7
1 file changed +25 -1
pack-bitmap.c
+25 -1
@@ -116,6 +116,10 @@ struct bitmap_index {
116
117 static int pseudo_merges_satisfied_nr;
118 static int pseudo_merges_cascades_nr;
119 +static int existing_bitmaps_hits_nr;
120 +static int existing_bitmaps_misses_nr;
121 +static int roots_with_bitmaps_nr;
122 +static int roots_without_bitmaps_nr;
123
124 static struct ewah_bitmap *lookup_stored_bitmap(struct stored_bitmap *st)
125 {
@@ -1040,10 +1044,14 @@ static int add_to_include_set(struct bitmap_index *bitmap_git,
1044
1045 partial = bitmap_for_commit(bitmap_git, commit);
1046 if (partial) {
1047 + existing_bitmaps_hits_nr++;
1048 +
1049 bitmap_or_ewah(data->base, partial);
1050 return 0;
1051 }
1052
1053 + existing_bitmaps_misses_nr++;
1054 +
1055 bitmap_set(data->base, bitmap_pos);
1056 if (apply_pseudo_merges_for_commit_1(bitmap_git, data->base, commit,
1057 bitmap_pos))
@@ -1099,8 +1107,12 @@ static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
1107 {
1108 struct ewah_bitmap *or_with = bitmap_for_commit(bitmap_git, commit);
1109
1102 - if (!or_with)
1110 + if (!or_with) {
1111 + existing_bitmaps_misses_nr++;
1112 return 0;
1113 + }
1114 +
1115 + existing_bitmaps_hits_nr++;
1116
1117 if (!*base)
1118 *base = ewah_to_bitmap(or_with);
@@ -1407,8 +1419,12 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
1419 object->flags &= ~UNINTERESTING;
1420 add_pending_object(revs, object, "");
1421 needs_walk = 1;
1422 +
1423 + roots_without_bitmaps_nr++;
1424 } else {
1425 object->flags |= SEEN;
1426 +
1427 + roots_with_bitmaps_nr++;
1428 }
1429 }
1430
@@ -1975,6 +1991,14 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
1991 pseudo_merges_satisfied_nr);
1992 trace2_data_intmax("bitmap", the_repository, "pseudo_merges_cascades",
1993 pseudo_merges_cascades_nr);
1994 + trace2_data_intmax("bitmap", the_repository, "bitmap/hits",
1995 + existing_bitmaps_hits_nr);
1996 + trace2_data_intmax("bitmap", the_repository, "bitmap/misses",
1997 + existing_bitmaps_misses_nr);
1998 + trace2_data_intmax("bitmap", the_repository, "bitmap/roots_with_bitmap",
1999 + roots_with_bitmaps_nr);
2000 + trace2_data_intmax("bitmap", the_repository, "bitmap/roots_without_bitmap",
2001 + roots_without_bitmaps_nr);
2002
2003 return bitmap_git;
2004