Refactor in BuildView: move progress counters
Move the progress counters (e.g. number of
evaluated actions) into the SkyframeBuildView's
progressReceiver, because this reflects the
ownership of these counters more cleanly, since
the progressReceiver is the only object that
mutates them.
In SkyframeBuildView, merge
resetEvaluatedConfiguredTargetKeysSet() and
resetEvaluationActionCount() into just
resetProgressReceiver(), because the two calls
must go together, and because the new name
expresses the purpose of these methods better.
In BuildView, merge getTargetsConfigured and
getTargetsLoaded() into just
getTargetsConfiguredAndLoaded(), because the two
calls always go together, both used to call
SkyframeBuildView.getEvaluatedTargetKeys() which
created a new ImmutableSet for both. Now we only
create that set once.
Change-Id: If8d6518abdbb854974d9589329e66f711413264a
Closes #10516.
Change-Id: If8d6518abdbb854974d9589329e66f711413264a
PiperOrigin-RevId: 288452414
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index f94389e..90c4131 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -78,6 +78,7 @@
import com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.RegexFilter;
+import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.WalkableGraph;
import java.util.ArrayList;
import java.util.Collection;
@@ -162,17 +163,19 @@
this.skyframeBuildView = skyframeExecutor.getSkyframeBuildView();
}
- /** The number of configured targets freshly evaluated in the last analysis run. */
- public int getTargetsConfigured() {
- return skyframeBuildView.getEvaluatedTargetKeys().size();
- }
-
- /** The number of targets (not configured targets) loaded in the last analysis run. */
- public int getTargetsLoaded() {
- return skyframeBuildView.getEvaluatedTargetKeys().stream()
- .map(key -> ((ConfiguredTargetKey) key).getLabel())
- .collect(toSet())
- .size();
+ /**
+ * Returns two numbers: number of analyzed and number of loaded targets.
+ *
+ * <p>The first number: configured targets freshly evaluated in the last analysis run.
+ *
+ * <p>The second number: targets (not configured targets) loaded in the last analysis run.
+ */
+ public Pair<Integer, Integer> getTargetsConfiguredAndLoaded() {
+ ImmutableSet<SkyKey> keys = skyframeBuildView.getEvaluatedTargetKeys();
+ int targetsConfigured = keys.size();
+ int targetsLoaded =
+ keys.stream().map(key -> ((ConfiguredTargetKey) key).getLabel()).collect(toSet()).size();
+ return Pair.of(targetsConfigured, targetsLoaded);
}
public int getActionsConstructed() {
@@ -213,8 +216,7 @@
logger.atInfo().log("Starting analysis");
pollInterruptedStatus();
- skyframeBuildView.resetEvaluatedConfiguredTargetKeysSet();
- skyframeBuildView.resetEvaluationActionCount();
+ skyframeBuildView.resetProgressReceiver();
// TODO(ulfjack): Expensive. Maybe we don't actually need the targets, only the labels?
Collection<Target> targets =