threads / patch / 58203

patch, 2 partstr2: shows the scope unconditionally with config

Subject: [PATCH 0/2] tr2: shows the scope unconditionally with config

## tl;dr

22 messages between Jul 21, 2022 and Aug 19, 2022. Diffs are folded; open one to read it.

replies: 21people: 3as markdown or json

tenglong.tl· Jul 21, 2022, 13:27 UTC · lore
From: Teng Long <dyroneteng@gmail.com>
This series is separated from :
  https://public-inbox.org/git/a01ae8478d3a8545241c5b064b6d369a330ee59f.1658159746.git.dyroneteng@gmail.com/
and now move to a independent topic now.
Thanks.
Teng Long (2):
  api-trace2.txt: print config key-value pair
  tr2: shows scope unconditionally in addition to key-value pair
 Documentation/technical/api-trace2.txt | 41 ++++++++++++++++++++++++++
 trace2/tr2_tgt_event.c                 |  3 ++
 trace2/tr2_tgt_normal.c                |  5 +++-
 trace2/tr2_tgt_perf.c                  |  9 ++++--
 4 files changed, 55 insertions(+), 3 deletions(-)
-- 
2.37.1.1.g8cbb44ffc4.dirty
tenglong.tl· Jul 21, 2022, 13:27 UTC · re: tenglong.tl · lore

[PATCH 1/2] api-trace2.txt: print config key-value pair

From: Teng Long <dyroneteng@gmail.com>

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 <dyroneteng@gmail.com>
---
 Documentation/technical/api-trace2.txt | 31 ++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
Show changes to Documentation/technical/api-trace2.txt +31 −0
diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 77a150b30e..dcd0429037 100644
--- a/Documentation/technical/api-trace2.txt
+++ b/Documentation/technical/api-trace2.txt
@@ -1207,6 +1207,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)
-- 
2.37.1.1.g8cbb44ffc4.dirty
tenglong.tl· Jul 21, 2022, 13:27 UTC · re: tenglong.tl · lore

[PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair

From: Teng Long <dyroneteng@gmail.com>

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 <dyroneteng@gmail.com>
---
 Documentation/technical/api-trace2.txt | 20 +++++++++++++++-----
 trace2/tr2_tgt_event.c                 |  3 +++
 trace2/tr2_tgt_normal.c                |  5 ++++-
 trace2/tr2_tgt_perf.c                  |  9 +++++++--
 4 files changed, 29 insertions(+), 8 deletions(-)
Show changes to 4 files +29 −8

Documentation/technical/api-trace2.txt, trace2/tr2_tgt_event.c, trace2/tr2_tgt_normal.c, trace2/tr2_tgt_perf.c

diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index dcd0429037..229f31ab31 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: <a string that 'git config --show-scope' would return>
 	"param":"core.abbrev",
 	"value":"7"
 }
@@ -1213,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
@@ -1232,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,
-- 
2.37.1.1.g8cbb44ffc4.dirty
Junio C Hamano· Jul 21, 2022, 16:57 UTC · re: tenglong.tl · lore

Re: [PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair

"tenglong.tl" <dyroneteng@gmail.com> writes:
Show 12 quoted lines
> diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
> index dcd0429037..229f31ab31 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: <a string that 'git config --show-scope' would return>
>  	"param":"core.abbrev",
>  	"value":"7"
>  }

Everything in these examples use concrete values and follow the real syntax (e.g. param is enclosed in double-quotes and so is its value core.abbrev; even though core.abbrev is not the only param that can be reported by a def-param event, it is used as a concrete example. The same story goes for value). The new "scope" thing stands out like a sore thumb. I think the above should read more like

	"event":"def_param",
	...
	"scope":"global",
	"param":"core.abbrev",
	"value":"7"
