git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 4/7] trace2: use system config for default trace2 settings

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Apr 3, 2019, 00:00 UTC
Message-ID
<20190403000032.GA190454@google.com>
In-Reply-To
<d048f3ffb801adc7f1b4e48248ca31ebade1b37d.1553879063.git.gitgitgadget@gmail.com>
Hi,
Jeff Hostetler via GitGitGadget wrote:
> Teach git to read the system config (usually "/etc/gitconfig") for
> default Trace2 settings.  This allows system-wide Trace2 settings to
> be installed and inherited to make it easier to manage a collection of
> systems.
Yay!  Thanks for writing this, and sorry for the slow review.
[...]
> Only the system config file is used.  Trace2 config values are ignored
> in local, global, and other config files.  Likewise, the "-c" command
> line arguments are ignored for Trace2 values.  These limits are for
> performance reasons.

Can you say a bit more about this? If I'm willing to pay the performance cost, is there a way for me to turn on respecting other config files? What is that performance cost?

[...]
Show 14 quoted lines
> --- a/Documentation/technical/api-trace2.txt
> +++ b/Documentation/technical/api-trace2.txt
> @@ -117,6 +117,37 @@ values are recognized.
>  Socket type can be either `stream` or `dgram`.  If the socket type is
>  omitted, Git will try both.
>  
> +== Trace2 Settings in System Config
> +
> +Trace2 also reads configuration information from the system config.
> +This is intended to help adminstrators to gather system-wide Git
> +performance data.
> +
> +Trace2 only reads the system configuration, it does not read global,
> +local, worktree, or `-c` config settings.

An additional limitation is that this doesn't appear to support include.* directives. Intended?

[...]
> --- a/t/t0210-trace2-normal.sh
> +++ b/t/t0210-trace2-normal.sh
[...]
Show 10 quoted lines
> +MOCK=./mock_system_config
> +
> +test_expect_success 'setup mocked /etc/gitconfig' '
> +	git config --file $MOCK trace2.normalTarget "$(pwd)/trace.normal" &&
> +	git config --file $MOCK trace2.normalBrief 1
> +'
> +
> +test_expect_success 'using mock, normal stream, return code 0' '
> +	test_when_finished "rm trace.normal actual expect" &&
> +	GIT_TEST_TR2_SYSTEM_CONFIG="$MOCK" test-tool trace2 001return 0 &&

Tests run with GIT_CONFIG_NOSYSTEM=1 to protect themselves from any system config the user has.

So this would be easier to test if we can use user-level config for it.

