aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2018-06-12 07:38:51 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-12 07:40:05 -0700
commit21d60de9af1770b6ef08702d5dc9e23ed928df10 (patch)
tree28b640381cdb05afbf1fce6c4d14f948e1a29837 /src/main/java/com/google/devtools/build/lib/runtime
parent71404a77556d564beddc8ec53c17ddbf6c8b8ab5 (diff)
Refactor profiler
- move the save method to an inner class - don't use a timer, use a blocking queue instead - add a format enum (in anticipation of adding a json output format) - update the test to use an in memory buffer, and avoid FoundationTestCase Compared to the original https://github.com/bazelbuild/bazel/commit/15b8c259db111012b4642287172cb4d1d82151f3, it contains these changes: - Make it so we don't create a queue if we are not going to write any data! The queue is now owned by the writer, and if there is no writer, there is no queue. This was causing a memory regression because slowest task profiling is enabled by default, in which case the profiler is started with no output file. In that case, there's no thread that is emptying the queue, but the queue was still created by default. - add additional tests for slowest task and histogram handling; these also provide coverage for the case where the profiler is started without an output stream - move all the writer thread handling into the inner class - make writer access thread-safe - add a bunch of documentation PiperOrigin-RevId: 200212978
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.java12
1 files changed, 8 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 dcdca11575..a7b1a96a0c 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
@@ -86,7 +86,6 @@ import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.OptionsParsingException;
import com.google.devtools.common.options.OptionsProvider;
import com.google.devtools.common.options.TriState;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -277,7 +276,7 @@ public final class BlazeRuntime {
Path profilePath = env.getWorkspace().getRelative(options.profilePath);
recordFullProfilerData = options.recordFullProfilerData;
- out = new BufferedOutputStream(profilePath.getOutputStream(), 1024 * 1024);
+ out = profilePath.getOutputStream();
env.getReporter().handle(Event.info("Writing profile data to '" + profilePath + "'"));
profiledTasks = ProfiledTaskKinds.ALL;
} else if (options.alwaysProfileSlowOperations) {
@@ -289,8 +288,13 @@ public final class BlazeRuntime {
Profiler.instance().start(
profiledTasks,
out,
- getProductName() + " profile for " + env.getOutputBase() + " at " + new Date()
- + ", build ID: " + buildID,
+ Profiler.Format.BINARY_BAZEL_FORMAT,
+ String.format(
+ "%s profile for %s at %s, build ID: %s",
+ getProductName(),
+ env.getOutputBase(),
+ new Date(),
+ buildID),
recordFullProfilerData,
clock,
execStartTimeNanos);