From a089724958a99924d9ec7ff60a6aea63d03448f2 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Mon, 15 Apr 2019 13:39:43 -0700 Subject: trace2: refactor setting process starting time Create trace2_initialize_clock() and call from main() to capture process start time in isolation and before other sub-systems are ready. Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- trace2.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'trace2.h') diff --git a/trace2.h b/trace2.h index ae5020d0e6..8f89e70c44 100644 --- a/trace2.h +++ b/trace2.h @@ -19,6 +19,23 @@ 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. -- cgit v1.2.3 From bce9db6de97c95882a7c46836bb6cc90acf0fef0 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Mon, 15 Apr 2019 13:39:47 -0700 Subject: trace2: use system/global config for default trace2 settings Teach git to read the system and global config files 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. The original GIT_TR2* environment variables are loaded afterwards and can be used to override the system settings. Only the system and global config files are used. Repo and worktree local config files are ignored. Likewise, the "-c" command line arguments are also ignored. These limits are for performance reasons. (1) For users not using Trace2, there should be minimal overhead to detect that Trace2 is not enabled. In particular, Trace2 should not allocate lots of otherwise unused data strucutres. (2) For accurate performance measurements, Trace2 should be initialized as early in the git process as possible, and before most of the normal git process initialization (which involves discovering the .git directory and reading a hierarchy of config files). Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- trace2.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'trace2.h') diff --git a/trace2.h b/trace2.h index 8f89e70c44..894bfca7e0 100644 --- a/trace2.h +++ b/trace2.h @@ -38,7 +38,8 @@ 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. @@ -125,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 -- cgit v1.2.3 From 26c6f251d754a33c188ce7ad8f5ea6cb0bc740d7 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Mon, 15 Apr 2019 13:39:48 -0700 Subject: trace2: report peak memory usage of the process Teach Windows version of git to report peak memory usage during exit() processing. Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- trace2.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'trace2.h') diff --git a/trace2.h b/trace2.h index 894bfca7e0..888531eb08 100644 --- a/trace2.h +++ b/trace2.h @@ -391,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 -- cgit v1.2.3