send-pack: add new tracing regions for push

At $DAYJOB we experienced some slow pushes and needed additional trace data to diagnose them. Add trace2 regions for various sections of send_pack(). Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Calvin Wan committed Aug 22, 2024 at 14:57 UTC db5281276ecdeeb19acea3391804e9ab1ebcd884
1 file changed +13 -3
send-pack.c
+13 -3
@@ -75,6 +75,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
75 int i;
76 int rc;
77
78 + trace2_region_enter("send_pack", "pack_objects", the_repository);
79 strvec_push(&po.args, "pack-objects");
80 strvec_push(&po.args, "--all-progress-implied");
81 strvec_push(&po.args, "--revs");
@@ -146,8 +147,10 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
147 */
148 if (rc > 128 && rc != 141)
149 error("pack-objects died of signal %d", rc - 128);
150 + trace2_region_leave("send_pack", "pack_objects", the_repository);
151 return -1;
152 }
153 + trace2_region_leave("send_pack", "pack_objects", the_repository);
154 return 0;
155 }
156
@@ -170,6 +173,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
173 int new_report = 0;
174 int once = 0;
175
176 + trace2_region_enter("send_pack", "receive_status", the_repository);
177 hint = NULL;
178 ret = receive_unpack_status(reader);
179 while (1) {
@@ -268,6 +272,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
272 new_report = 1;
273 }
274 }
275 + trace2_region_leave("send_pack", "receive_status", the_repository);
276 return ret;
277 }
278
@@ -512,8 +517,11 @@ int send_pack(struct send_pack_args *args,
517 }
518
519 git_config_get_bool("push.negotiate", &push_negotiate);
515 - if (push_negotiate)
520 + if (push_negotiate) {
521 + trace2_region_enter("send_pack", "push_negotiate", the_repository);
522 get_commons_through_negotiation(args->url, remote_refs, &commons);
523 + trace2_region_leave("send_pack", "push_negotiate", the_repository);
524 + }
525
526 if (!git_config_get_bool("push.usebitmaps", &use_bitmaps))
527 args->disable_bitmaps = !use_bitmaps;
@@ -641,10 +649,11 @@ int send_pack(struct send_pack_args *args,
649 /*
650 * Finally, tell the other end!
651 */
644 - if (!args->dry_run && push_cert_nonce)
652 + if (!args->dry_run && push_cert_nonce) {
653 cmds_sent = generate_push_cert(&req_buf, remote_refs, args,
654 cap_buf.buf, push_cert_nonce);
647 - else if (!args->dry_run)
655 + trace2_printf("Generated push certificate");
656 + } else if (!args->dry_run) {
657 for (ref = remote_refs; ref; ref = ref->next) {
658 char *old_hex, *new_hex;
659
@@ -664,6 +673,7 @@ int send_pack(struct send_pack_args *args,
673 old_hex, new_hex, ref->name);
674 }
675 }
676 + }
677
678 if (use_push_options) {
679 struct string_list_item *item;