or something.  Pick your favourite value for scope.
Other than that, these two patches make quite a lot of sense.
Thanks.
tenglong.tl· Jul 22, 2022, 06:12 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair

Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Everything in these examples use concrete values and follow the real
> syntax (e.g. param is enclosed in double-quotes and so is its value
> core.abbrev; even though core.abbrev is not the only param that can
> be reported by a def-param event, it is used as a concrete example.
> The same story goes for value).  The new "scope" thing stands out
> like a sore thumb.  I think the above should read more like
>
> 	"event":"def_param",
> 	...
> 	"scope":"global",
> 	"param":"core.abbrev",
> 	"value":"7"
>
> or something.  Pick your favourite value for scope.
>
> Other than that, these two patches make quite a lot of sense.

Yes. I think you are right, in this context, we should obey the same syntax and will fix in next patch.

Thanks.
tenglong.tl· Jul 22, 2022, 08:19 UTC · re: tenglong.tl · lore

[PATCH v1 0/2] tr2: shows the scope unconditionally with config

From: Teng Long <dyroneteng@gmail.com>
Changes since the initial patch:
1. [1/2] optimize the "scope" field representation with real syntax and
concrete value.
Thanks.
Teng Long (2):
  api-trace2.txt: print config key-value pair
  tr2: shows scope unconditionally in addition to key-value pair
 Documentation/technical/api-trace2.txt | 41 ++++++++++++++++++++++++++
 trace2/tr2_tgt_event.c                 |  3 ++
 trace2/tr2_tgt_normal.c                |  5 +++-
 trace2/tr2_tgt_perf.c                  |  9 ++++--
 4 files changed, 55 insertions(+), 3 deletions(-)
Range-diff against v0:
1:  bebd97c832 ! 1:  32f8b9ae6b api-trace2.txt: print config key-value pair
    @@ Commit message
         Signed-off-by: Teng Long <dyroneteng@gmail.com>
     
      ## Documentation/technical/api-trace2.txt ##
    +@@ Documentation/technical/api-trace2.txt: 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"
    + }
     @@ Documentation/technical/api-trace2.txt: at offset 508.
      This example also shows that thread names are assigned in a racy manner
      as each thread starts and allocates TLS storage.
2:  2f8fce6599 ! 2:  78575cca0b tr2: shows scope unconditionally in addition to key-value pair
    @@ Commit message
         Signed-off-by: Teng Long <dyroneteng@gmail.com>
     
      ## Documentation/technical/api-trace2.txt ##
    -@@ Documentation/technical/api-trace2.txt: The "exec_id" field is a command-unique id and is only useful if the
    - {
    - 	"event":"def_param",
    - 	...
    -+	scope: <a string that 'git config --show-scope' would return>
    - 	"param":"core.abbrev",
    - 	"value":"7"
    - }
     @@ Documentation/technical/api-trace2.txt: Print Configs::
      +
      The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration
-- 
2.37.1.1.g8cbb44ffc4.dirty
tenglong.tl· Jul 22, 2022, 08:19 UTC · re: tenglong.tl · lore

[PATCH v1 1/2] api-trace2.txt: print config key-value pair

From: Teng Long <dyroneteng@gmail.com>

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 <dyroneteng@gmail.com>
---
 Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
Show changes to Documentation/technical/api-trace2.txt +32 −0
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)
-- 
2.37.1.1.g8cbb44ffc4.dirty
Ævar Arnfjörð Bjarmason· Jul 22, 2022, 10:59 UTC · re: tenglong.tl · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

On Fri, Jul 22 2022, tenglong.tl wrote:
Show 35 quoted lines
> From: Teng Long <dyroneteng@gmail.com>
>
> 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 <dyroneteng@gmail.com>
> ---
>  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:

I didn't notice this before, but this is an addition to a long section where the examples are ------- delimited, starting with "in this example.." usually.

So this "print configs" seems like on odd continuation. Shouldn't this
copy the template of "Thread Events::" above. I.e. something like (I
have not tried to asciidoc render this):
	
	Config (def param) Events::
		We can optionally emit configuration events, see
		`trace2.configParams` in linkgit:git-config[1] for how to enable
		it.
	+
	< your example below would follow this>

I.e. re my earlier mention of git-config we it explains GIT_TRACE2_CONFIG_PARAMS, so perhaps it suffices to just link to linkgit:git-config[1] for that.

