From patchwork Fri Jul 22 08:19:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12926112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23A70C43334 for ; Fri, 22 Jul 2022 08:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234970AbiGVIUF (ORCPT ); Fri, 22 Jul 2022 04:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234977AbiGVITr (ORCPT ); Fri, 22 Jul 2022 04:19:47 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6098B9E7A8 for ; Fri, 22 Jul 2022 01:19:43 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id y24so3979631plh.7 for ; Fri, 22 Jul 2022 01:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wq/W1UaogW21+AR8mEKJDM9cWneyVeoWVkCtYHnDQ5Q=; b=oj1jAaIhcySC2zvLwmYD9zDUBzdltD9LXNpA5epulPwr6Hyi8ChKe06Pz3d8G0nfvH rYqzJZSyia4IDhC0jh0gB3nbpndn3M1F6KTTY6FecFsd6GOM8kkBFe+g10C0adeMF8Ev HOCVOLnkqpBlG6C04bEPotjDeherJ6O9/FMZDjEPvyTkZ6ukP+W6X6OVdH6IA9X8jejJ m4H5a6tLrT+4MOOwSMl+qzq4wcL9kOMHG/HScpsd0Hz/DNVpWY+upR3KJn9XnfQN4ONv 9meIKWVKDEYVTFvnrr3EXC7nwvGYMtpp7sYT2S5porB3eVH2hfrgmwDforFdx+UxYfjq K83A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wq/W1UaogW21+AR8mEKJDM9cWneyVeoWVkCtYHnDQ5Q=; b=cc6sA5c2vWRdM6hcZvfnUGALFSX+o/9tCG7uF4xhUE+93idIpW2Bplo+6FcFUSZcE9 KYUjzqQoBj5/N+mAIt3jy6By7OwcgOlCrTnJ4rSmlNC9+fWSU1+Yh/lWiwMxgTmjEzMi h4lFjUH4O6TdJo0edSemd/b7UM9xZSvt1o0RHB2MbJAg6/tR7dQPkhSEW4Q/fVt+9HgP GCBQ61X0hVi/t2O3YFqW6DMvzKZGOkofJ76ldGDSyXN3tbpu1Qi/9FEWA6x855JMwCPw wMq+uLaDdGwvrNPwP1pDnKTPyURJD8uxjYZ5eatep/A+bAaYNdCCQ/V8Gtcaq1jsztwj hStw== X-Gm-Message-State: AJIora8lKi113KWfmptRYz7V8BznMmYGrkIcwfu1h2bYvHkA0iBYifC7 Q8cGMW1KWi+p1A0cXitCiIbyZOpcn8Q= X-Google-Smtp-Source: AGRyM1ssSYyxGrrK8wuZTSm5TDcvd2kPfMC+AJg2zGfiu5UvWaldk15ooLD7kJJocQhVa9/+tRnmqw== X-Received: by 2002:a17:90b:4a04:b0:1ef:c318:ef9c with SMTP id kk4-20020a17090b4a0400b001efc318ef9cmr15796477pjb.67.1658477981889; Fri, 22 Jul 2022 01:19:41 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id q9-20020aa78429000000b00528d580cb45sm3188734pfn.127.2022.07.22.01.19.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2022 01:19:41 -0700 (PDT) From: "tenglong.tl" X-Google-Original-From: "tenglong.tl" To: dyroneteng@gmail.com Cc: avarab@gmail.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v1 1/2] api-trace2.txt: print config key-value pair Date: Fri, 22 Jul 2022 16:19:31 +0800 Message-Id: <32f8b9ae6bb6aff0ce55ee494c4c0d40c672752b.1658472474.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.37.1.1.g8cbb44ffc4.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Teng Long It's supported to print "interesting" config key-value paire to tr2 log by setting "GIT_TRACE2_CONFIG_PARAMS" environment variable and the "trace2.configparam" config, let's add the related docs in Documentaion/technical/api-trace2.txt. Signed-off-by: Teng Long --- Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt index 77a150b30e..ddc0bfb9c9 100644 --- a/Documentation/technical/api-trace2.txt +++ b/Documentation/technical/api-trace2.txt @@ -717,6 +717,7 @@ The "exec_id" field is a command-unique id and is only useful if the { "event":"def_param", ... + "scope":"global", "param":"core.abbrev", "value":"7" } @@ -1207,6 +1208,37 @@ at offset 508. This example also shows that thread names are assigned in a racy manner as each thread starts and allocates TLS storage. +Print Configs:: + + Dump "interesting" config values to trace2 log. ++ +The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration +`trace2.configparams` can be used to output config values which you care +about(see linkgit:git-config[1). For example: ++ +---------------- +$ git config color.ui auto +---------------- ++ +Then, mark the config `color.ui` as "interesting" config with +`GIT_TRACE2_CONFIG_PARAMS`: ++ +---------------- +$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ export GIT_TRACE2_CONFIG_PARAMS=color.ui +$ git version +... +$ cat ~/log.perf +d0 | main | version | | | | | ... +d0 | main | start | | 0.001642 | | | /usr/local/bin/git version +d0 | main | cmd_name | | | | | version (version) +d0 | main | def_param | | | | | color.ui:auto +d0 | main | data | r0 | 0.002100 | 0.002100 | fsync | fsync/writeout-only:0 +d0 | main | data | r0 | 0.002126 | 0.002126 | fsync | fsync/hardware-flush:0 +d0 | main | exit | | 0.002142 | | | code:0 +d0 | main | atexit | | 0.002161 | | | code:0 +---------------- == Future Work === Relationship to the Existing Trace Api (api-trace.txt) From patchwork Fri Jul 22 08:19:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12926113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D7AFC43334 for ; Fri, 22 Jul 2022 08:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234914AbiGVIUH (ORCPT ); Fri, 22 Jul 2022 04:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234918AbiGVITs (ORCPT ); Fri, 22 Jul 2022 04:19:48 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C9B9E2A6 for ; Fri, 22 Jul 2022 01:19:44 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id g12so3908656pfb.3 for ; Fri, 22 Jul 2022 01:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RjlArnORTzLu2tZdWlkVXjtNTFr9wJcfwBVzeUSmAQQ=; b=SqtkjRvmejICqyXBzDU8QLxOTB53y72e96tlww6srPRDFsIb0O0ufwRF1Ymct3Di1V jxJVBpPlvzoiFU/vCAVA6mSI9z0gC+tgkFbTEhl4vse42qJpMQRR+EI/uTsbENQiF9WQ xQtTQTTvCerKjEjHR4IxbOoozGIiakkDq34nSbBDWiIL8NkCe7/fUtI7tqrqnaGq1DjU YGCN4hWBfLNHbyHcm7BQ9Mwob0NGLkV+F5mrzC1mdpKGl+QPJf61pmgSOa5dyDZOhKq4 JGpAsWmNKTbHWbedcVA6KDsKuhLYNilC0gfYLZrdZFGeS3UZezLzjkx8sLVUN5bSQ4FH rJXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RjlArnORTzLu2tZdWlkVXjtNTFr9wJcfwBVzeUSmAQQ=; b=guzxDA7zq0oOznTMLhDWxZ+1/pcyWLI6RqDy6T0xkj8zaW7kTMzqinUMLlLB3qItVj aLrbU4RTPdWFirzHNZz/lzD5V1LCUNWMemSAxTIZ4loR+3oUMfNsw/ZUziFK1BMGXCBC r6a7QSAaqBrmUC2LoRCBCs401h/FQUKDTcDN8pDiX9i50KXigf6K2kNT81MUExTb5Aw0 KiWF5XPb5kMtQANFAW2YlVpCfrVl3ySJIdWBHSxMnnDdGfmqT2J2UF5btLuhBiPJisoB K4Vgm2tZYVHuTxG1d0/H29Or3GSOp9+oUhhJWaLIVRMnhmu+obpa5ix8K4za787+/36I kvQA== X-Gm-Message-State: AJIora9mQY7hHo5zMh244qyKvxQhQrBjwn4613tFpTvDMFahr+28Nrsm r5vi+1qjRuOY76xLt6XAKGI= X-Google-Smtp-Source: AGRyM1vpW19i2hYPj8+50SnX/v22gXKVScYvSnhjDCIHdOYuZcONj65STpnLpNxEv7Ld/D+xgx0Eeg== X-Received: by 2002:aa7:9afa:0:b0:528:bbf7:e444 with SMTP id y26-20020aa79afa000000b00528bbf7e444mr2321054pfp.71.1658477983957; Fri, 22 Jul 2022 01:19:43 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id q9-20020aa78429000000b00528d580cb45sm3188734pfn.127.2022.07.22.01.19.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2022 01:19:43 -0700 (PDT) From: "tenglong.tl" X-Google-Original-From: "tenglong.tl" To: dyroneteng@gmail.com Cc: avarab@gmail.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v1 2/2] tr2: shows scope unconditionally in addition to key-value pair Date: Fri, 22 Jul 2022 16:19:32 +0800 Message-Id: <78575cca0b3ef4acb1bb42a00ccd3104f3fa4cea.1658472474.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.37.1.1.g8cbb44ffc4.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Teng Long When we specify GIT_TRACE2_CONFIG_PARAMS or trace2.configparams, trace2 will prints "interesting" config values to log. Sometimes, when a config set in multiple scope files, the following output looks like (the irrelevant fields are omitted here as "..."): ...| def_param | ... | core.multipackindex:false ...| def_param | ... | core.multipackindex:false ...| def_param | ... | core.multipackindex:false As the log shows, even each config in different scope is dumped, but we don't know which scope it comes from. Therefore, it's better to add the scope names as well to make them be more recognizable. For example, when execute: $ GIT_TRACE2_PERF=1 \ > GIT_TRACE2_CONFIG_PARAMS=core.multipackIndex \ > git rev-list --test-bitmap HEAD" The following is the ouput (the irrelevant fields are omitted here as "..."): Format normal: ... git.c:461 ... def_param scope:system core.multipackindex=false ... git.c:461 ... def_param scope:global core.multipackindex=false ... git.c:461 ... def_param scope:local core.multipackindex=false Format perf: ... | def_param | ... | scope:system | core.multipackindex:false ... | def_param | ... | scope:global | core.multipackindex:false ... | def_param | ... | scope:local | core.multipackindex:false Format event: {"event":"def_param", ... ,"scope":"system","param":"core.multipackindex","value":"false"} {"event":"def_param", ... ,"scope":"global","param":"core.multipackindex","value":"false"} {"event":"def_param", ... ,"scope":"local","param":"core.multipackindex","value":"false"} Signed-off-by: Teng Long --- Documentation/technical/api-trace2.txt | 19 ++++++++++++++----- trace2/tr2_tgt_event.c | 3 +++ trace2/tr2_tgt_normal.c | 5 ++++- trace2/tr2_tgt_perf.c | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt index ddc0bfb9c9..534cfa98fa 100644 --- a/Documentation/technical/api-trace2.txt +++ b/Documentation/technical/api-trace2.txt @@ -1214,10 +1214,17 @@ Print Configs:: + The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration `trace2.configparams` can be used to output config values which you care -about(see linkgit:git-config[1). For example: +about(see linkgit:git-config[1). For example assume that we want to config +different `color.ui` values in multiple scopes, such as: + ---------------- -$ git config color.ui auto +$ git config --system color.ui never +$ git config --global color.ui always +$ git config --local color.ui auto +$ git config --list --show-scope | grep 'color.ui' +system color.ui=never +global color.ui=always +local color.ui=auto ---------------- + Then, mark the config `color.ui` as "interesting" config with @@ -1233,11 +1240,13 @@ $ cat ~/log.perf d0 | main | version | | | | | ... d0 | main | start | | 0.001642 | | | /usr/local/bin/git version d0 | main | cmd_name | | | | | version (version) -d0 | main | def_param | | | | | color.ui:auto +d0 | main | def_param | | | | scope:system | color.ui:never +d0 | main | def_param | | | | scope:global | color.ui:always +d0 | main | def_param | | | | scope:local | color.ui:auto d0 | main | data | r0 | 0.002100 | 0.002100 | fsync | fsync/writeout-only:0 d0 | main | data | r0 | 0.002126 | 0.002126 | fsync | fsync/hardware-flush:0 -d0 | main | exit | | 0.002142 | | | code:0 -d0 | main | atexit | | 0.002161 | | | code:0 +d0 | main | exit | | 0.000470 | | | code:0 +d0 | main | atexit | | 0.000477 | | | code:0 ---------------- == Future Work diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c index c5c8cfbbaa..37a3163be1 100644 --- a/trace2/tr2_tgt_event.c +++ b/trace2/tr2_tgt_event.c @@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param, { const char *event_name = "def_param"; struct json_writer jw = JSON_WRITER_INIT; + enum config_scope scope = current_config_scope(); + const char *scope_name = config_scope_name(scope); jw_object_begin(&jw, 0); event_fmt_prepare(event_name, file, line, NULL, &jw); + jw_object_string(&jw, "scope", scope_name); jw_object_string(&jw, "param", param); jw_object_string(&jw, "value", value); jw_end(&jw); diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c index c42fbade7f..69f8033077 100644 --- a/trace2/tr2_tgt_normal.c +++ b/trace2/tr2_tgt_normal.c @@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param, const char *value) { struct strbuf buf_payload = STRBUF_INIT; + enum config_scope scope = current_config_scope(); + const char *scope_name = config_scope_name(scope); - strbuf_addf(&buf_payload, "def_param %s=%s", param, value); + strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param, + value); normal_io_write_fl(file, line, &buf_payload); strbuf_release(&buf_payload); } diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c index a1eff8bea3..8cb792488c 100644 --- a/trace2/tr2_tgt_perf.c +++ b/trace2/tr2_tgt_perf.c @@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param, { const char *event_name = "def_param"; struct strbuf buf_payload = STRBUF_INIT; + struct strbuf scope_payload = STRBUF_INIT; + enum config_scope scope = current_config_scope(); + const char *scope_name = config_scope_name(scope); strbuf_addf(&buf_payload, "%s:%s", param, value); + strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name); - perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL, - &buf_payload); + perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, + scope_payload.buf, &buf_payload); strbuf_release(&buf_payload); + strbuf_release(&scope_payload); } static void fn_repo_fl(const char *file, int line,