{"thread":{"id":"58203","subject":"[PATCH 0/2] tr2: shows the scope unconditionally with config","startedAt":"2022-07-21T13:28:09Z","lastAt":"2022-08-19T21:18:43Z","messageCount":22,"participants":["tenglong.tl","Junio C Hamano","Ævar Arnfjörð Bjarmason","Teng Long"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"459618","messageId":"20220721132748.37848-1-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":null,"subject":"[PATCH 0/2] tr2: shows the scope unconditionally with config","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-21T13:27:46Z","receivedAt":"2022-07-21T13:28:09Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nThis series is separated from :\n\n  https://public-inbox.org/git/a01ae8478d3a8545241c5b064b6d369a330ee59f.1658159746.git.dyroneteng@gmail.com/\n\nand now move to a independent topic now.\n\nThanks.\n\n\nTeng Long (2):\n  api-trace2.txt: print config key-value pair\n  tr2: shows scope unconditionally in addition to key-value pair\n\n Documentation/technical/api-trace2.txt | 41 ++++++++++++++++++++++++++\n trace2/tr2_tgt_event.c                 |  3 ++\n trace2/tr2_tgt_normal.c                |  5 +++-\n trace2/tr2_tgt_perf.c                  |  9 ++++--\n 4 files changed, 55 insertions(+), 3 deletions(-)\n\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"459619","messageId":"20220721132748.37848-2-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"20220721132748.37848-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH 1/2] api-trace2.txt: print config key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-21T13:27:47Z","receivedAt":"2022-07-21T13:28:11Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nIt's supported to print \"interesting\" config key-value paire\nto tr2 log by setting \"GIT_TRACE2_CONFIG_PARAMS\" environment\nvariable and the \"trace2.configparam\" config, let's add the\nrelated docs in Documentaion/technical/api-trace2.txt.\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/technical/api-trace2.txt | 31 ++++++++++++++++++++++++++\n 1 file changed, 31 insertions(+)\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex 77a150b30e..dcd0429037 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -1207,6 +1207,37 @@ at offset 508.\n This example also shows that thread names are assigned in a racy manner\n as each thread starts and allocates TLS storage.\n \n+Print Configs::\n+\n+\t  Dump \"interesting\" config values to trace2 log.\n++\n+The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n+`trace2.configparams` can be used to output config values which you care\n+about(see linkgit:git-config[1). For example:\n++\n+----------------\n+$ git config color.ui auto\n+----------------\n++\n+Then, mark the config `color.ui` as \"interesting\" config with\n+`GIT_TRACE2_CONFIG_PARAMS`:\n++\n+----------------\n+$ export GIT_TRACE2_PERF_BRIEF=1\n+$ export GIT_TRACE2_PERF=~/log.perf\n+$ export GIT_TRACE2_CONFIG_PARAMS=color.ui\n+$ git version\n+...\n+$ cat ~/log.perf\n+d0 | main                     | version      |     |           |           |              | ...\n+d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n+d0 | main                     | cmd_name     |     |           |           |              | version (version)\n+d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n+d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n+d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+----------------\n == Future Work\n \n === Relationship to the Existing Trace Api (api-trace.txt)\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"459620","messageId":"20220721132748.37848-3-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"20220721132748.37848-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-21T13:27:48Z","receivedAt":"2022-07-21T13:28:14Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nWhen we specify GIT_TRACE2_CONFIG_PARAMS or trace2.configparams,\ntrace2 will prints \"interesting\" config values to log. Sometimes,\nwhen a config set in multiple scope files, the following output\nlooks like (the irrelevant fields are omitted here as \"...\"):\n\n...| def_param    |  ...  | core.multipackindex:false\n...| def_param    |  ...  | core.multipackindex:false\n...| def_param    |  ...  | core.multipackindex:false\n\nAs the log shows, even each config in different scope is dumped, but\nwe don't know which scope it comes from. Therefore, it's better to\nadd the scope names as well to make them be more recognizable. For\nexample, when execute:\n\n    $ GIT_TRACE2_PERF=1 \\\n    > GIT_TRACE2_CONFIG_PARAMS=core.multipackIndex \\\n    > git rev-list --test-bitmap HEAD\"\n\nThe following is the ouput (the irrelevant fields are omitted here\nas \"...\"):\n\nFormat normal:\n... git.c:461 ... def_param scope:system core.multipackindex=false\n... git.c:461 ... def_param scope:global core.multipackindex=false\n... git.c:461 ... def_param scope:local core.multipackindex=false\n\nFormat perf:\n\n... | def_param    | ... | scope:system | core.multipackindex:false\n... | def_param    | ... | scope:global | core.multipackindex:false\n... | def_param    | ... | scope:local  | core.multipackindex:false\n\nFormat event:\n\n{\"event\":\"def_param\", ... ,\"scope\":\"system\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n{\"event\":\"def_param\", ... ,\"scope\":\"global\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n{\"event\":\"def_param\", ... ,\"scope\":\"local\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/technical/api-trace2.txt | 20 +++++++++++++++-----\n trace2/tr2_tgt_event.c                 |  3 +++\n trace2/tr2_tgt_normal.c                |  5 ++++-\n trace2/tr2_tgt_perf.c                  |  9 +++++++--\n 4 files changed, 29 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex dcd0429037..229f31ab31 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -717,6 +717,7 @@ The \"exec_id\" field is a command-unique id and is only useful if the\n {\n \t\"event\":\"def_param\",\n \t...\n+\tscope: <a string that 'git config --show-scope' would return>\n \t\"param\":\"core.abbrev\",\n \t\"value\":\"7\"\n }\n@@ -1213,10 +1214,17 @@ Print Configs::\n +\n The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n `trace2.configparams` can be used to output config values which you care\n-about(see linkgit:git-config[1). For example:\n+about(see linkgit:git-config[1). For example assume that we want to config\n+different `color.ui` values in multiple scopes, such as:\n +\n ----------------\n-$ git config color.ui auto\n+$ git config --system color.ui never\n+$ git config --global color.ui always\n+$ git config --local color.ui auto\n+$ git config --list --show-scope | grep 'color.ui'\n+system  color.ui=never\n+global  color.ui=always\n+local   color.ui=auto\n ----------------\n +\n Then, mark the config `color.ui` as \"interesting\" config with\n@@ -1232,11 +1240,13 @@ $ cat ~/log.perf\n d0 | main                     | version      |     |           |           |              | ...\n d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n d0 | main                     | cmd_name     |     |           |           |              | version (version)\n-d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | def_param    |     |           |           | scope:system | color.ui:never\n+d0 | main                     | def_param    |     |           |           | scope:global | color.ui:always\n+d0 | main                     | def_param    |     |           |           | scope:local  | color.ui:auto\n d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n-d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n-d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+d0 | main                     | exit         |     |  0.000470 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.000477 |           |              | code:0\n ----------------\n == Future Work\n \ndiff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c\nindex c5c8cfbbaa..37a3163be1 100644\n--- a/trace2/tr2_tgt_event.c\n+++ b/trace2/tr2_tgt_event.c\n@@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,\n {\n \tconst char *event_name = \"def_param\";\n \tstruct json_writer jw = JSON_WRITER_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n \tjw_object_begin(&jw, 0);\n \tevent_fmt_prepare(event_name, file, line, NULL, &jw);\n+\tjw_object_string(&jw, \"scope\", scope_name);\n \tjw_object_string(&jw, \"param\", param);\n \tjw_object_string(&jw, \"value\", value);\n \tjw_end(&jw);\ndiff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c\nindex c42fbade7f..69f8033077 100644\n--- a/trace2/tr2_tgt_normal.c\n+++ b/trace2/tr2_tgt_normal.c\n@@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,\n \t\t\tconst char *value)\n {\n \tstruct strbuf buf_payload = STRBUF_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n-\tstrbuf_addf(&buf_payload, \"def_param %s=%s\", param, value);\n+\tstrbuf_addf(&buf_payload, \"def_param scope:%s %s=%s\", scope_name, param,\n+\t\t    value);\n \tnormal_io_write_fl(file, line, &buf_payload);\n \tstrbuf_release(&buf_payload);\n }\ndiff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c\nindex a1eff8bea3..8cb792488c 100644\n--- a/trace2/tr2_tgt_perf.c\n+++ b/trace2/tr2_tgt_perf.c\n@@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,\n {\n \tconst char *event_name = \"def_param\";\n \tstruct strbuf buf_payload = STRBUF_INIT;\n+\tstruct strbuf scope_payload = STRBUF_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n \tstrbuf_addf(&buf_payload, \"%s:%s\", param, value);\n+\tstrbuf_addf(&scope_payload, \"%s:%s\", \"scope\", scope_name);\n \n-\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,\n-\t\t\t &buf_payload);\n+\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL,\n+\t\t\t scope_payload.buf, &buf_payload);\n \tstrbuf_release(&buf_payload);\n+\tstrbuf_release(&scope_payload);\n }\n \n static void fn_repo_fl(const char *file, int line,\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"459662","messageId":"xmqqh73ajteh.fsf@gitster.g","threadId":"58203","inReplyTo":"20220721132748.37848-3-tenglong.tl@alibaba-inc.com","subject":"Re: [PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-21T16:57:10Z","receivedAt":"2022-07-21T16:57:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"tenglong.tl\" <dyroneteng@gmail.com> writes:\n\n> diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\n> index dcd0429037..229f31ab31 100644\n> --- a/Documentation/technical/api-trace2.txt\n> +++ b/Documentation/technical/api-trace2.txt\n> @@ -717,6 +717,7 @@ The \"exec_id\" field is a command-unique id and is only useful if the\n>  {\n>  \t\"event\":\"def_param\",\n>  \t...\n> +\tscope: <a string that 'git config --show-scope' would return>\n>  \t\"param\":\"core.abbrev\",\n>  \t\"value\":\"7\"\n>  }\n\nEverything in these examples use concrete values and follow the real\nsyntax (e.g. param is enclosed in double-quotes and so is its value\ncore.abbrev; even though core.abbrev is not the only param that can\nbe reported by a def-param event, it is used as a concrete example.\nThe same story goes for value).  The new \"scope\" thing stands out\nlike a sore thumb.  I think the above should read more like\n\n\t\"event\":\"def_param\",\n\t...\n\t\"scope\":\"global\",\n\t\"param\":\"core.abbrev\",\n\t\"value\":\"7\"\n\nor something.  Pick your favourite value for scope.\n\nOther than that, these two patches make quite a lot of sense.\n\nThanks.\n"},{"id":"459754","messageId":"20220722061240.9348-1-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"xmqqh73ajteh.fsf@gitster.g","subject":"Re: [PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-22T06:12:40Z","receivedAt":"2022-07-22T06:12:52Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Everything in these examples use concrete values and follow the real\n> syntax (e.g. param is enclosed in double-quotes and so is its value\n> core.abbrev; even though core.abbrev is not the only param that can\n> be reported by a def-param event, it is used as a concrete example.\n> The same story goes for value).  The new \"scope\" thing stands out\n> like a sore thumb.  I think the above should read more like\n>\n> \t\"event\":\"def_param\",\n> \t...\n> \t\"scope\":\"global\",\n> \t\"param\":\"core.abbrev\",\n> \t\"value\":\"7\"\n>\n> or something.  Pick your favourite value for scope.\n>\n> Other than that, these two patches make quite a lot of sense.\n\nYes. I think you are right, in this context, we should obey the same syntax\nand will fix in next patch.\n\nThanks.\n"},{"id":"459759","messageId":"cover.1658472474.git.dyroneteng@gmail.com","threadId":"58203","inReplyTo":"20220721132748.37848-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH v1 0/2] tr2: shows the scope unconditionally with config","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-22T08:19:30Z","receivedAt":"2022-07-22T08:19:59Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nChanges since the initial patch:\n\n1. [1/2] optimize the \"scope\" field representation with real syntax and\nconcrete value.\n\nThanks.\n\nTeng Long (2):\n  api-trace2.txt: print config key-value pair\n  tr2: shows scope unconditionally in addition to key-value pair\n\n Documentation/technical/api-trace2.txt | 41 ++++++++++++++++++++++++++\n trace2/tr2_tgt_event.c                 |  3 ++\n trace2/tr2_tgt_normal.c                |  5 +++-\n trace2/tr2_tgt_perf.c                  |  9 ++++--\n 4 files changed, 55 insertions(+), 3 deletions(-)\n\nRange-diff against v0:\n1:  bebd97c832 ! 1:  32f8b9ae6b api-trace2.txt: print config key-value pair\n    @@ Commit message\n         Signed-off-by: Teng Long <dyroneteng@gmail.com>\n     \n      ## Documentation/technical/api-trace2.txt ##\n    +@@ Documentation/technical/api-trace2.txt: The \"exec_id\" field is a command-unique id and is only useful if the\n    + {\n    + \t\"event\":\"def_param\",\n    + \t...\n    ++\t\"scope\":\"global\",\n    + \t\"param\":\"core.abbrev\",\n    + \t\"value\":\"7\"\n    + }\n     @@ Documentation/technical/api-trace2.txt: at offset 508.\n      This example also shows that thread names are assigned in a racy manner\n      as each thread starts and allocates TLS storage.\n2:  2f8fce6599 ! 2:  78575cca0b tr2: shows scope unconditionally in addition to key-value pair\n    @@ Commit message\n         Signed-off-by: Teng Long <dyroneteng@gmail.com>\n     \n      ## Documentation/technical/api-trace2.txt ##\n    -@@ Documentation/technical/api-trace2.txt: The \"exec_id\" field is a command-unique id and is only useful if the\n    - {\n    - \t\"event\":\"def_param\",\n    - \t...\n    -+\tscope: <a string that 'git config --show-scope' would return>\n    - \t\"param\":\"core.abbrev\",\n    - \t\"value\":\"7\"\n    - }\n     @@ Documentation/technical/api-trace2.txt: Print Configs::\n      +\n      The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"459760","messageId":"32f8b9ae6bb6aff0ce55ee494c4c0d40c672752b.1658472474.git.dyroneteng@gmail.com","threadId":"58203","inReplyTo":"cover.1658472474.git.dyroneteng@gmail.com","subject":"[PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-22T08:19:31Z","receivedAt":"2022-07-22T08:20:06Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nIt's supported to print \"interesting\" config key-value paire\nto tr2 log by setting \"GIT_TRACE2_CONFIG_PARAMS\" environment\nvariable and the \"trace2.configparam\" config, let's add the\nrelated docs in Documentaion/technical/api-trace2.txt.\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++\n 1 file changed, 32 insertions(+)\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex 77a150b30e..ddc0bfb9c9 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -717,6 +717,7 @@ The \"exec_id\" field is a command-unique id and is only useful if the\n {\n \t\"event\":\"def_param\",\n \t...\n+\t\"scope\":\"global\",\n \t\"param\":\"core.abbrev\",\n \t\"value\":\"7\"\n }\n@@ -1207,6 +1208,37 @@ at offset 508.\n This example also shows that thread names are assigned in a racy manner\n as each thread starts and allocates TLS storage.\n \n+Print Configs::\n+\n+\t  Dump \"interesting\" config values to trace2 log.\n++\n+The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n+`trace2.configparams` can be used to output config values which you care\n+about(see linkgit:git-config[1). For example:\n++\n+----------------\n+$ git config color.ui auto\n+----------------\n++\n+Then, mark the config `color.ui` as \"interesting\" config with\n+`GIT_TRACE2_CONFIG_PARAMS`:\n++\n+----------------\n+$ export GIT_TRACE2_PERF_BRIEF=1\n+$ export GIT_TRACE2_PERF=~/log.perf\n+$ export GIT_TRACE2_CONFIG_PARAMS=color.ui\n+$ git version\n+...\n+$ cat ~/log.perf\n+d0 | main                     | version      |     |           |           |              | ...\n+d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n+d0 | main                     | cmd_name     |     |           |           |              | version (version)\n+d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n+d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n+d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+----------------\n == Future Work\n \n === Relationship to the Existing Trace Api (api-trace.txt)\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"459761","messageId":"78575cca0b3ef4acb1bb42a00ccd3104f3fa4cea.1658472474.git.dyroneteng@gmail.com","threadId":"58203","inReplyTo":"cover.1658472474.git.dyroneteng@gmail.com","subject":"[PATCH v1 2/2] tr2: shows scope unconditionally in addition to key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-22T08:19:32Z","receivedAt":"2022-07-22T08:20:08Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nWhen we specify GIT_TRACE2_CONFIG_PARAMS or trace2.configparams,\ntrace2 will prints \"interesting\" config values to log. Sometimes,\nwhen a config set in multiple scope files, the following output\nlooks like (the irrelevant fields are omitted here as \"...\"):\n\n...| def_param    |  ...  | core.multipackindex:false\n...| def_param    |  ...  | core.multipackindex:false\n...| def_param    |  ...  | core.multipackindex:false\n\nAs the log shows, even each config in different scope is dumped, but\nwe don't know which scope it comes from. Therefore, it's better to\nadd the scope names as well to make them be more recognizable. For\nexample, when execute:\n\n    $ GIT_TRACE2_PERF=1 \\\n    > GIT_TRACE2_CONFIG_PARAMS=core.multipackIndex \\\n    > git rev-list --test-bitmap HEAD\"\n\nThe following is the ouput (the irrelevant fields are omitted here\nas \"...\"):\n\nFormat normal:\n... git.c:461 ... def_param scope:system core.multipackindex=false\n... git.c:461 ... def_param scope:global core.multipackindex=false\n... git.c:461 ... def_param scope:local core.multipackindex=false\n\nFormat perf:\n\n... | def_param    | ... | scope:system | core.multipackindex:false\n... | def_param    | ... | scope:global | core.multipackindex:false\n... | def_param    | ... | scope:local  | core.multipackindex:false\n\nFormat event:\n\n{\"event\":\"def_param\", ... ,\"scope\":\"system\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n{\"event\":\"def_param\", ... ,\"scope\":\"global\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n{\"event\":\"def_param\", ... ,\"scope\":\"local\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/technical/api-trace2.txt | 19 ++++++++++++++-----\n trace2/tr2_tgt_event.c                 |  3 +++\n trace2/tr2_tgt_normal.c                |  5 ++++-\n trace2/tr2_tgt_perf.c                  |  9 +++++++--\n 4 files changed, 28 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex ddc0bfb9c9..534cfa98fa 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -1214,10 +1214,17 @@ Print Configs::\n +\n The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n `trace2.configparams` can be used to output config values which you care\n-about(see linkgit:git-config[1). For example:\n+about(see linkgit:git-config[1). For example assume that we want to config\n+different `color.ui` values in multiple scopes, such as:\n +\n ----------------\n-$ git config color.ui auto\n+$ git config --system color.ui never\n+$ git config --global color.ui always\n+$ git config --local color.ui auto\n+$ git config --list --show-scope | grep 'color.ui'\n+system  color.ui=never\n+global  color.ui=always\n+local   color.ui=auto\n ----------------\n +\n Then, mark the config `color.ui` as \"interesting\" config with\n@@ -1233,11 +1240,13 @@ $ cat ~/log.perf\n d0 | main                     | version      |     |           |           |              | ...\n d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n d0 | main                     | cmd_name     |     |           |           |              | version (version)\n-d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | def_param    |     |           |           | scope:system | color.ui:never\n+d0 | main                     | def_param    |     |           |           | scope:global | color.ui:always\n+d0 | main                     | def_param    |     |           |           | scope:local  | color.ui:auto\n d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n-d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n-d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+d0 | main                     | exit         |     |  0.000470 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.000477 |           |              | code:0\n ----------------\n == Future Work\n \ndiff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c\nindex c5c8cfbbaa..37a3163be1 100644\n--- a/trace2/tr2_tgt_event.c\n+++ b/trace2/tr2_tgt_event.c\n@@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,\n {\n \tconst char *event_name = \"def_param\";\n \tstruct json_writer jw = JSON_WRITER_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n \tjw_object_begin(&jw, 0);\n \tevent_fmt_prepare(event_name, file, line, NULL, &jw);\n+\tjw_object_string(&jw, \"scope\", scope_name);\n \tjw_object_string(&jw, \"param\", param);\n \tjw_object_string(&jw, \"value\", value);\n \tjw_end(&jw);\ndiff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c\nindex c42fbade7f..69f8033077 100644\n--- a/trace2/tr2_tgt_normal.c\n+++ b/trace2/tr2_tgt_normal.c\n@@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,\n \t\t\tconst char *value)\n {\n \tstruct strbuf buf_payload = STRBUF_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n-\tstrbuf_addf(&buf_payload, \"def_param %s=%s\", param, value);\n+\tstrbuf_addf(&buf_payload, \"def_param scope:%s %s=%s\", scope_name, param,\n+\t\t    value);\n \tnormal_io_write_fl(file, line, &buf_payload);\n \tstrbuf_release(&buf_payload);\n }\ndiff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c\nindex a1eff8bea3..8cb792488c 100644\n--- a/trace2/tr2_tgt_perf.c\n+++ b/trace2/tr2_tgt_perf.c\n@@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,\n {\n \tconst char *event_name = \"def_param\";\n \tstruct strbuf buf_payload = STRBUF_INIT;\n+\tstruct strbuf scope_payload = STRBUF_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n \tstrbuf_addf(&buf_payload, \"%s:%s\", param, value);\n+\tstrbuf_addf(&scope_payload, \"%s:%s\", \"scope\", scope_name);\n \n-\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,\n-\t\t\t &buf_payload);\n+\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL,\n+\t\t\t scope_payload.buf, &buf_payload);\n \tstrbuf_release(&buf_payload);\n+\tstrbuf_release(&scope_payload);\n }\n \n static void fn_repo_fl(const char *file, int line,\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"459766","messageId":"220722.86fsits91m.gmgdl@evledraar.gmail.com","threadId":"58203","inReplyTo":"32f8b9ae6bb6aff0ce55ee494c4c0d40c672752b.1658472474.git.dyroneteng@gmail.com","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-07-22T10:59:12Z","receivedAt":"2022-07-22T11:04:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Jul 22 2022, tenglong.tl wrote:\n\n> From: Teng Long <dyroneteng@gmail.com>\n>\n> It's supported to print \"interesting\" config key-value paire\n> to tr2 log by setting \"GIT_TRACE2_CONFIG_PARAMS\" environment\n> variable and the \"trace2.configparam\" config, let's add the\n> related docs in Documentaion/technical/api-trace2.txt.\n>\n> Signed-off-by: Teng Long <dyroneteng@gmail.com>\n> ---\n>  Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n> diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\n> index 77a150b30e..ddc0bfb9c9 100644\n> --- a/Documentation/technical/api-trace2.txt\n> +++ b/Documentation/technical/api-trace2.txt\n> @@ -717,6 +717,7 @@ The \"exec_id\" field is a command-unique id and is only useful if the\n>  {\n>  \t\"event\":\"def_param\",\n>  \t...\n> +\t\"scope\":\"global\",\n>  \t\"param\":\"core.abbrev\",\n>  \t\"value\":\"7\"\n>  }\n> @@ -1207,6 +1208,37 @@ at offset 508.\n>  This example also shows that thread names are assigned in a racy manner\n>  as each thread starts and allocates TLS storage.\n>  \n> +Print Configs::\n> +\n> +\t  Dump \"interesting\" config values to trace2 log.\n> ++\n> +The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n> +`trace2.configparams` can be used to output config values which you care\n> +about(see linkgit:git-config[1). For example:\n\nI didn't notice this before, but this is an addition to a long section\nwhere the examples are ------- delimited, starting with \"in this\nexample..\" usually.\n\nSo this \"print configs\" seems like on odd continuation. Shouldn't this\ncopy the template of \"Thread Events::\" above. I.e. something like (I\nhave not tried to asciidoc render this):\n\t\n\tConfig (def param) Events::\n\t\tWe can optionally emit configuration events, see\n\t\t`trace2.configParams` in linkgit:git-config[1] for how to enable\n\t\tit.\n\t+\n\t< your example below would follow this>\n\nI.e. re my earlier mention of git-config we it explains\nGIT_TRACE2_CONFIG_PARAMS, so perhaps it suffices to just link to\nlinkgit:git-config[1] for that.\n\nAlso a nit: trace2.configParams, not trace2.configparams.\n\t\n> ++\n> +----------------\n> +$ git config color.ui auto\n> +----------------\n> ++\n> +Then, mark the config `color.ui` as \"interesting\" config with\n> +`GIT_TRACE2_CONFIG_PARAMS`:\n> ++\n> +----------------\n> +$ export GIT_TRACE2_PERF_BRIEF=1\n> +$ export GIT_TRACE2_PERF=~/log.perf\n> +$ export GIT_TRACE2_CONFIG_PARAMS=color.ui\n> +$ git version\n> +...\n> +$ cat ~/log.perf\n> +d0 | main                     | version      |     |           |           |              | ...\n> +d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n> +d0 | main                     | cmd_name     |     |           |           |              | version (version)\n> +d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n> +d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n> +d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n> +d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n> +d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n> +----------------\n>  == Future Work\n>  \n>  === Relationship to the Existing Trace Api (api-trace.txt)\n\n"},{"id":"459795","messageId":"xmqqy1wkc0yw.fsf@gitster.g","threadId":"58203","inReplyTo":"32f8b9ae6bb6aff0ce55ee494c4c0d40c672752b.1658472474.git.dyroneteng@gmail.com","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-22T21:05:27Z","receivedAt":"2022-07-22T21:05:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"tenglong.tl\" <dyroneteng@gmail.com> writes:\n\n> From: Teng Long <dyroneteng@gmail.com>\n>\n> It's supported to print \"interesting\" config key-value paire\n> to tr2 log by setting \"GIT_TRACE2_CONFIG_PARAMS\" environment\n> variable and the \"trace2.configparam\" config, let's add the\n> related docs in Documentaion/technical/api-trace2.txt.\n>\n> Signed-off-by: Teng Long <dyroneteng@gmail.com>\n> ---\n>  Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n> diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\n> index 77a150b30e..ddc0bfb9c9 100644\n> --- a/Documentation/technical/api-trace2.txt\n> +++ b/Documentation/technical/api-trace2.txt\n> @@ -717,6 +717,7 @@ The \"exec_id\" field is a command-unique id and is only useful if the\n>  {\n>  \t\"event\":\"def_param\",\n>  \t...\n> +\t\"scope\":\"global\",\n>  \t\"param\":\"core.abbrev\",\n>  \t\"value\":\"7\"\n>  }\n\nIsn't this a bit premature to do in [PATCH 1/2]?\n"},{"id":"459829","messageId":"20220723060619.24566-1-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"xmqqy1wkc0yw.fsf@gitster.g","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-23T06:06:19Z","receivedAt":"2022-07-23T06:06:35Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"> Isn't this a bit premature to do in [PATCH 1/2]?\n\nYes, one oversight, sorry for that and will fix.\n\nThanks.\n"},{"id":"459838","messageId":"xmqqilnnafh2.fsf@gitster.g","threadId":"58203","inReplyTo":"20220723060619.24566-1-tenglong.tl@alibaba-inc.com","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-23T17:47:21Z","receivedAt":"2022-07-23T17:47:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"tenglong.tl\" <dyroneteng@gmail.com> writes:\n\n>> Isn't this a bit premature to do in [PATCH 1/2]?\n>\n> Yes, one oversight, sorry for that and will fix.\n\nI've tweaked with \"rebase -i\" after queuing and before pushing the\nintegration result out, so if you can double check the result to\nmake sure I didn't screw up, there is no need to resend.\n\nThanks.\n"},{"id":"459858","messageId":"20220725091818.22909-1-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"xmqqilnnafh2.fsf@gitster.g","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-07-25T09:18:18Z","receivedAt":"2022-07-25T09:18:31Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I've tweaked with \"rebase -i\" after queuing and before pushing the\n> integration result out, so if you can double check the result to\n> make sure I didn't screw up, there is no need to resend.\n\nOK, got it. There is no inconsistency in understanding, I agree with\nyour suggestion.\n\nThanks for explanation.\n"},{"id":"459907","messageId":"xmqqczdt3tb6.fsf@gitster.g","threadId":"58203","inReplyTo":"220722.86fsits91m.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-25T19:07:09Z","receivedAt":"2022-07-25T19:07:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Fri, Jul 22 2022, tenglong.tl wrote:\n> ...\n>> +Print Configs::\n>> +\n>> +\t  Dump \"interesting\" config values to trace2 log.\n>> ++\n>> +The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n>> +`trace2.configparams` can be used to output config values which you care\n>> +about(see linkgit:git-config[1). For example:\n>\n> I didn't notice this before, but this is an addition to a long section\n> where the examples are ------- delimited, starting with \"in this\n> example..\" usually.\n>\n> So this \"print configs\" seems like on odd continuation. Shouldn't this\n> copy the template of \"Thread Events::\" above. I.e. something like (I\n> have not tried to asciidoc render this):\n> \t\n> \tConfig (def param) Events::\n> \t\tWe can optionally emit configuration events, see\n> \t\t`trace2.configParams` in linkgit:git-config[1] for how to enable\n> \t\tit.\n> \t+\n> \t< your example below would follow this>\n>\n> I.e. re my earlier mention of git-config we it explains\n> GIT_TRACE2_CONFIG_PARAMS, so perhaps it suffices to just link to\n> linkgit:git-config[1] for that.\n>\n> Also a nit: trace2.configParams, not trace2.configparams.\n\nThese may be worth fixing, regardless of the \"adding scope in the\nexample needs to wait until 2/2\" I pointed out separately.\n\nThanks.\n"},{"id":"460346","messageId":"20220801122515.23146-1-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"220722.86fsits91m.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"tenglong.tl","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-08-01T12:25:15Z","receivedAt":"2022-08-01T12:43:33Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> I didn't notice this before, but this is an addition to a long section\n> where the examples are ------- delimited, starting with \"in this\n> example..\" usually.\n\nA little puzzled. About \"------- delimited\", do you mean the \"block\" syntax?\n\n> So this \"print configs\" seems like on odd continuation. Shouldn't this\n> copy the template of \"Thread Events::\" above. I.e. something like (I\n> have not tried to asciidoc render this):\n\nI think \"Events\" in \"Thread Events\" means the thread start and end events,\nmaybe not a template here. So I think it might be better to keep this namingi\nif I'm right, but I will use this candidate naming to show diff in the end.\n\nI'm not good at naming so I'm glad to accept the suggestion about it.\n\n>\tConfig (def param) Events::\n>\t\tWe can optionally emit configuration events, see\n>\t\t`trace2.configParams` in linkgit:git-config[1] for how to enable\n>\t\tit.\n>\t+\n>\t< your example below would follow this>\n\nI refer to the previous sections, it's like the template is :\n\n<title>\n\n        <brief one-line description>\n\n<detailed multi-lines description>\n\nSo, how about this like:\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex 77a150b30e..38d0878d85 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -1207,6 +1207,37 @@ at offset 508.\n This example also shows that thread names are assigned in a racy manner\n as each thread starts and allocates TLS storage.\n\n+Config (def param) Events::\n+\n+         Dump \"interesting\" config values to trace2 log.\n++\n+We can optionally emit configuration events, see\n+`trace2.configparams` in linkgit:git-config[1] for how to enable\n+it.\n++\n+----------------\n+$ git config color.ui auto\n+----------------\n++\n+Then, mark the config `color.ui` as \"interesting\" config with\n+`GIT_TRACE2_CONFIG_PARAMS`:\n++\n+----------------\n+$ export GIT_TRACE2_PERF_BRIEF=1\n+$ export GIT_TRACE2_PERF=~/log.perf\n+$ export GIT_TRACE2_CONFIG_PARAMS=color.ui\n+$ git version\n+...\n+$ cat ~/log.perf\n+d0 | main                     | version      |     |           |           |              | ...\n+d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n+d0 | main                     | cmd_name     |     |           |           |              | version (version)\n+d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n+d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n+d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+----------------\n == Future Work\n\n === Relationship to the Existing Trace Api (api-trace.txt)\n\nThanks.\n"},{"id":"460742","messageId":"xmqqa68iz5yx.fsf@gitster.g","threadId":"58203","inReplyTo":"20220801122515.23146-1-tenglong.tl@alibaba-inc.com","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-05T22:21:58Z","receivedAt":"2022-08-05T22:22:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"tenglong.tl\" <dyroneteng@gmail.com> writes:\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> I didn't notice this before, but this is an addition to a long section\n> ...\n> I refer to the previous sections, it's like the template is :\n>\n> <title>\n>\n>         <brief one-line description>\n>\n> <detailed multi-lines description>\n>\n> So, how about this like:\n>\n> diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\n> index 77a150b30e..38d0878d85 100644\n> --- a/Documentation/technical/api-trace2.txt\n> +++ b/Documentation/technical/api-trace2.txt\n> @@ -1207,6 +1207,37 @@ at offset 508.\n\nSo, what is the outcome from this discussion?  It seems that this\nsubthread on [1/2] is blocking the two-patch series?\n\nThanks.\n"},{"id":"460805","messageId":"20220808061636.88692-1-tenglong.tl@alibaba-inc.com","threadId":"58203","inReplyTo":"xmqqa68iz5yx.fsf@gitster.g","subject":"Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-08-08T06:16:36Z","receivedAt":"2022-08-08T06:16:46Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"\nJunio C Hamano <gitster@pobox.com> writes:\n\n> So, what is the outcome from this discussion?  It seems that this\n> subthread on [1/2] is blocking the two-patch series?\n\nI think it's blocking. I replied a comment to comfirm that I understand Ævar\nArnfjörð Bjarmason's suggestion and also there is an improvement change in it:\n\n  https://public-inbox.org/git/20220801122515.23146-1-tenglong.tl@alibaba-inc.com/\n\nThanks.\n"},{"id":"461108","messageId":"cover.1660272404.git.dyroneteng@gmail.com","threadId":"58203","inReplyTo":"cover.1658472474.git.dyroneteng@gmail.com","subject":"[PATCH v2 0/2] tr2: shows the scope unconditionally with config","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-08-12T02:56:44Z","receivedAt":"2022-08-12T02:57:01Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nDiff from v1:\n\n* Fix the premature code in [1/2] by Junio's comment in:\n\n  https://public-inbox.org/git/xmqqy1wkc0yw.fsf@gitster.g/\n\n* Optimize the documentaion in [1/2] by Ævar's comment in:\n\n  https://public-inbox.org/git/220722.86fsits91m.gmgdl@evledraar.gmail.com/\n\nI send this patch version a little earlier maybe because some context not fully\ndiscussed or solved, intend to avoid context signal disappearance because it's\nbeen lasted a while now. \n\nThanks.\n\nTeng Long (2):\n  api-trace2.txt: print config key-value pair\n  tr2: shows scope unconditionally in addition to key-value pair\n\n Documentation/technical/api-trace2.txt | 40 ++++++++++++++++++++++++++\n trace2/tr2_tgt_event.c                 |  3 ++\n trace2/tr2_tgt_normal.c                |  5 +++-\n trace2/tr2_tgt_perf.c                  |  9 ++++--\n 4 files changed, 54 insertions(+), 3 deletions(-)\n\nRange-diff against v1:\n1:  bebd97c832 ! 1:  84bd8a71d7 api-trace2.txt: print config key-value pair\n    @@ Documentation/technical/api-trace2.txt: at offset 508.\n      This example also shows that thread names are assigned in a racy manner\n      as each thread starts and allocates TLS storage.\n      \n    -+Print Configs::\n    ++Config (def param) Events::\n     +\n     +\t  Dump \"interesting\" config values to trace2 log.\n     ++\n    -+The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n    -+`trace2.configparams` can be used to output config values which you care\n    -+about(see linkgit:git-config[1). For example:\n    ++We can optionally emit configuration events, see\n    ++`trace2.configparams` in linkgit:git-config[1] for how to enable\n    ++it.\n     ++\n     +----------------\n     +$ git config color.ui auto\n2:  2f8fce6599 ! 2:  9856058df6 tr2: shows scope unconditionally in addition to key-value pair\n    @@ Documentation/technical/api-trace2.txt: The \"exec_id\" field is a command-unique\n      {\n      \t\"event\":\"def_param\",\n      \t...\n    -+\tscope: <a string that 'git config --show-scope' would return>\n    ++\t\"scope\":\"global\",\n      \t\"param\":\"core.abbrev\",\n      \t\"value\":\"7\"\n      }\n    -@@ Documentation/technical/api-trace2.txt: Print Configs::\n    - +\n    - The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration\n    - `trace2.configparams` can be used to output config values which you care\n    --about(see linkgit:git-config[1). For example:\n    -+about(see linkgit:git-config[1). For example assume that we want to config\n    -+different `color.ui` values in multiple scopes, such as:\n    +@@ Documentation/technical/api-trace2.txt: We can optionally emit configuration events, see\n    + it.\n      +\n      ----------------\n     -$ git config color.ui auto\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"461109","messageId":"84bd8a71d7a1adcbcc7ef954ff10ea932e430f1b.1660272404.git.dyroneteng@gmail.com","threadId":"58203","inReplyTo":"cover.1660272404.git.dyroneteng@gmail.com","subject":"[PATCH v2 1/2] api-trace2.txt: print config key-value pair","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-08-12T02:56:45Z","receivedAt":"2022-08-12T02:57:05Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nIt's supported to print \"interesting\" config key-value paire\nto tr2 log by setting \"GIT_TRACE2_CONFIG_PARAMS\" environment\nvariable and the \"trace2.configparam\" config, let's add the\nrelated docs in Documentaion/technical/api-trace2.txt.\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/technical/api-trace2.txt | 31 ++++++++++++++++++++++++++\n 1 file changed, 31 insertions(+)\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex 77a150b30e..38d0878d85 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -1207,6 +1207,37 @@ at offset 508.\n This example also shows that thread names are assigned in a racy manner\n as each thread starts and allocates TLS storage.\n \n+Config (def param) Events::\n+\n+\t  Dump \"interesting\" config values to trace2 log.\n++\n+We can optionally emit configuration events, see\n+`trace2.configparams` in linkgit:git-config[1] for how to enable\n+it.\n++\n+----------------\n+$ git config color.ui auto\n+----------------\n++\n+Then, mark the config `color.ui` as \"interesting\" config with\n+`GIT_TRACE2_CONFIG_PARAMS`:\n++\n+----------------\n+$ export GIT_TRACE2_PERF_BRIEF=1\n+$ export GIT_TRACE2_PERF=~/log.perf\n+$ export GIT_TRACE2_CONFIG_PARAMS=color.ui\n+$ git version\n+...\n+$ cat ~/log.perf\n+d0 | main                     | version      |     |           |           |              | ...\n+d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n+d0 | main                     | cmd_name     |     |           |           |              | version (version)\n+d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n+d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n+d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+----------------\n == Future Work\n \n === Relationship to the Existing Trace Api (api-trace.txt)\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"461110","messageId":"9856058df68d61557b11dc2fc7179acae24f5d8e.1660272404.git.dyroneteng@gmail.com","threadId":"58203","inReplyTo":"cover.1660272404.git.dyroneteng@gmail.com","subject":"[PATCH v2 2/2] tr2: shows scope unconditionally in addition to key-value pair","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-08-12T02:56:46Z","receivedAt":"2022-08-12T02:57:07Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nWhen we specify GIT_TRACE2_CONFIG_PARAMS or trace2.configparams,\ntrace2 will prints \"interesting\" config values to log. Sometimes,\nwhen a config set in multiple scope files, the following output\nlooks like (the irrelevant fields are omitted here as \"...\"):\n\n...| def_param    |  ...  | core.multipackindex:false\n...| def_param    |  ...  | core.multipackindex:false\n...| def_param    |  ...  | core.multipackindex:false\n\nAs the log shows, even each config in different scope is dumped, but\nwe don't know which scope it comes from. Therefore, it's better to\nadd the scope names as well to make them be more recognizable. For\nexample, when execute:\n\n    $ GIT_TRACE2_PERF=1 \\\n    > GIT_TRACE2_CONFIG_PARAMS=core.multipackIndex \\\n    > git rev-list --test-bitmap HEAD\"\n\nThe following is the ouput (the irrelevant fields are omitted here\nas \"...\"):\n\nFormat normal:\n... git.c:461 ... def_param scope:system core.multipackindex=false\n... git.c:461 ... def_param scope:global core.multipackindex=false\n... git.c:461 ... def_param scope:local core.multipackindex=false\n\nFormat perf:\n\n... | def_param    | ... | scope:system | core.multipackindex:false\n... | def_param    | ... | scope:global | core.multipackindex:false\n... | def_param    | ... | scope:local  | core.multipackindex:false\n\nFormat event:\n\n{\"event\":\"def_param\", ... ,\"scope\":\"system\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n{\"event\":\"def_param\", ... ,\"scope\":\"global\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n{\"event\":\"def_param\", ... ,\"scope\":\"local\",\"param\":\"core.multipackindex\",\"value\":\"false\"}\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/technical/api-trace2.txt | 17 +++++++++++++----\n trace2/tr2_tgt_event.c                 |  3 +++\n trace2/tr2_tgt_normal.c                |  5 ++++-\n trace2/tr2_tgt_perf.c                  |  9 +++++++--\n 4 files changed, 27 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt\nindex 38d0878d85..2afa28bb5a 100644\n--- a/Documentation/technical/api-trace2.txt\n+++ b/Documentation/technical/api-trace2.txt\n@@ -717,6 +717,7 @@ The \"exec_id\" field is a command-unique id and is only useful if the\n {\n \t\"event\":\"def_param\",\n \t...\n+\t\"scope\":\"global\",\n \t\"param\":\"core.abbrev\",\n \t\"value\":\"7\"\n }\n@@ -1216,7 +1217,13 @@ We can optionally emit configuration events, see\n it.\n +\n ----------------\n-$ git config color.ui auto\n+$ git config --system color.ui never\n+$ git config --global color.ui always\n+$ git config --local color.ui auto\n+$ git config --list --show-scope | grep 'color.ui'\n+system  color.ui=never\n+global  color.ui=always\n+local   color.ui=auto\n ----------------\n +\n Then, mark the config `color.ui` as \"interesting\" config with\n@@ -1232,11 +1239,13 @@ $ cat ~/log.perf\n d0 | main                     | version      |     |           |           |              | ...\n d0 | main                     | start        |     |  0.001642 |           |              | /usr/local/bin/git version\n d0 | main                     | cmd_name     |     |           |           |              | version (version)\n-d0 | main                     | def_param    |     |           |           |              | color.ui:auto\n+d0 | main                     | def_param    |     |           |           | scope:system | color.ui:never\n+d0 | main                     | def_param    |     |           |           | scope:global | color.ui:always\n+d0 | main                     | def_param    |     |           |           | scope:local  | color.ui:auto\n d0 | main                     | data         | r0  |  0.002100 |  0.002100 | fsync        | fsync/writeout-only:0\n d0 | main                     | data         | r0  |  0.002126 |  0.002126 | fsync        | fsync/hardware-flush:0\n-d0 | main                     | exit         |     |  0.002142 |           |              | code:0\n-d0 | main                     | atexit       |     |  0.002161 |           |              | code:0\n+d0 | main                     | exit         |     |  0.000470 |           |              | code:0\n+d0 | main                     | atexit       |     |  0.000477 |           |              | code:0\n ----------------\n == Future Work\n \ndiff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c\nindex c5c8cfbbaa..37a3163be1 100644\n--- a/trace2/tr2_tgt_event.c\n+++ b/trace2/tr2_tgt_event.c\n@@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,\n {\n \tconst char *event_name = \"def_param\";\n \tstruct json_writer jw = JSON_WRITER_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n \tjw_object_begin(&jw, 0);\n \tevent_fmt_prepare(event_name, file, line, NULL, &jw);\n+\tjw_object_string(&jw, \"scope\", scope_name);\n \tjw_object_string(&jw, \"param\", param);\n \tjw_object_string(&jw, \"value\", value);\n \tjw_end(&jw);\ndiff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c\nindex c42fbade7f..69f8033077 100644\n--- a/trace2/tr2_tgt_normal.c\n+++ b/trace2/tr2_tgt_normal.c\n@@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,\n \t\t\tconst char *value)\n {\n \tstruct strbuf buf_payload = STRBUF_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n-\tstrbuf_addf(&buf_payload, \"def_param %s=%s\", param, value);\n+\tstrbuf_addf(&buf_payload, \"def_param scope:%s %s=%s\", scope_name, param,\n+\t\t    value);\n \tnormal_io_write_fl(file, line, &buf_payload);\n \tstrbuf_release(&buf_payload);\n }\ndiff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c\nindex a1eff8bea3..8cb792488c 100644\n--- a/trace2/tr2_tgt_perf.c\n+++ b/trace2/tr2_tgt_perf.c\n@@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,\n {\n \tconst char *event_name = \"def_param\";\n \tstruct strbuf buf_payload = STRBUF_INIT;\n+\tstruct strbuf scope_payload = STRBUF_INIT;\n+\tenum config_scope scope = current_config_scope();\n+\tconst char *scope_name = config_scope_name(scope);\n \n \tstrbuf_addf(&buf_payload, \"%s:%s\", param, value);\n+\tstrbuf_addf(&scope_payload, \"%s:%s\", \"scope\", scope_name);\n \n-\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,\n-\t\t\t &buf_payload);\n+\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL,\n+\t\t\t scope_payload.buf, &buf_payload);\n \tstrbuf_release(&buf_payload);\n+\tstrbuf_release(&scope_payload);\n }\n \n static void fn_repo_fl(const char *file, int line,\n-- \n2.37.1.1.g8cbb44ffc4.dirty\n\n"},{"id":"461154","messageId":"xmqqo7wp9n7a.fsf@gitster.g","threadId":"58203","inReplyTo":"9856058df68d61557b11dc2fc7179acae24f5d8e.1660272404.git.dyroneteng@gmail.com","subject":"Re: [PATCH v2 2/2] tr2: shows scope unconditionally in addition to key-value pair","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-12T21:16:57Z","receivedAt":"2022-08-12T21:17:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Teng Long <dyroneteng@gmail.com> writes:\n\n> diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c\n> index c5c8cfbbaa..37a3163be1 100644\n> --- a/trace2/tr2_tgt_event.c\n> +++ b/trace2/tr2_tgt_event.c\n> @@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,\n>  {\n>  \tconst char *event_name = \"def_param\";\n>  \tstruct json_writer jw = JSON_WRITER_INIT;\n> +\tenum config_scope scope = current_config_scope();\n> +\tconst char *scope_name = config_scope_name(scope);\n>  \n>  \tjw_object_begin(&jw, 0);\n>  \tevent_fmt_prepare(event_name, file, line, NULL, &jw);\n> +\tjw_object_string(&jw, \"scope\", scope_name);\n>  \tjw_object_string(&jw, \"param\", param);\n>  \tjw_object_string(&jw, \"value\", value);\n>  \tjw_end(&jw);\n\nOK, that is quite straight-forward.\n\n> diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c\n> index c42fbade7f..69f8033077 100644\n> --- a/trace2/tr2_tgt_normal.c\n> +++ b/trace2/tr2_tgt_normal.c\n> @@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,\n>  \t\t\tconst char *value)\n>  {\n>  \tstruct strbuf buf_payload = STRBUF_INIT;\n> +\tenum config_scope scope = current_config_scope();\n> +\tconst char *scope_name = config_scope_name(scope);\n>  \n> -\tstrbuf_addf(&buf_payload, \"def_param %s=%s\", param, value);\n> +\tstrbuf_addf(&buf_payload, \"def_param scope:%s %s=%s\", scope_name, param,\n> +\t\t    value);\n>  \tnormal_io_write_fl(file, line, &buf_payload);\n>  \tstrbuf_release(&buf_payload);\n>  }\n\nSo is this one.  Quite nice.\n\nIs everybody happy with the choice of \":\" colon here, though?  The\none in tgt_perf below uses the same delimiter that is used between\n<param, value> to delimit <\"scope\", scome_name>.  I am wondering if\nthis one should use \"=\", the delimiter used between <param, value>\nin this output stream, to match.  I do not care at all either way,\nbut I am mentioning it because I happened have noticed it, and\nbecause somebody else may care.\n\nThanks, will queue.\n\n\n> diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c\n> index a1eff8bea3..8cb792488c 100644\n> --- a/trace2/tr2_tgt_perf.c\n> +++ b/trace2/tr2_tgt_perf.c\n> @@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,\n>  {\n>  \tconst char *event_name = \"def_param\";\n>  \tstruct strbuf buf_payload = STRBUF_INIT;\n> +\tstruct strbuf scope_payload = STRBUF_INIT;\n> +\tenum config_scope scope = current_config_scope();\n> +\tconst char *scope_name = config_scope_name(scope);\n>  \n>  \tstrbuf_addf(&buf_payload, \"%s:%s\", param, value);\n> +\tstrbuf_addf(&scope_payload, \"%s:%s\", \"scope\", scope_name);\n>  \n> -\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,\n> -\t\t\t &buf_payload);\n> +\tperf_io_write_fl(file, line, event_name, NULL, NULL, NULL,\n> +\t\t\t scope_payload.buf, &buf_payload);\n>  \tstrbuf_release(&buf_payload);\n> +\tstrbuf_release(&scope_payload);\n>  }\n>  \n>  static void fn_repo_fl(const char *file, int line,\n"},{"id":"461620","messageId":"xmqqpmgwj5jp.fsf@gitster.g","threadId":"58203","inReplyTo":"cover.1660272404.git.dyroneteng@gmail.com","subject":"Re: [PATCH v2 0/2] tr2: shows the scope unconditionally with config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-19T21:18:34Z","receivedAt":"2022-08-19T21:18:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Teng Long <dyroneteng@gmail.com> writes:\n\n> From: Teng Long <dyroneteng@gmail.com>\n>\n> Diff from v1:\n>\n> * Fix the premature code in [1/2] by Junio's comment in:\n>\n>   https://public-inbox.org/git/xmqqy1wkc0yw.fsf@gitster.g/\n>\n> * Optimize the documentaion in [1/2] by Ævar's comment in:\n>\n>   https://public-inbox.org/git/220722.86fsits91m.gmgdl@evledraar.gmail.com/\n>\n> I send this patch version a little earlier maybe because some context not fully\n> discussed or solved, intend to avoid context signal disappearance because it's\n> been lasted a while now. \n\nWe haven't seen any comments (other than mine) for a full week, and\nam wondering if everybody is happy with it.  Let me mark it for\n'next' in the draft of \"What's cooking\" and merge it down.\n"}]}