Also a nit: trace2.configParams, not trace2.configparams.
	
Show 27 quoted lines
> ++
> +----------------
> +$ 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)
Junio C Hamano· Jul 25, 2022, 19:07 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 30 quoted lines
> On Fri, Jul 22 2022, tenglong.tl wrote:
> ...
>> +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:
>
> I didn't notice this before, but this is an addition to a long section
> where the examples are ------- delimited, starting with "in this
> example.." usually.
>
> So this "print configs" seems like on odd continuation. Shouldn't this
> copy the template of "Thread Events::" above. I.e. something like (I
> have not tried to asciidoc render this):
> 	
> 	Config (def param) Events::
> 		We can optionally emit configuration events, see
> 		`trace2.configParams` in linkgit:git-config[1] for how to enable
> 		it.
> 	+
> 	< your example below would follow this>
>
> I.e. re my earlier mention of git-config we it explains
> GIT_TRACE2_CONFIG_PARAMS, so perhaps it suffices to just link to
> linkgit:git-config[1] for that.
>
> Also a nit: trace2.configParams, not trace2.configparams.

These may be worth fixing, regardless of the "adding scope in the example needs to wait until 2/2" I pointed out separately.

Thanks.
tenglong.tl· Aug 1, 2022, 12:25 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> I didn't notice this before, but this is an addition to a long section
> where the examples are ------- delimited, starting with "in this
> example.." usually.
A little puzzled. About "------- delimited", do you mean the "block" syntax?
> So this "print configs" seems like on odd continuation. Shouldn't this
> copy the template of "Thread Events::" above. I.e. something like (I
> have not tried to asciidoc render this):

I think "Events" in "Thread Events" means the thread start and end events, maybe not a template here. So I think it might be better to keep this namingi if I'm right, but I will use this candidate naming to show diff in the end.

I'm not good at naming so I'm glad to accept the suggestion about it.
Show 6 quoted lines
>	Config (def param) Events::
>		We can optionally emit configuration events, see
>		`trace2.configParams` in linkgit:git-config[1] for how to enable
>		it.
>	+
>	< your example below would follow this>
I refer to the previous sections, it's like the template is :
<title>
        <brief one-line description>
<detailed multi-lines description>
So, how about this like:
Show changes to Documentation/technical/api-trace2.txt +31 −0
diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 77a150b30e..38d0878d85 100644
--- a/Documentation/technical/api-trace2.txt
+++ b/Documentation/technical/api-trace2.txt
@@ -1207,6 +1207,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.

+Config (def param) Events::
+
+         Dump "interesting" config values to trace2 log.
++
+We can optionally emit configuration events, see
+`trace2.configparams` in linkgit:git-config[1] for how to enable
+it.
++
+----------------
+$ 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)

Thanks.
Junio C Hamano· Aug 5, 2022, 22:21 UTC · re: tenglong.tl · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

"tenglong.tl" <dyroneteng@gmail.com> writes:
Show 19 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> I didn't notice this before, but this is an addition to a long section
> ...
> I refer to the previous sections, it's like the template is :
>
> <title>
>
>         <brief one-line description>
>
> <detailed multi-lines description>
>
> So, how about this like:
>
> diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
> index 77a150b30e..38d0878d85 100644
> --- a/Documentation/technical/api-trace2.txt
> +++ b/Documentation/technical/api-trace2.txt
> @@ -1207,6 +1207,37 @@ at offset 508.

So, what is the outcome from this discussion? It seems that this subthread on [1/2] is blocking the two-patch series?

Thanks.
Teng Long· Aug 8, 2022, 06:16 UTC · re: Junio C Hamano · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

Junio C Hamano <gitster@pobox.com> writes:
> So, what is the outcome from this discussion?  It seems that this
> subthread on [1/2] is blocking the two-patch series?

I think it's blocking. I replied a comment to comfirm that I understand Ævar Arnfjörð Bjarmason's suggestion and also there is an improvement change in it:

  https://public-inbox.org/git/20220801122515.23146-1-tenglong.tl@alibaba-inc.com/
