Split SkyQueryEnvironment#getReverseDeps into a few helper methods and use them in ParallelSkyQueryUtils.
In AllRdepsUnboundedVisitor#getVisitResult, only get rdeps of the nodes in question. As long as we're careful to only visit nodes have corresponding Targets (which we already are doing), there's no need to also get the Targets corresponding to the nodes in question.
--
MOS_MIGRATED_REVID=135680956
diff --git a/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java b/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java
index 4d9212f..ec7474d 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java
@@ -170,8 +170,13 @@
protected Visit getVisitResult(Iterable<SkyKey> keys) throws InterruptedException {
// TODO(bazel-team): Defer some of this work to the next recursive visitation. Instead, have
// this visitation merely get the Skyframe-land rdeps.
+
+ // Note that this does more than merely get the Skyframe-land rdeps:
+ // (i) It only returns rdeps that have corresponding Targets.
+ // (ii) It only returns rdeps whose corresponding Targets have a valid dependency edge to
+ // their direct dep.
Iterable<SkyKey> keysToVisit = SkyQueryEnvironment.makeTransitiveTraversalKeysStrict(
- env.getReverseDeps(env.makeTargetsFromSkyKeys(keys).values()));
+ env.getReverseDepsOfTransitiveTraversalKeys(keys));
return new Visit(
/*keysToUseForResult=*/ keys,
/*keysToVisit=*/ keysToVisit);