diff options
author | 2018-06-12 12:21:25 -0700 | |
---|---|---|
committer | 2018-06-12 12:23:15 -0700 | |
commit | 400fffe8b2df50c5b57ced5d9a8b46e40d529d4e (patch) | |
tree | a9a1291a0a05d4dee5c8e2ea9da092135c91a42f /src/main/java/com/google/devtools/build/lib/runtime | |
parent | c958649131ab8cf48a881aaddc50390cb7d79bfb (diff) |
Add support for the Json trace file format
Add a --experimental_generate_json_trace_profile option that puts a file into
the output base (or uses --profile if set).
There are still a lot of problems with this.
- unexplained holes
- way too many threads
- nonsensical event titles
- too many detail events, too little overview
- it may also cause unnecessary load
- it silently overwrites the existing file on subsequent invocations
The format is documented here: goo.gl/oMZPLh
PiperOrigin-RevId: 200259431
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java | 10 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java | 11 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index a7b1a96a0c..cb7dd06472 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java @@ -272,7 +272,15 @@ public final class BlazeRuntime { ProfiledTaskKinds profiledTasks = ProfiledTaskKinds.NONE; try { - if (options.profilePath != null) { + if (options.enableTracer) { + Path profilePath = options.profilePath != null + ? env.getWorkspace().getRelative(options.profilePath) + : env.getOutputBase().getRelative("command.profile"); + recordFullProfilerData = false; + out = profilePath.getOutputStream(); + env.getReporter().handle(Event.info("Writing tracer profile to '" + profilePath + "'")); + profiledTasks = ProfiledTaskKinds.ALL_FOR_TRACE; + } else if (options.profilePath != null) { Path profilePath = env.getWorkspace().getRelative(options.profilePath); recordFullProfilerData = options.recordFullProfilerData; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java index 6e9ba86492..923ebe6693 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java @@ -194,6 +194,17 @@ public class CommonCommandOptions extends OptionsBase { public String buildRequestId; @Option( + name = "experimental_generate_json_trace_profile", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.LOGGING, + effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING}, + help = + "If enabled, Bazel profiles the build and writes a JSON-format profile into a file in the " + + "output base." + ) + public boolean enableTracer; + + @Option( name = "profile", defaultValue = "null", documentationCategory = OptionDocumentationCategory.LOGGING, |