Skip to content

Commit 10ccb50

Browse files
committed
Merge branch 'tl/trace2-config-scope'
Tweak trace2 output about configuration variables. * tl/trace2-config-scope: tr2: shows scope unconditionally in addition to key-value pair api-trace2.txt: print config key-value pair
2 parents 2540220 + 35ae40e commit 10ccb50

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed

Documentation/technical/api-trace2.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ The "exec_id" field is a command-unique id and is only useful if the
717717
{
718718
"event":"def_param",
719719
...
720+
"scope":"global",
720721
"param":"core.abbrev",
721722
"value":"7"
722723
}
@@ -1207,6 +1208,45 @@ at offset 508.
12071208
This example also shows that thread names are assigned in a racy manner
12081209
as each thread starts and allocates TLS storage.
12091210

1211+
Config (def param) Events::
1212+
1213+
Dump "interesting" config values to trace2 log.
1214+
+
1215+
We can optionally emit configuration events, see
1216+
`trace2.configparams` in linkgit:git-config[1] for how to enable
1217+
it.
1218+
+
1219+
----------------
1220+
$ git config --system color.ui never
1221+
$ git config --global color.ui always
1222+
$ git config --local color.ui auto
1223+
$ git config --list --show-scope | grep 'color.ui'
1224+
system color.ui=never
1225+
global color.ui=always
1226+
local color.ui=auto
1227+
----------------
1228+
+
1229+
Then, mark the config `color.ui` as "interesting" config with
1230+
`GIT_TRACE2_CONFIG_PARAMS`:
1231+
+
1232+
----------------
1233+
$ export GIT_TRACE2_PERF_BRIEF=1
1234+
$ export GIT_TRACE2_PERF=~/log.perf
1235+
$ export GIT_TRACE2_CONFIG_PARAMS=color.ui
1236+
$ git version
1237+
...
1238+
$ cat ~/log.perf
1239+
d0 | main | version | | | | | ...
1240+
d0 | main | start | | 0.001642 | | | /usr/local/bin/git version
1241+
d0 | main | cmd_name | | | | | version (version)
1242+
d0 | main | def_param | | | | scope:system | color.ui:never
1243+
d0 | main | def_param | | | | scope:global | color.ui:always
1244+
d0 | main | def_param | | | | scope:local | color.ui:auto
1245+
d0 | main | data | r0 | 0.002100 | 0.002100 | fsync | fsync/writeout-only:0
1246+
d0 | main | data | r0 | 0.002126 | 0.002126 | fsync | fsync/hardware-flush:0
1247+
d0 | main | exit | | 0.000470 | | | code:0
1248+
d0 | main | atexit | | 0.000477 | | | code:0
1249+
----------------
12101250
== Future Work
12111251

12121252
=== Relationship to the Existing Trace Api (api-trace.txt)

trace2/tr2_tgt_event.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,
479479
{
480480
const char *event_name = "def_param";
481481
struct json_writer jw = JSON_WRITER_INIT;
482+
enum config_scope scope = current_config_scope();
483+
const char *scope_name = config_scope_name(scope);
482484

483485
jw_object_begin(&jw, 0);
484486
event_fmt_prepare(event_name, file, line, NULL, &jw);
487+
jw_object_string(&jw, "scope", scope_name);
485488
jw_object_string(&jw, "param", param);
486489
jw_object_string(&jw, "value", value);
487490
jw_end(&jw);

trace2/tr2_tgt_normal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,
298298
const char *value)
299299
{
300300
struct strbuf buf_payload = STRBUF_INIT;
301+
enum config_scope scope = current_config_scope();
302+
const char *scope_name = config_scope_name(scope);
301303

302-
strbuf_addf(&buf_payload, "def_param %s=%s", param, value);
304+
strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param,
305+
value);
303306
normal_io_write_fl(file, line, &buf_payload);
304307
strbuf_release(&buf_payload);
305308
}

trace2/tr2_tgt_perf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,
441441
{
442442
const char *event_name = "def_param";
443443
struct strbuf buf_payload = STRBUF_INIT;
444+
struct strbuf scope_payload = STRBUF_INIT;
445+
enum config_scope scope = current_config_scope();
446+
const char *scope_name = config_scope_name(scope);
444447

445448
strbuf_addf(&buf_payload, "%s:%s", param, value);
449+
strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
446450

447-
perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,
448-
&buf_payload);
451+
perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,
452+
scope_payload.buf, &buf_payload);
449453
strbuf_release(&buf_payload);
454+
strbuf_release(&scope_payload);
450455
}
451456

452457
static void fn_repo_fl(const char *file, int line,

0 commit comments

Comments
 (0)