@matheusbsbs / matheus-bagliano / commits / 9e5afdf997
Fork 0

fetch: add trace2 instrumentation

Add trace2 regions to fetch-pack.c to better track time spent in the various phases of a fetch: * parsing remote refs and finding a cutoff * marking local refs as complete * marking complete remote refs as common All stages could potentially be slow for repositories with many refs. Signed-off-by: Erik Chen <erikchen@chromium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Erik Chen committed Nov 19, 2019 at 23:02 UTC 9e5afdf99703f0bc851b8f7fb2fe5d9817cc6f39
1 file changed +12 -1
fetch-pack.c
+12 -1
@@ -669,6 +669,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
669
670 save_commit_buffer = 0;
671
672 + trace2_region_enter("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);
673 for (ref = *refs; ref; ref = ref->next) {
674 struct object *o;
675
@@ -679,7 +680,8 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
680 if (!o)
681 continue;
682
682 - /* We already have it -- which may mean that we were
683 + /*
684 + * We already have it -- which may mean that we were
685 * in sync with the other side at some time after
686 * that (it is OK if we guess wrong here).
687 */
@@ -689,7 +691,13 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
691 cutoff = commit->date;
692 }
693 }
694 + trace2_region_leave("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);
695
696 + /*
697 + * This block marks all local refs as COMPLETE, and then recursively marks all
698 + * parents of those refs as COMPLETE.
699 + */
700 + trace2_region_enter("fetch-pack", "mark_complete_local_refs", NULL);
701 if (!args->deepen) {
702 for_each_ref(mark_complete_oid, NULL);
703 for_each_cached_alternate(NULL, mark_alternate_complete);
@@ -697,11 +705,13 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
705 if (cutoff)
706 mark_recent_complete_commits(args, cutoff);
707 }
708 + trace2_region_leave("fetch-pack", "mark_complete_local_refs", NULL);
709
710 /*
711 * Mark all complete remote refs as common refs.
712 * Don't mark them common yet; the server has to be told so first.
713 */
714 + trace2_region_enter("fetch-pack", "mark_common_remote_refs", NULL);
715 for (ref = *refs; ref; ref = ref->next) {
716 struct object *o = deref_tag(the_repository,
717 lookup_object(the_repository,
@@ -714,6 +724,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
724 negotiator->known_common(negotiator,
725 (struct commit *)o);
726 }
727 + trace2_region_leave("fetch-pack", "mark_common_remote_refs", NULL);
728
729 save_commit_buffer = old_save_commit_buffer;
730 }