From patchwork Wed Oct 2 23:49:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11171919 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F81414DB for ; Wed, 2 Oct 2019 23:49:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DBD821A4C for ; Wed, 2 Oct 2019 23:49:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BvhBX/K3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728482AbfJBXth (ORCPT ); Wed, 2 Oct 2019 19:49:37 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:43352 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727327AbfJBXtg (ORCPT ); Wed, 2 Oct 2019 19:49:36 -0400 Received: by mail-pf1-f201.google.com with SMTP id i187so715617pfc.10 for ; Wed, 02 Oct 2019 16:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to; bh=hfLMzXPeDYnKSQdJnB0ygtFFCgsvCyT0ONFB8t5nQws=; b=BvhBX/K3sQAK2Rk+KjjRp3kefPtwmWTysKdoI04+/qT1i2VR1UsgVxkChMFLZpzDnf Hyb8TMse9EcZc7kEaWqi1k5T/Y6GGxyRVmXnvY7j02D0DgdEuNo4GaVEin4npTyBgKMZ Bgy6KAWTd8UIcquKPnBPAlNKq7giYyT2AN11Q4CnZlDz9OOsVaBYgq/tmY6+2vvjWwlV HQ8CLHtu5KynooIb45qps96/NkR5O2v3f3r6hZfJthrjvbF+eVgp3vii3v0YW14tK+6P yIO3V6CwpT7zdsvNtKX3OAF3KWG70Y1EBAXAgU8BWLFtLeGntUe2XlM1qh5IaiGeE0b6 gKkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=hfLMzXPeDYnKSQdJnB0ygtFFCgsvCyT0ONFB8t5nQws=; b=H4MBsTrwpWDLlBfodBoIPaUlBlRI3uZb7WQ6oDYDixAwrwpB7zJjAmLBB+h8SR0Wf0 ZDFDDOTn1co6TdhCLPWZSPlxfRPyd68AOGpDctCeSxEnnuZV7fE4/8L089RPWZcD+sJ7 a0LZVCbVA0wJuNNydKq64H/OyKLCjlmgaeahBUxtiIkiYpkBMR2xut3zHeCrtmstTOE4 2HS7VUtm8sf4G5nS/8l4worlWLjfphI0mdfteh2kuRvCoa26WAR6iGNXVx63w51Od0Yp 5w5ICZDMoTfT+9+LH8glihqaG0/2Vmc7So3ReewNuGE8Yn7SY3iEhMzAwwS6KvtxR6tM yUGw== X-Gm-Message-State: APjAAAWxQeuEaRlc3w9KF0NtAFWLrCOgtJmJjkoK6oVEe3pWtQ+cr71j KL/G0cg0aHiGehCShdBxd8IMzFbf5mHNKflj1avNyzpJWjskspySucq7UYk0RIAwqJugks6/U8H r2t2jNCzxapmc6RULDY0FVqu1cfQCZFokLNw2Y+OCtn23FJrr/yFZwBFXL6BdHb8= X-Google-Smtp-Source: APXvYqztueUhda8iIAvzWgYWCf1aZlBKbG/zF4If1BgIpxId+D+z/mz5/yFKmnDhWukhx/MWbIdtv+wyDhD+xw== X-Received: by 2002:a63:eb4c:: with SMTP id b12mr5959406pgk.1.1570060174273; Wed, 02 Oct 2019 16:49:34 -0700 (PDT) Date: Wed, 2 Oct 2019 16:49:28 -0700 In-Reply-To: Message-Id: <348b99edf3e736f11ea13793610f2e0433875fab.1570059953.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog Subject: [PATCH 1/2] fetch: add trace2 instrumentation From: Josh Steadmon To: git@vger.kernel.org Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add trace2 regions to fetch-pack.c and builtins/fetch.c to better track time spent in the various phases of a fetch: * listing refs * negotiation for protocol versions v0-v2 * fetching refs * consuming refs Signed-off-by: Josh Steadmon --- builtin/fetch.c | 22 +++++++++++++++------- fetch-pack.c | 13 ++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 67c0eb88c6..ee3dc085bb 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1071,8 +1071,11 @@ static int check_exist_and_connected(struct ref *ref_map) static int fetch_refs(struct transport *transport, struct ref *ref_map) { int ret = check_exist_and_connected(ref_map); - if (ret) + if (ret) { + trace2_region_enter("fetch", "fetch_refs", the_repository); ret = transport_fetch_refs(transport, ref_map); + trace2_region_leave("fetch", "fetch_refs", the_repository); + } if (!ret) /* * Keep the new pack's ".keep" file around to allow the caller @@ -1088,11 +1091,14 @@ static int consume_refs(struct transport *transport, struct ref *ref_map) { int connectivity_checked = transport->smart_options ? transport->smart_options->connectivity_checked : 0; - int ret = store_updated_refs(transport->url, - transport->remote->name, - connectivity_checked, - ref_map); + int ret; + trace2_region_enter("fetch", "consume_refs", the_repository); + ret = store_updated_refs(transport->url, + transport->remote->name, + connectivity_checked, + ref_map); transport_unlock_pack(transport); + trace2_region_leave("fetch", "consume_refs", the_repository); return ret; } @@ -1337,9 +1343,11 @@ static int do_fetch(struct transport *transport, argv_array_push(&ref_prefixes, "refs/tags/"); } - if (must_list_refs) + if (must_list_refs) { + trace2_region_enter("fetch", "remote_refs", the_repository); remote_refs = transport_get_remote_refs(transport, &ref_prefixes); - else + trace2_region_leave("fetch", "remote_refs", the_repository); + } else remote_refs = NULL; argv_array_clear(&ref_prefixes); diff --git a/fetch-pack.c b/fetch-pack.c index 6ccc6294ea..c016eeab1d 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -382,6 +382,7 @@ static int find_common(struct fetch_negotiator *negotiator, state_len = 0; } + trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository); flushes = 0; retval = -1; if (args->no_dependents) @@ -466,6 +467,7 @@ static int find_common(struct fetch_negotiator *negotiator, } } done: + trace2_region_leave("fetch-pack", "negotiation_v0_v1", the_repository); if (!got_ready || !no_done) { packet_buf_write(&req_buf, "done\n"); send_request(args, fd[1], &req_buf); @@ -1378,7 +1380,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, enum fetch_state state = FETCH_CHECK_LOCAL; struct oidset common = OIDSET_INIT; struct packet_reader reader; - int in_vain = 0; + int in_vain = 0, negotiation_started = 0; int haves_to_send = INITIAL_FLUSH; struct fetch_negotiator negotiator; fetch_negotiator_init(r, &negotiator); @@ -1421,6 +1423,12 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, } break; case FETCH_SEND_REQUEST: + if (!negotiation_started) { + negotiation_started = 1; + trace2_region_enter("fetch-pack", + "negotiation_v2", + the_repository); + } if (send_fetch_request(&negotiator, fd[1], args, ref, &common, &haves_to_send, &in_vain, @@ -1444,6 +1452,9 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, } break; case FETCH_GET_PACK: + trace2_region_leave("fetch-pack", + "negotiation_v2", + the_repository); /* Check for shallow-info section */ if (process_section_header(&reader, "shallow-info", 1)) receive_shallow_info(args, &reader, shallows, si); From patchwork Wed Oct 2 23:49:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11171923 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19F1D16B1 for ; Wed, 2 Oct 2019 23:49:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECAEB222BE for ; Wed, 2 Oct 2019 23:49:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YR6GKzlt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728716AbfJBXtk (ORCPT ); Wed, 2 Oct 2019 19:49:40 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:41186 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727327AbfJBXtj (ORCPT ); Wed, 2 Oct 2019 19:49:39 -0400 Received: by mail-vk1-f201.google.com with SMTP id u123so231154vkf.8 for ; Wed, 02 Oct 2019 16:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to; bh=UprPYrepAY5h9AAZedBDIHbfqDboqFL59p1RPsmZshU=; b=YR6GKzltSmPOqdeFbcqACC2cnSbmejnwAKUqHyXDsLtPIkuoJiCT08aBn9NJTrRi1j lAnqLo9lA5YVYxoTPR9L7lbrnlpK1Kh+VVvXP7PzKVGew2JcYvnt+CPRdKLOkUi6vSbX 2kkO1V0IHQVEswRQQRy7XBmyLnHBwP40hlqlkTNKLBVh/Woox8fSgu8azY80XuE59J34 5c547eXqcrq9OgXpzHguWUq14N4LaqysF2aW9EWf5i949grbyS6ptdvQByBULqBfkHp1 6F83E77wx1wkpUnGa3vx5zryB9PLAia1D4Rg72G+5mSKAYp82k/ZDmuUb+YMs6Bm0mrC WSvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=UprPYrepAY5h9AAZedBDIHbfqDboqFL59p1RPsmZshU=; b=hORQ0/ZvZGmto+1ptowP2YJgVjUeO6qHi9TtdSaAypG9SWvJj6WUhugEgHQC3B7yEq 4RG8N43k39T8erS4zqTdqg+wzDZT9syv2Glx+vvRoSE3FqOe7ExMmxzmd3LGnCxp0AZz YJgEQ6bXvHVhkgQrdAcZYQ0Q3IrE8KzpUIlUEQoF396uVIh6IbP03ARTUzOG47i6nTZV TTNFX8ivEX/PD9+3bvezRUwJbHuCoSVhQvVwda8ZCBs8sqrMiZziP5jAJ2BETfDrRs+0 NwmtJJNLQnrMXgtTcXHRuZylJGz0hNla05J95tvU7oTOEYSGb8nqJV/pNC9jNN6yLzuC 2rxw== X-Gm-Message-State: APjAAAXjeM26qEcm/0oBOZc6yjpUbeQ1XWE92R7GDgIlCT6m/DwJfdn/ tEdYwDgl/fS2f+m4XY2Ct768pbYOOOXJ8qGp2eNf0eY7QL3Bl8GBDlWjne9aW8XYCpM+wjDViql SLKS0r1O8GI3S67sBh1uBv3B77HCbzlUodCYE4TkYfbWtDy8i2h6PVebVTVwXCvI= X-Google-Smtp-Source: APXvYqzpevBWwgW5bpgfFlq3TIzuI3wqHFSI864vavunOyeTdEUdO8V3cIEG+Jzu2nyfXkP5/C0gVW7ipuDNCQ== X-Received: by 2002:a05:6102:3032:: with SMTP id v18mr3408002vsa.203.1570060176956; Wed, 02 Oct 2019 16:49:36 -0700 (PDT) Date: Wed, 2 Oct 2019 16:49:29 -0700 In-Reply-To: Message-Id: <054936f40b8232516763ec90bf44ad50d86d7b65.1570059953.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog Subject: [PATCH 2/2] push: add trace2 instrumentation From: Josh Steadmon To: git@vger.kernel.org Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add trace2 regions in transport.c and builtin/push.c to better track time spent in various phases of pushing: * Listing refs * Checking submodules * Pushing submodules * Pushing refs Signed-off-by: Josh Steadmon --- builtin/push.c | 2 ++ transport.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 3742daf7b0..cc1292a566 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -357,8 +357,10 @@ static int push_with_options(struct transport *transport, struct refspec *rs, if (verbosity > 0) fprintf(stderr, _("Pushing to %s\n"), transport->url); + trace2_region_enter("push", "transport_push", the_repository); err = transport_push(the_repository, transport, rs, flags, &reject_reasons); + trace2_region_leave("push", "transport_push", the_repository); if (err != 0) { fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR)); error(_("failed to push some refs to '%s'"), transport->url); diff --git a/transport.c b/transport.c index ae558af944..f313f288de 100644 --- a/transport.c +++ b/transport.c @@ -1145,8 +1145,10 @@ int transport_push(struct repository *r, refspec_ref_prefixes(rs, &ref_prefixes); + trace2_region_enter("transport_push", "get_refs_list", the_repository); remote_refs = transport->vtable->get_refs_list(transport, 1, &ref_prefixes); + trace2_region_leave("transport_push", "get_refs_list", the_repository); argv_array_clear(&ref_prefixes); @@ -1182,6 +1184,7 @@ int transport_push(struct repository *r, struct ref *ref = remote_refs; struct oid_array commits = OID_ARRAY_INIT; + trace2_region_enter("transport_push", "push_submodules", the_repository); for (; ref; ref = ref->next) if (!is_null_oid(&ref->new_oid)) oid_array_append(&commits, @@ -1194,9 +1197,11 @@ int transport_push(struct repository *r, transport->push_options, pretend)) { oid_array_clear(&commits); + trace2_region_leave("transport_push", "push_submodules", the_repository); die(_("failed to push all needed submodules")); } oid_array_clear(&commits); + trace2_region_leave("transport_push", "push_submodules", the_repository); } if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) || @@ -1207,6 +1212,7 @@ int transport_push(struct repository *r, struct string_list needs_pushing = STRING_LIST_INIT_DUP; struct oid_array commits = OID_ARRAY_INIT; + trace2_region_enter("transport_push", "check_submodules", the_repository); for (; ref; ref = ref->next) if (!is_null_oid(&ref->new_oid)) oid_array_append(&commits, @@ -1217,15 +1223,19 @@ int transport_push(struct repository *r, transport->remote->name, &needs_pushing)) { oid_array_clear(&commits); + trace2_region_leave("transport_push", "check_submodules", the_repository); die_with_unpushed_submodules(&needs_pushing); } string_list_clear(&needs_pushing, 0); oid_array_clear(&commits); + trace2_region_leave("transport_push", "check_submodules", the_repository); } - if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY)) + if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY)) { + trace2_region_enter("transport_push", "push_refs", the_repository); push_ret = transport->vtable->push_refs(transport, remote_refs, flags); - else + trace2_region_leave("transport_push", "push_refs", the_repository); + } else push_ret = 0; err = push_had_errors(remote_refs); ret = push_ret | err;