Thanks.
Junio C Hamano· Jul 22, 2022, 21:05 UTC · re: tenglong.tl · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

"tenglong.tl" <dyroneteng@gmail.com> writes:
Show 24 quoted lines
> From: Teng Long <dyroneteng@gmail.com>
>
> 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 <dyroneteng@gmail.com>
> ---
>  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"
>  }
Isn't this a bit premature to do in [PATCH 1/2]?
Junio C Hamano· Jul 23, 2022, 17:47 UTC · re: tenglong.tl · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

"tenglong.tl" <dyroneteng@gmail.com> writes:
>> Isn't this a bit premature to do in [PATCH 1/2]?
>
> Yes, one oversight, sorry for that and will fix.

I've tweaked with "rebase -i" after queuing and before pushing the integration result out, so if you can double check the result to make sure I didn't screw up, there is no need to resend.

Thanks.
tenglong.tl· Jul 25, 2022, 09:18 UTC · re: Junio C Hamano · lore

Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair

Junio C Hamano <gitster@pobox.com> writes:
> I've tweaked with "rebase -i" after queuing and before pushing the
> integration result out, so if you can double check the result to
> make sure I didn't screw up, there is no need to resend.

OK, got it. There is no inconsistency in understanding, I agree with your suggestion.

Thanks for explanation.
tenglong.tl· Jul 22, 2022, 08:19 UTC · re: tenglong.tl · lore

[PATCH v1 2/2] tr2: shows scope unconditionally in addition to key-value pair

From: Teng Long <dyroneteng@gmail.com>

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 <dyroneteng@gmail.com>
---
 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(-)
Show changes to 4 files +28 −8

Documentation/technical/api-trace2.txt, trace2/tr2_tgt_event.c, trace2/tr2_tgt_normal.c, trace2/tr2_tgt_perf.c

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,
-- 
2.37.1.1.g8cbb44ffc4.dirty
Teng Long· Aug 12, 2022, 02:56 UTC · re: tenglong.tl · lore

[PATCH v2 0/2] tr2: shows the scope unconditionally with config

From: Teng Long <dyroneteng@gmail.com>
Diff from v1:
* Fix the premature code in [1/2] by Junio's comment in:
  https://public-inbox.org/git/xmqqy1wkc0yw.fsf@gitster.g/
* Optimize the documentaion in [1/2] by Ævar's comment in:
  https://public-inbox.org/git/220722.86fsits91m.gmgdl@evledraar.gmail.com/

I send this patch version a little earlier maybe because some context not fully discussed or solved, intend to avoid context signal disappearance because it's been lasted a while now.

Thanks.
Teng Long (2):
  api-trace2.txt: print config key-value pair
  tr2: shows scope unconditionally in addition to key-value pair
 Documentation/technical/api-trace2.txt | 40 ++++++++++++++++++++++++++
 trace2/tr2_tgt_event.c                 |  3 ++
 trace2/tr2_tgt_normal.c                |  5 +++-
 trace2/tr2_tgt_perf.c                  |  9 ++++--
 4 files changed, 54 insertions(+), 3 deletions(-)
Range-diff against v1:
1:  bebd97c832 ! 1:  84bd8a71d7 api-trace2.txt: print config key-value pair
    @@ Documentation/technical/api-trace2.txt: 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::
    ++Config (def param) Events::
     +
     +	  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:
    ++We can optionally emit configuration events, see
    ++`trace2.configparams` in linkgit:git-config[1] for how to enable
    ++it.
     ++
     +----------------
     +$ git config color.ui auto
2:  2f8fce6599 ! 2:  9856058df6 tr2: shows scope unconditionally in addition to key-value pair
    @@ Documentation/technical/api-trace2.txt: The "exec_id" field is a command-unique
      {
      	"event":"def_param",
      	...
    -+	scope: <a string that 'git config --show-scope' would return>
    ++	"scope":"global",
      	"param":"core.abbrev",
      	"value":"7"
      }
    -@@ Documentation/technical/api-trace2.txt: 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:
    +@@ Documentation/technical/api-trace2.txt: We can optionally emit configuration events, see
    + it.
      +
      ----------------
     -$ git config color.ui auto
