aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2017-03-28 22:39:35 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2017-03-29 14:22:26 +0200
commitdb4dec23008069a4c5ceccdb686e515808c921ba (patch)
treeacec73f2e74a6f593c5f0e7dd5df22450654a15f /src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
parent0e866a8b732e31df1a4ddfd13c4870d4721de70b (diff)
Clear AspectValues when discarding analysis cache, along with ConfiguredTargetValues. Also clear transitive packages for both, even for top-level targets.
This is not expected to save significant memory, but is expected to reduce the number of references to Packages, allowing them to be dropped more easily when discarding analysis cache and running in batch mode. PiperOrigin-RevId: 151508877
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
index 09cc4eddc3..110957009f 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
@@ -27,9 +27,7 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.skyframe.SkyKey;
-
import java.util.Map;
-
import javax.annotation.Nullable;
/**
@@ -44,14 +42,14 @@ public final class ConfiguredTargetValue extends ActionLookupValue {
// only after they are cleared.
@Nullable private ConfiguredTarget configuredTarget;
- private final NestedSet<Package> transitivePackages;
+ @Nullable private NestedSet<Package> transitivePackages;
ConfiguredTargetValue(ConfiguredTarget configuredTarget,
Map<Artifact, ActionAnalysisMetadata> generatingActionMap,
NestedSet<Package> transitivePackages) {
super(generatingActionMap);
- this.configuredTarget = configuredTarget;
- this.transitivePackages = transitivePackages;
+ this.configuredTarget = Preconditions.checkNotNull(configuredTarget, generatingActionMap);
+ this.transitivePackages = Preconditions.checkNotNull(transitivePackages, generatingActionMap);
}
@VisibleForTesting
@@ -67,8 +65,9 @@ public final class ConfiguredTargetValue extends ActionLookupValue {
}
public NestedSet<Package> getTransitivePackages() {
- return transitivePackages;
+ return Preconditions.checkNotNull(transitivePackages);
}
+
/**
* Clears configured target data from this value, leaving only the artifact->generating action
* map.
@@ -76,10 +75,18 @@ public final class ConfiguredTargetValue extends ActionLookupValue {
* <p>Should only be used when user specifies --discard_analysis_cache. Must be called at most
* once per value, after which {@link #getConfiguredTarget} and {@link #getActions} cannot be
* called.
+ *
+ * @param clearEverything if true, clear the {@link #configuredTarget}. If not, only the {@link
+ * #transitivePackages} field is cleared. Top-level targets need their {@link
+ * #configuredTarget} preserved, so should pass false here.
*/
- public void clear() {
+ public void clear(boolean clearEverything) {
Preconditions.checkNotNull(configuredTarget);
- configuredTarget = null;
+ Preconditions.checkNotNull(transitivePackages);
+ if (clearEverything) {
+ configuredTarget = null;
+ }
+ transitivePackages = null;
}
@VisibleForTesting