From patchwork Mon Oct 7 22:35:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11178607 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 0272C76 for ; Mon, 7 Oct 2019 22:35:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D605A2133F for ; Mon, 7 Oct 2019 22:35:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hROGAJb+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729502AbfJGWfY (ORCPT ); Mon, 7 Oct 2019 18:35:24 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:33110 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728893AbfJGWfX (ORCPT ); Mon, 7 Oct 2019 18:35:23 -0400 Received: by mail-pf1-f202.google.com with SMTP id z4so12187994pfn.0 for ; Mon, 07 Oct 2019 15:35:22 -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=WvOo2F52uAhKVcozWLUcAvKYoVb7FMGGeFTbet/FlBc=; b=hROGAJb+jI6za5HsfD5EExh6enri59ktsjWPRTw8OojcGCq7HrlrvxEJYNYilhzruV K0OPtmnI8iJGX9yqPcYrELxMGoIEbxiCgBcc3zcj+6GhNn1CQVtseLvn44csvS77Y3AK SnkUFbG7PofQad46fd0c3kLDf11VHTYeu73q3ve+XPDgxPT4wk0fWTseqhq/fM8ZA1H2 RQ7Vd/vSzKLy5/hWv1o4esjoNVAifEFy6n01pSpb50WQAJgUF0dQeEQ+OcA3EcSWAyIE bV1uVk2qey6VTjdwJQgMoSsduS9xk5chzEirh/N0r3Yzh4uJPTZPTUgtJ1dETv37gZjD lOag== 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=WvOo2F52uAhKVcozWLUcAvKYoVb7FMGGeFTbet/FlBc=; b=uFFyguwHgu8C2oFRYr5f1vxmVVEAw8MwGMpPDCmhVt7Cyr5jTvbnfEvZEXJRv8fphT YGXJcGJM0wnGghxvczzKHj1egRo+RTvW+vba6Q+6ERmCUsp4GRUsw0zsVVZRMi2Yhu07 D1fow6ZjWeH0ebk0MKSkltPrfeIFjwK2Ncjj4rX9Fip18bbJ8vPygbmQHLa6LH3P4vdh 9m6Hb+PO/6eX/OkzZfybQ2K8FpPTpr6PfLI1qAv3MlQ9s7ZIyX8gWBtHgui/J0a4TbcX Xyd92I5MAjelvag/bshmmgog8INn6f1e+2ZukKIB0qeT1R/Z59qvoiAjJy9bI/wpLChK WwtQ== X-Gm-Message-State: APjAAAVrGkGmkAxTA9twM2sMBh14glMDNOxs/csbdE4OuQ1SnFOZ5JRY TK0Tg2LumvAKUp17gxpcgl6GAeNKugG2jYD+1F58BTsWVpp4YxDAvfo9QNnXCkkIAXU0z0bcVNZ 4HBb8g9Ow/3cLiKBQ8ilRArUbPwpouW29p3RelJwHCZekpIR1jFHCILAHXWW0Ov8= X-Google-Smtp-Source: APXvYqwFGTZ8dXkTeqzQ3XjnVkHmdqsitJdmYe3AqiOXfrobn8piOkVzYefzglLYI0mK6JSZn+iJj2KKlZdJHw== X-Received: by 2002:a63:d058:: with SMTP id s24mr31641685pgi.189.1570487721395; Mon, 07 Oct 2019 15:35:21 -0700 (PDT) Date: Mon, 7 Oct 2019 15:35:15 -0700 In-Reply-To: Message-Id: <348b99edf3e736f11ea13793610f2e0433875fab.1570487473.git.steadmon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.23.0.581.g78d2f28ef7-goog Subject: [PATCH v2 1/2] fetch: add trace2 instrumentation From: Josh Steadmon To: git@vger.kernel.org, jonathantanmy@google.com 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 Mon Oct 7 22:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Steadmon X-Patchwork-Id: 11178609 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 A2FAC76 for ; Mon, 7 Oct 2019 22:35:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8209E206C0 for ; Mon, 7 Oct 2019 22:35:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZpKFe4fR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729517AbfJGWf0 (ORCPT ); Mon, 7 Oct 2019 18:35:26 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:42908 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728893AbfJGWf0 (ORCPT ); Mon, 7 Oct 2019 18:35:26 -0400 Received: by mail-pg1-f201.google.com with SMTP id d3so11132405pgv.9 for ; Mon, 07 Oct 2019 15:35:24 -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=MqXwEARbDXCNksxYAQsjOPkaHRgBlJTJ/Q9kS5NOciY=; b=ZpKFe4fRhueWm3ZbEX4BFLY/elpSsClLocUZnpe0v4oV1U1uYmYBzM0FrgXgRr9Dmq l3ACjAOOuL98ZktMmhh5N3rB9uWVCcgDA6t5YjEuFiNpFNTSrnWtPgEw+uu5W9tygtA6 UF1Ao6N8OURc19zSe7MOBUu4I321pRqm8QceS9SSmvBqw/fsaVJ0h1KNUGYBFXrhAsCJ 2Mn+EeJHfgA2x4UejEYP56pKLGKK6N6ZHrDEf0Xgc1epOsnTM0l29KnshohOpbS7u66R Lk0WSlo24mKcD9lg6c0JPoB0+DxlU48m6OaKzdPSEVy12oGnvt+ACmTyIFI13LRloxnQ W+kg== 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=MqXwEARbDXCNksxYAQsjOPkaHRgBlJTJ/Q9kS5NOciY=; b=MnSgsm5s2TEGxOJJ0cmo+FCfRSqo09Ifv9QXdLj1PkffXPMRKm/rxTZ3elA0h/t4Du EfnQli2Dxk69WJdu5h1FPakE3FRdzLCYNLqVhDSExmp1snwj5yh7jsPI9YT9sZ/wJFNE lqOVmZJFW8FPntOqlYsDyZgiEUMxsioPKMk+N9jQyDSLnyi70FLkUlMD2WR9FN1oAAJw BRhEkbaciWMwWSXwioShuFRnOO3AWrDgn0iQ9KlCBOO0mdY+tLW5aVwZKPdCtXDvCvWr Ss8IfrSMNsTQJuz4/JTlWylxsibDKHA7PVQwBHayu+kbQcAi+WHjAgwFZ3ZcZY2sGzlZ EFcA== X-Gm-Message-State: APjAAAUHKu726UHvaEy2kK5EeFjLHTKDCV08r9K//9uxlstiIMwNlzdl 4R4aFIx89b5d3PlRoZK6RhR3AoYKVeJim97yNngFdDd/8hlnR7F4wqCMcS8Oo4TuZ30saHNfnEK uxzotq0m6Ms5ntuxBEhy1RF2el8bSOB64j/Os9uccf1BC/7T19jti3GQCJCn9Peo= X-Google-Smtp-Source: APXvYqwAlPPJ9nPkogpOxMMswtQifL6i9Nzvk3yBmIDYUhXzsSP2ANxtcew7akt5gBZ9eKrwmbbAVLWFmDxURw== X-Received: by 2002:a63:347:: with SMTP id 68mr13586915pgd.244.1570487723889; Mon, 07 Oct 2019 15:35:23 -0700 (PDT) Date: Mon, 7 Oct 2019 15:35:16 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.23.0.581.g78d2f28ef7-goog Subject: [PATCH v2 2/2] push: add trace2 instrumentation From: Josh Steadmon To: git@vger.kernel.org, jonathantanmy@google.com 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..83379a037d 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", r); remote_refs = transport->vtable->get_refs_list(transport, 1, &ref_prefixes); + trace2_region_leave("transport_push", "get_refs_list", r); 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", r); 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", r); die(_("failed to push all needed submodules")); } oid_array_clear(&commits); + trace2_region_leave("transport_push", "push_submodules", r); } 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", r); 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", r); die_with_unpushed_submodules(&needs_pushing); } string_list_clear(&needs_pushing, 0); oid_array_clear(&commits); + trace2_region_leave("transport_push", "check_submodules", r); } - if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY)) + if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY)) { + trace2_region_enter("transport_push", "push_refs", r); push_ret = transport->vtable->push_refs(transport, remote_refs, flags); - else + trace2_region_leave("transport_push", "push_refs", r); + } else push_ret = 0; err = push_had_errors(remote_refs); ret = push_ret | err;