-- 
2.37.1.1.g8cbb44ffc4.dirty
Teng Long· Aug 12, 2022, 02:56 UTC · re: Teng Long · lore

[PATCH v2 1/2] api-trace2.txt: print config key-value pair

From: Teng Long <dyroneteng@gmail.com>

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 <dyroneteng@gmail.com>
---
 Documentation/technical/api-trace2.txt | 31 ++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
Show changes to Documentation/technical/api-trace2.txt +31 −0
diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 77a150b30e..38d0878d85 100644
--- a/Documentation/technical/api-trace2.txt
+++ b/Documentation/technical/api-trace2.txt
@@ -1207,6 +1207,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.
 
+Config (def param) Events::
+
+	  Dump "interesting" config values to trace2 log.
++
+We can optionally emit configuration events, see
+`trace2.configparams` in linkgit:git-config[1] for how to enable
+it.
++
+----------------
+$ 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)
-- 
2.37.1.1.g8cbb44ffc4.dirty
Teng Long· Aug 12, 2022, 02:56 UTC · re: Teng Long · lore

[PATCH v2 2/2] tr2: shows scope unconditionally in addition to key-value pair

From: Teng Long <dyroneteng@gmail.com>

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 <dyroneteng@gmail.com>
---
 Documentation/technical/api-trace2.txt | 17 +++++++++++++----
 trace2/tr2_tgt_event.c                 |  3 +++
 trace2/tr2_tgt_normal.c                |  5 ++++-
 trace2/tr2_tgt_perf.c                  |  9 +++++++--
 4 files changed, 27 insertions(+), 7 deletions(-)
Show changes to 4 files +27 −7

Documentation/technical/api-trace2.txt, trace2/tr2_tgt_event.c, trace2/tr2_tgt_normal.c, trace2/tr2_tgt_perf.c

diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 38d0878d85..2afa28bb5a 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"
 }
@@ -1216,7 +1217,13 @@ We can optionally emit configuration events, see
 it.
 +
 ----------------
-$ 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
@@ -1232,11 +1239,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,
-- 
2.37.1.1.g8cbb44ffc4.dirty
Junio C Hamano· Aug 12, 2022, 21:16 UTC · re: Teng Long · lore

Re: [PATCH v2 2/2] tr2: shows scope unconditionally in addition to key-value pair

Teng Long <dyroneteng@gmail.com> writes:
Show 17 quoted lines
> 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);
OK, that is quite straight-forward.
Show 17 quoted lines
> 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);
>  }
So is this one.  Quite nice.

Is everybody happy with the choice of ":" colon here, though? The one in tgt_perf below uses the same delimiter that is used between <param, value> to delimit <"scope", scome_name>. I am wondering if this one should use "=", the delimiter used between <param, value> in this output stream, to match. I do not care at all either way, but I am mentioning it because I happened have noticed it, and because somebody else may care.

Thanks, will queue.
Show 24 quoted lines
> 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,
Junio C Hamano· Aug 19, 2022, 21:18 UTC · re: Teng Long · lore

Re: [PATCH v2 0/2] tr2: shows the scope unconditionally with config

Teng Long <dyroneteng@gmail.com> writes:
Show 15 quoted lines
> From: Teng Long <dyroneteng@gmail.com>
>
> Diff from v1:
>
> * Fix the premature code in [1/2] by Junio's comment in:
>
>   https://public-inbox.org/git/xmqqy1wkc0yw.fsf@gitster.g/
>
> * Optimize the documentaion in [1/2] by Ævar's comment in:
>
>   https://public-inbox.org/git/220722.86fsits91m.gmgdl@evledraar.gmail.com/
>
> I send this patch version a little earlier maybe because some context not fully
> discussed or solved, intend to avoid context signal disappearance because it's
> been lasted a while now. 

We haven't seen any comments (other than mine) for a full week, and am wondering if everybody is happy with it. Let me mark it for 'next' in the draft of "What's cooking" and merge it down.

← back to recent threads