Merge branch 'jh/trace2-sid-fix'

Polishing of the new trace2 facility continues.  The system-level
configuration can specify site-wide trace2 settings, which can be
overridden with per-user configuration and environment variables.

* jh/trace2-sid-fix:
  trace2: fixup access problem on /etc/gitconfig in read_very_early_config
  trace2: update docs to describe system/global config settings
  trace2: make SIDs more unique
  trace2: clarify UTC datetime formatting
  trace2: report peak memory usage of the process
  trace2: use system/global config for default trace2 settings
  config: add read_very_early_config()
  trace2: find exec-dir before trace2 initialization
  trace2: add absolute elapsed time to start event
  trace2: refactor setting process starting time
  config: initialize opts structure in repo_read_config()
This commit is contained in:
Junio C Hamano
2019-05-13 23:50:31 +09:00
29 changed files with 759 additions and 217 deletions

View File

@@ -19,9 +19,27 @@ struct json_writer;
* [] trace2_printf* -- legacy trace[1] messages.
*/
/*
* Initialize the TRACE2 clock and do nothing else, in particular
* no mallocs, no system inspection, and no environment inspection.
*
* This should be called at the very top of main() to capture the
* process start time. This is intended to reduce chicken-n-egg
* bootstrap pressure.
*
* It is safe to call this more than once. This allows capturing
* absolute startup costs on Windows which uses a little trickery
* to do setup work before common-main.c:main() is called.
*
* The main trace2_initialize_fl() may be called a little later
* after more infrastructure is established.
*/
void trace2_initialize_clock(void);
/*
* Initialize TRACE2 tracing facility if any of the builtin TRACE2
* targets are enabled in the environment. Emits a 'version' event.
* targets are enabled in the system config or the environment.
* Emits a 'version' event.
*
* Cleanup/Termination is handled automatically by a registered
* atexit() routine.
@@ -108,10 +126,11 @@ void trace2_cmd_alias_fl(const char *file, int line, const char *alias,
* Emit one or more 'def_param' events for "interesting" configuration
* settings.
*
* The environment variable "GIT_TR2_CONFIG_PARAMS" can be set to a
* list of patterns considered important. For example:
*
* GIT_TR2_CONFIG_PARAMS="core.*,remote.*.url"
* Use the TR2_SYSENV_CFG_PARAM setting to register a comma-separated
* list of patterns configured important. For example:
* git config --system trace2.configParams 'core.*,remote.*.url'
* or:
* GIT_TR2_CONFIG_PARAMS=core.*,remote.*.url"
*
* Note: this routine does a read-only iteration on the config data
* (using read_early_config()), so it must not be called until enough
@@ -372,13 +391,19 @@ void trace2_printf(const char *fmt, ...);
* Optional platform-specific code to dump information about the
* current and any parent process(es). This is intended to allow
* post-processors to know who spawned this git instance and anything
* else the platform may be able to tell us about the current process.
* else that the platform may be able to tell us about the current process.
*/
enum trace2_process_info_reason {
TRACE2_PROCESS_INFO_STARTUP,
TRACE2_PROCESS_INFO_EXIT,
};
#if defined(GIT_WINDOWS_NATIVE)
void trace2_collect_process_info(void);
void trace2_collect_process_info(enum trace2_process_info_reason reason);
#else
#define trace2_collect_process_info() \
do { \
#define trace2_collect_process_info(reason) \
do { \
} while (0)
#endif