[...]
Show 22 quoted lines
> --- /dev/null
> +++ b/trace2/tr2_sysenv.c
> @@ -0,0 +1,128 @@
> +#include "cache.h"
> +#include "config.h"
> +#include "dir.h"
> +#include "tr2_sysenv.h"
> +
> +/*
> + * Each entry represents a trace2 setting.
> + * See Documentation/technical/api-trace2.txt
> + */
> +struct tr2_sysenv_entry {
> +	const char *env_var_name;
> +	const char *git_config_name;
> +
> +	char *value;
> +	unsigned int getenv_called : 1;
> +};
> +
> +/*
> + * This table must match "enum tr2_sysenv_variable" in tr2_sysenv.h.
Can we deduplicate to avoid the need to match?
Perhaps using C99 array initializers would help:
	[TR2_SYSENV_CFG_PARAM] = { ... },
[...]
Show 24 quoted lines
> +/*
> + * Load Trace2 settings from the system config (usually "/etc/gitconfig"
> + * unless we were built with a runtime-prefix).  These are intended to
> + * define the default values for Trace2 as requested by the administrator.
> + */
> +void tr2_sysenv_load(void)
> +{
> +	const char *system_config_pathname;
> +	const char *test_pathname;
> +
> +	system_config_pathname = git_etc_gitconfig();
> +
> +	test_pathname = getenv("GIT_TEST_TR2_SYSTEM_CONFIG");
> +	if (test_pathname) {
> +		if (!*test_pathname || !strcmp(test_pathname, "0"))
> +			return; /* disable use of system config */
> +
> +		/* mock it with given test file */
> +		system_config_pathname = test_pathname;
> +	}
> +
> +	if (file_exists(system_config_pathname))
> +		git_config_from_file(tr2_sysenv_cb, system_config_pathname,
> +				     NULL);

This duplicates functionality from config.c and misses some features along the way (e.g. support for include.*).

Would read_early_config work? If we want a variant that doesn't discover_git_directory, we can change that function to handle it.

For our needs at Google, it would be very helpful to have support for include.* and reading settings from at least $HOME/.gitconfig in addition to /etc/gitconfig (even better if it supports per-repo config as well). I believe it would simplify the code and tests, too. If there's anything I can to help, please don't hesitate to ask.

Thanks, Jonathan

Previous: Jonathan NiederNext: Jeff Hostetler
Message 20 of 68 in “trace2: load trace2 settings from system config”
  1. 0/4 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Mar 28, 2019
  2. 1/4 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Mar 28, 2019
  3. 2/4 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Mar 28, 2019
  4. 3/4 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Mar 28, 2019
  5. 4/4 trace2: use system config for default trace2 settingsJeff Hostetler via GitGitGadget, Mar 28, 2019
  6. Ævar Arnfjörð BjarmasonMar 28, 2019
  7. Jeff HostetlerMar 28, 2019
  8. Josh SteadmonMar 28, 2019
  9. 0/7 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Mar 29, 2019
  10. 2/7 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Mar 29, 2019
  11. 3/7 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Mar 29, 2019
  12. 5/7 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Mar 29, 2019
  13. Ævar Arnfjörð BjarmasonMar 29, 2019
  14. Jeff HostetlerApr 1, 2019
  15. 6/7 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Mar 29, 2019
  16. 4/7 trace2: use system config for default trace2 settingsJeff Hostetler via GitGitGadget, Mar 29, 2019
  17. Josh SteadmonApr 1, 2019
  18. Jeff HostetlerApr 1, 2019
  19. Jonathan NiederApr 3, 2019
  20. Jonathan NiederApr 3, 2019
  21. Jeff HostetlerApr 9, 2019
  22. 7/7 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Mar 29, 2019
  23. Ævar Arnfjörð BjarmasonMar 29, 2019
  24. Jeff HostetlerApr 1, 2019
  25. 1/7 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Mar 29, 2019
  26. Josh SteadmonApr 1, 2019
  27. 00/10 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Apr 11, 2019
  28. 01/10 config: initialize opts structure in repo_read_config()Jeff Hostetler via GitGitGadget, Apr 11, 2019
  29. Jonathan NiederApr 12, 2019
  30. Johannes SchindelinApr 15, 2019
  31. 03/10 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Apr 11, 2019
  32. 05/10 config: add read_very_early_config()Jeff Hostetler via GitGitGadget, Apr 11, 2019
  33. 08/10 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Apr 11, 2019
  34. 07/10 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Apr 11, 2019
  35. 10/10 trace2: update docs to describe system/global config settingsJeff Hostetler via GitGitGadget, Apr 11, 2019
  36. 09/10 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Apr 11, 2019
  37. 02/10 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Apr 11, 2019
  38. 06/10 trace2: use system/global config for default trace2 settingsJeff Hostetler via GitGitGadget, Apr 11, 2019
  39. 04/10 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Apr 11, 2019
  40. Junio C HamanoApr 12, 2019
  41. Jeff HostetlerApr 12, 2019
  42. 00/10 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Apr 15, 2019
  43. 01/10 config: initialize opts structure in repo_read_config()Jeff Hostetler via GitGitGadget, Apr 15, 2019
  44. 02/10 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Apr 15, 2019
  45. 03/10 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Apr 15, 2019
  46. 05/10 config: add read_very_early_config()Jeff Hostetler via GitGitGadget, Apr 15, 2019
  47. 07/10 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Apr 15, 2019
  48. 06/10 trace2: use system/global config for default trace2 settingsJeff Hostetler via GitGitGadget, Apr 15, 2019
  49. SZEDER GáborApr 27, 2019
  50. Jeff HostetlerApr 29, 2019
  51. 10/10 trace2: update docs to describe system/global config settingsJeff Hostetler via GitGitGadget, Apr 15, 2019
  52. 04/10 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Apr 15, 2019
  53. 09/10 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Apr 15, 2019
  54. 08/10 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Apr 15, 2019
  55. 00/11 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Apr 29, 2019
  56. 01/11 config: initialize opts structure in repo_read_config()Jeff Hostetler via GitGitGadget, Apr 29, 2019
  57. 03/11 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Apr 29, 2019
  58. 02/11 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Apr 29, 2019
  59. 07/11 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Apr 29, 2019
  60. 08/11 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Apr 29, 2019
  61. 09/11 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Apr 29, 2019
  62. 06/11 trace2: use system/global config for default trace2 settingsJeff Hostetler via GitGitGadget, Apr 29, 2019
  63. 11/11 trace2: fixup access problem on /etc/gitconfig in read_very_early_configJeff Hostetler via GitGitGadget, Apr 29, 2019
  64. 10/11 trace2: update docs to describe system/global config settingsJeff Hostetler via GitGitGadget, Apr 29, 2019
  65. 05/11 config: add read_very_early_config()Jeff Hostetler via GitGitGadget, Apr 29, 2019
  66. 04/11 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Apr 29, 2019
  67. Jeff HostetlerApr 29, 2019
  68. Junio C HamanoMay 7, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.