tr2: shows the scope unconditionally with config
cover tr2: shows the scope unconditionally with config
From: Teng Long <[email protected]>
This series is separated from :
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(-)
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
PATCH 1/2 api-trace2.txt: print config key-value pair
From: Teng Long <[email protected]>
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.
--- Documentation/technical/api-trace2.txt | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Documentation/technical/api-trace2.txt +31 -0
@@ -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)
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
PATCH 2/2 tr2: shows scope unconditionally in addition to key-value pair
In reply to tenglong.tlFrom: Teng Long <[email protected]>
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 \
Quoted 2 lines
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"}
--- 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(-)
Documentation/technical/api-trace2.txt +15 -5
@@ -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
trace2/tr2_tgt_event.c +3 -0
@@ -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);
trace2/tr2_tgt_normal.c +4 -1
@@ -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); }
trace2/tr2_tgt_perf.c +7 -2
@@ -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,
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
Re: [PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair
Documentation/technical/api-trace2.txt The "exec_id" field is a command-unique id and is only useful if the · line 723
Quoted 12 lines · tenglong.tl
Documentation/technical/api-trace2.txt +1
-0@@ -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.
Re: [PATCH 2/2] tr2: shows scope unconditionally in addition to key-value pair
Quoted 13 lines · Junio C Hamano
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"
Quoted 3 lines
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.
cover tr2: shows the scope unconditionally with config
In reply to tenglong.tlFrom: Teng Long <[email protected]>
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
## 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
## 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
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
PATCH 1/2 api-trace2.txt: print config key-value pair
From: Teng Long <[email protected]>
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.
--- Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
Documentation/technical/api-trace2.txt +32 -0
@@ -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)
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Quoted 25 lines · tenglong.tl
From: Teng Long <[email protected]>
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 inDocumentaion/technical/api-trace2.txt.Signed-off-by Teng Long <[email protected]>--- Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)Documentation/technical/api-trace2.txt +1
-0@@ -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" }
Documentation/technical/api-trace2.txt at offset 508. · line 1217
Quoted 10 lines
Documentation/technical/api-trace2.txt +7
-0@@ -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.
Quoted 27 lines
Documentation/technical/api-trace2.txt +24
-0++ +---------------- +$ 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)
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Quoted 25 lines · Ævar Arnfjörð Bjarmason
On Fri, Jul 22 2022, tenglong.tl wrote:
...Documentation/technical/api-trace2.txt at offset 508. · line 1217
Quoted 7 lines
Documentation/technical/api-trace2.txt +7
-0+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, seetrace2.configParamsin linkgit:git-config[1] for how to enable it.
+
< your example below would follow this>
Quoted 5 lines
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.
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
In reply to Ævar Arnfjörð BjarmasonQuoted 3 lines · Ævar Arnfjörð Bjarmason
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?
Quoted 3 lines
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.
Quoted 6 lines
Config (def param) Events::
We can optionally emit configuration events, seetrace2.configParamsin 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:
Documentation/technical/api-trace2.txt +31 -0
@@ -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.
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Documentation/technical/api-trace2.txt at offset 508.
Quoted 19 lines · tenglong.tl
Quoted 1 line · Ævar Arnfjörð Bjarmason
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:
Documentation/technical/api-trace2.txt +0
-0@@ -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.
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Quoted 2 lines · Junio C Hamano
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/[email protected]/
Thanks.
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
In reply to tenglong.tlQuoted 17 lines · tenglong.tl
From: Teng Long <[email protected]>
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 inDocumentaion/technical/api-trace2.txt.Signed-off-by Teng Long <[email protected]>--- Documentation/technical/api-trace2.txt | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)Documentation/technical/api-trace2.txt +0
-0
Documentation/technical/api-trace2.txt The "exec_id" field is a command-unique id and is only useful if the · line 723
Quoted 7 lines
Documentation/technical/api-trace2.txt +1
-0@@ -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]?
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Quoted 1 line
Isn't this a bit premature to do in [PATCH 1/2]?
Yes, one oversight, sorry for that and will fix.
Thanks.
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Quoted 3 lines · tenglong.tl
Quoted 1 line
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.
Re: [PATCH v1 1/2] api-trace2.txt: print config key-value pair
Quoted 3 lines · Junio C Hamano
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.
PATCH 2/2 tr2: shows scope unconditionally in addition to key-value pair
In reply to tenglong.tlFrom: Teng Long <[email protected]>
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 \
Quoted 2 lines
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"}
--- 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(-)
Documentation/technical/api-trace2.txt +14 -5
@@ -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
trace2/tr2_tgt_event.c +3 -0
@@ -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);
trace2/tr2_tgt_normal.c +4 -1
@@ -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); }
trace2/tr2_tgt_perf.c +7 -2
@@ -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,
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
v2 cover tr2: shows the scope unconditionally with config
In reply to tenglong.tlFrom: Teng Long <[email protected]>
Diff from v1:
* Fix the premature code in [1/2] by Junio's comment in:
https://public-inbox.org/git/[email protected]/
* Optimize the documentaion in [1/2] by Ævar's comment in:
https://public-inbox.org/git/[email protected]/
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
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
PATCH v2 1/2 api-trace2.txt: print config key-value pair
From: Teng Long <[email protected]>
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.
--- Documentation/technical/api-trace2.txt | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Documentation/technical/api-trace2.txt +31 -0
@@ -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)
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
PATCH v2 2/2 tr2: shows scope unconditionally in addition to key-value pair
In reply to Teng LongFrom: Teng Long <[email protected]>
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 \
Quoted 2 lines
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"}
--- 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(-)
Documentation/technical/api-trace2.txt +13 -4
@@ -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
trace2/tr2_tgt_event.c +3 -0
@@ -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);
trace2/tr2_tgt_normal.c +4 -1
@@ -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); }
trace2/tr2_tgt_perf.c +7 -2
@@ -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,
Signature · 1 line
2.37.1.1.g8cbb44ffc4.dirty
Re: [PATCH v2 2/2] tr2: shows scope unconditionally in addition to key-value pair
Quoted 7 lines · Teng Long
trace2/tr2_tgt_event.c +0
-0@@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param, {const char *event_name ="def_param" ;
trace2/tr2_tgt_event.c static void fn_param_fl(const char *file, int line, const char *param, · line 490
Quoted 10 lines
trace2/tr2_tgt_event.c +3
-0struct 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.
Quoted 7 lines
trace2/tr2_tgt_normal.c +0
-0@@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param, const char *value) {
trace2/tr2_tgt_normal.c static void fn_param_fl(const char *file, int line, const char *param, · line 308
Quoted 10 lines
trace2/tr2_tgt_normal.c +4
-1struct 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.
Quoted 24 lines
trace2/tr2_tgt_perf.c +7
-2@@ -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,
Quoted 8 lines · Teng Long
From: Teng Long <[email protected]>
Diff from v1:
* Fix the premature code in [1/2] by Junio's comment in:
Quoted 7 lines
* Optimize the documentaion in [1/2] by Ævar's comment in:
https://public-inbox.org/git/[email protected]/
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.