diff options
author | 2018-07-27 06:11:47 -0700 | |
---|---|---|
committer | 2018-07-27 06:13:25 -0700 | |
commit | 2193da931c6804c497f8320dcc81e0d119d26c8c (patch) | |
tree | ab9f07f9684437c25da0dc89a5fc9c74d7f23422 /src/main/java/com/google/devtools/build/lib/runtime | |
parent | 0858ae1f6eb890c1e203a2aa21130ba34ca36a27 (diff) |
Add an option to compress the JSON trace profile.
chrome://tracing is able to load gzipped profiles out of the box.
RELNOTES: None
PiperOrigin-RevId: 206308018
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 | 19 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java | 8 |
2 files changed, 23 insertions, 4 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 a5336fa920..ee4147f666 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 @@ -45,6 +45,7 @@ import com.google.devtools.build.lib.profiler.AutoProfiler; import com.google.devtools.build.lib.profiler.MemoryProfiler; import com.google.devtools.build.lib.profiler.ProfilePhase; import com.google.devtools.build.lib.profiler.Profiler; +import com.google.devtools.build.lib.profiler.Profiler.Format; import com.google.devtools.build.lib.profiler.Profiler.ProfiledTaskKinds; import com.google.devtools.build.lib.profiler.ProfilerTask; import com.google.devtools.build.lib.profiler.SilentCloseable; @@ -274,14 +275,24 @@ public final class BlazeRuntime { Profiler.Format format = Profiler.Format.BINARY_BAZEL_FORMAT; try { if (options.enableTracer) { - Path profilePath = options.profilePath != null - ? workspace.getWorkspace().getRelative(options.profilePath) - : workspace.getOutputBase().getRelative("command.profile"); + format = + options.enableTracerCompression + ? Format.JSON_TRACE_FILE_COMPRESSED_FORMAT + : Profiler.Format.JSON_TRACE_FILE_FORMAT; + Path profilePath; + if (options.profilePath != null) { + profilePath = workspace.getWorkspace().getRelative(options.profilePath); + } else { + String profileName = "command.profile"; + if (format == Format.JSON_TRACE_FILE_COMPRESSED_FORMAT) { + profileName = "command.profile.gz"; + } + profilePath = workspace.getOutputBase().getRelative(profileName); + } recordFullProfilerData = false; out = profilePath.getOutputStream(); eventHandler.handle(Event.info("Writing tracer profile to '" + profilePath + "'")); profiledTasks = ProfiledTaskKinds.ALL_FOR_TRACE; - format = Profiler.Format.JSON_TRACE_FILE_FORMAT; } else if (options.profilePath != null) { Path profilePath = workspace.getWorkspace().getRelative(options.profilePath); 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 b398aff727..cef27315e6 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 @@ -196,6 +196,14 @@ public class CommonCommandOptions extends OptionsBase { public boolean enableTracer; @Option( + name = "experimental_json_trace_compression", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.LOGGING, + effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING}, + help = "If enabled, Bazel compresses the JSON-format profile with gzip.") + public boolean enableTracerCompression; + + @Option( name = "profile", defaultValue = "null", documentationCategory = OptionDocumentationCategory.LOGGING, |