Add stats about cache hits and execution strategies to Bazel's UI.
Fixes: 2846
RELNOTES: Bazel now displays information about remote cache hits and execution strategies used in its UI after every build and test, and adds a corresponding line "process stats" to BuildToolLogs in BEP.
PiperOrigin-RevId: 191441770
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
index 927355d..4d2cdce 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
@@ -18,6 +18,7 @@
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.devtools.build.lib.actions.ActionKeyContext;
+import com.google.devtools.build.lib.actions.ActionResultReceivedEvent;
import com.google.devtools.build.lib.buildeventstream.BuildToolLogs;
import com.google.devtools.build.lib.buildtool.BuildRequest;
import com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent;
@@ -50,11 +51,14 @@
private boolean enabled;
private boolean discardActions;
+ private SpawnStats spawnStats;
+
@Override
public void beforeCommand(CommandEnvironment env) {
this.reporter = env.getReporter();
this.eventBus = env.getEventBus();
this.actionKeyContext = env.getSkyframeExecutor().getActionKeyContext();
+ this.spawnStats = new SpawnStats();
eventBus.register(this);
}
@@ -63,6 +67,7 @@
this.criticalPathComputer = null;
this.eventBus = null;
this.reporter = null;
+ this.spawnStats = null;
}
@Override
@@ -81,6 +86,11 @@
}
@Subscribe
+ public void actionResultReceived(ActionResultReceivedEvent event) {
+ spawnStats.countActionResult(event.getActionResult());
+ }
+
+ @Subscribe
public void buildComplete(BuildCompleteEvent event) {
try {
// We might want to make this conditional on a flag; it can sometimes be a bit of a nuisance.
@@ -115,6 +125,11 @@
}
reporter.handle(Event.info(Joiner.on(", ").join(items)));
+
+ String spawnSummary = spawnStats.getSummary();
+ reporter.handle(Event.info(spawnSummary));
+ statistics.add(Pair.of("process stats", ByteString.copyFromUtf8(spawnSummary)));
+
reporter.post(new BuildToolLogs(statistics, ImmutableList.of()));
} finally {
criticalPathComputer = null;