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