From: Joel Rosdahl Date: Sun, 21 Apr 2019 20:12:06 +0000 (+0200) Subject: Tweak manuals and code related to tracing X-Git-Tag: v3.7~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67fe5050b4be03025fc83a4018d038158ea86e6e;p=thirdparty%2Fccache.git Tweak manuals and code related to tracing --- diff --git a/LICENSE.adoc b/LICENSE.adoc index 7b0b33df7..30848f40d 100644 --- a/LICENSE.adoc +++ b/LICENSE.adoc @@ -448,7 +448,7 @@ src/minitrace.[hc] ~~~~~~~~~~~~~~~~~~ A library for producing JSON traces suitable for Chrome's built-in trace viewer -(chrome://tracing). Downloaded from +(chrome://tracing). Downloaded from . ------------------------------------------------------------------------------- The MIT License (MIT) diff --git a/doc/DEVELOPER.md b/doc/DEVELOPER.md index fca6b0144..318dc6fac 100644 --- a/doc/DEVELOPER.md +++ b/doc/DEVELOPER.md @@ -1,31 +1,35 @@ -Developer Manual +Developer manual ================ Tracing ------- -In order to see what ccache is doing, it is possible to enable microsecond tracing. -This needs to be done when compiling ccache, using the `--enable-tracing` feature. +In order to see what ccache is doing, it is possible to enable microsecond +tracing. This needs to be done when compiling ccache using the +`--enable-tracing` configure option. -By setting *CCACHE_INTERNAL_TRACE*, one can obtain a trace of an individual compile. -This trace can then be loaded into the `chrome://tracing` page of Chromium/Chrome. +By setting `CCACHE_INTERNAL_TRACE` one can obtain a trace of an individual +compile. This trace can then be loaded into the `chrome://tracing` page of +Chromium/Chrome. -The current event categories are: config, main, hash, manifest, cache, file, execute +The current event categories are config, main, hash, manifest, cache, file, +execute. -With a unique file per compile, there is a script to combine them all into one trace: +There is a script to combine trace logs from multiple compilations into one: -`misc/combine_events.py file1.json file2.json file3.json | gzip > ccache.trace.gz` + misc/combine_events.py file_1.json ... file_n.json | gzip > ccache.trace.gz -This will offset each invididual trace by starting time, to make one combined trace. +This will offset each invididual trace by starting time to make one combined +trace. -If you set the variable, the trace JSON output will be put next to the object file: +When you set the `CCACHE_INTERNAL_TRACE` variable, the trace JSON output will +be put next to the object file, e.g. as `output.o.ccache-trace`. This is done +by first generating a temporary file until the output name is known. -e.g. `output.o.ccache-trace` +There is also another script to generate a summary (per job slot) of all the +ccache runs: -This is done by first generating a temporary file, until the output name is known. + misc/combine_events.py *.ccache-trace | misc/summarize_events.py 1 > ccache.trace -There is another script, to generate a summary (per job slot) of all the ccache runs: - -`misc/combine_events.py *.ccache-trace | misc/summarize_events.py 1 > ccache.trace` - -You will need to give the number of job slots used (`make -j`), as input to the script. +You will need to give the number of job slots used (`make -j`) as input to the +script. diff --git a/src/ccache.c b/src/ccache.c index e585b058e..1433eb179 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -3540,10 +3540,9 @@ create_initial_config_file(const char *path) #ifdef MTR_ENABLED static void *trace_id; static const char *trace_file; -#endif -#ifdef MTR_ENABLED -static void trace_init(const char *json) +static void +trace_init(const char *json) { trace_file = json; mtr_init(json); @@ -3551,7 +3550,8 @@ static void trace_init(const char *json) MTR_INSTANT_C("", "", "time", s); } -static void trace_start(const char *json) +static void +trace_start(const char *json) { trace_file = json; cc_log("Starting tracing: %s", json); @@ -3560,7 +3560,8 @@ static void trace_start(const char *json) MTR_START("program", "ccache", trace_id); } -static void trace_stop(void *context) +static void +trace_stop(void *context) { const char *json = (const char *) context; if (str_eq(json, "")) { @@ -3592,7 +3593,8 @@ tmpdir() #endif return "/tmp"; } -#endif + +#endif // MTR_ENABLED // Read config file(s), populate variables, create configuration file in cache // directory if missing, etc. @@ -3602,7 +3604,7 @@ initialize(void) char *tracefile = getenv("CCACHE_INTERNAL_TRACE"); if (tracefile != NULL) { #ifdef MTR_ENABLED - // We don't have any conf yet, so we can't use temp_dir() here + // We don't have any conf yet, so we can't use temp_dir() here. tracefile = format("%s/trace.%d.json", tmpdir(), (int)getpid()); trace_init(tracefile);