-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.
#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);
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);
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, "")) {
#endif
return "/tmp";
}
-#endif
+
+#endif // MTR_ENABLED
// Read config file(s), populate variables, create configuration file in cache
// directory if missing, etc.
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);