aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2016-09-05 09:40:13 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-09-06 15:38:32 +0000
commitab64e592fe5f5fb2e5dd2996b72c75416b2de721 (patch)
treeb75286653cfe812584ae30f133ef1364af2f452a /src/main/java/com/google/devtools/build/lib
parentca4e573188e6466f31e2208f659734cf6428c811 (diff)
Make --experimental_interleave_loading_and_analysis a no-op.
This is now enabled by default, and this change removes the code path where it's disabled. Remove a few tests that were testing the removed code, and rewrite some others that still seem useful. We still drop configured targets on configuration changes, so we use that to check that things are dropped from Skyframe. -- MOS_MIGRATED_REVID=132226208
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/BuildView.java16
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java28
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/LegacyLoadingPhaseRunner.java210
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/LoadingCallback.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java22
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java21
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java46
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java23
8 files changed, 66 insertions, 311 deletions
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 0fbaebb7d2..e070680d1a 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
@@ -184,13 +184,6 @@ public class BuildView {
help = "Only schedules extra_actions for top level targets.")
public boolean extraActionTopLevelOnly;
- @Option(name = "experimental_interleave_loading_and_analysis",
- defaultValue = "true",
- category = "experimental",
- help = "Interleave loading and analysis phases, so that one target may be analyzed at"
- + " the same time as an unrelated target is loaded.")
- public boolean interleaveLoadingAndAnalysis;
-
@Option(name = "version_window_for_dirty_node_gc",
defaultValue = "0",
category = "undocumented",
@@ -198,6 +191,15 @@ public class BuildView {
+ " from the graph upon the next update. Values must be non-negative long integers,"
+ " or -1 indicating the maximum possible window.")
public long versionWindowForDirtyNodeGc;
+
+ @Deprecated
+ @Option(
+ name = "experimental_interleave_loading_and_analysis",
+ defaultValue = "true",
+ category = "experimental",
+ help = "No-op."
+ )
+ public boolean interleaveLoadingAndAnalysis;
}
private static Logger LOG = Logger.getLogger(BuildView.class.getName());
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
index caa0affcc3..974a63228c 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
@@ -44,7 +44,6 @@ import com.google.devtools.build.lib.buildtool.buildevent.BuildInterruptedEvent;
import com.google.devtools.build.lib.buildtool.buildevent.BuildStartingEvent;
import com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.events.Event;
@@ -400,20 +399,22 @@ public final class BuildTool {
validator.validateTargets(targets, keepGoing);
}
}
-
- @Override
- public void notifyVisitedPackages(Set<PackageIdentifier> visitedPackages) {
- env.getSkyframeExecutor().updateLoadedPackageSet(visitedPackages);
- }
};
LoadingPhaseRunner loadingPhaseRunner = env.getSkyframeExecutor().getLoadingPhaseRunner(
runtime.getPackageFactory().getRuleClassNames(),
request.getLoadingOptions().useSkyframeTargetPatternEvaluator);
- LoadingResult result = loadingPhaseRunner.execute(getReporter(),
- env.getEventBus(), request.getTargets(), env.getRelativeWorkingDirectory(),
- request.getLoadingOptions(), runtime.createBuildOptions(request).getAllLabels(),
- keepGoing, isLoadingEnabled(request), request.shouldRunTests(), callback);
+ LoadingResult result =
+ loadingPhaseRunner.execute(
+ getReporter(),
+ env.getEventBus(),
+ request.getTargets(),
+ env.getRelativeWorkingDirectory(),
+ request.getLoadingOptions(),
+ runtime.createBuildOptions(request).getAllLabels(),
+ keepGoing,
+ request.shouldRunTests(),
+ callback);
env.throwPendingException();
return result;
}
@@ -595,11 +596,4 @@ public final class BuildTool {
private Reporter getReporter() {
return env.getReporter();
}
-
- private static boolean isLoadingEnabled(BuildRequest request) {
- boolean enableLoadingFlag = !request.getViewOptions().interleaveLoadingAndAnalysis;
- // TODO(bazel-team): should return false when fdo optimization is enabled, because in that case,
- // we would require packages to be set before analysis phase. See FdoSupport#prepareToBuild.
- return enableLoadingFlag;
- }
}
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/LegacyLoadingPhaseRunner.java b/src/main/java/com/google/devtools/build/lib/pkgcache/LegacyLoadingPhaseRunner.java
index a3a288aeef..6d7fc3f251 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/LegacyLoadingPhaseRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/LegacyLoadingPhaseRunner.java
@@ -15,31 +15,22 @@ package com.google.devtools.build.lib.pkgcache;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.common.eventbus.EventBus;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.ResolvedTargets;
import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.events.DelegatingEventHandler;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
-import com.google.devtools.build.lib.packages.NoSuchThingException;
-import com.google.devtools.build.lib.packages.NonconfigurableAttributeMapper;
-import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.packages.TestTargetUtils;
-import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.vfs.PathFragment;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
@@ -99,15 +90,21 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner {
/**
* Performs target pattern evaluation, test suite expansion (if requested), and loads the
- * transitive closure of the resulting targets as well as of the targets needed to use the
- * given build configuration provider.
+ * transitive closure of the resulting targets as well as of the targets needed to use the given
+ * build configuration provider.
*/
@Override
- public LoadingResult execute(EventHandler eventHandler, EventBus eventBus,
- List<String> targetPatterns, PathFragment relativeWorkingDirectory, LoadingOptions options,
- ListMultimap<String, Label> labelsToLoadUnconditionally, boolean keepGoing,
- boolean enableLoading, boolean determineTests, @Nullable LoadingCallback callback)
- throws TargetParsingException, LoadingFailedException, InterruptedException {
+ public LoadingResult execute(
+ EventHandler eventHandler,
+ EventBus eventBus,
+ List<String> targetPatterns,
+ PathFragment relativeWorkingDirectory,
+ LoadingOptions options,
+ ListMultimap<String, Label> labelsToLoadUnconditionally,
+ boolean keepGoing,
+ boolean determineTests,
+ @Nullable LoadingCallback callback)
+ throws TargetParsingException, LoadingFailedException, InterruptedException {
LOG.info("Starting pattern evaluation");
Stopwatch timer = Stopwatch.createStarted();
if (options.buildTestsOnly && options.compileOneDependency) {
@@ -189,30 +186,20 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner {
}
LoadingPhaseRunner.maybeReportDeprecation(eventHandler, targets.getTargets());
- if (enableLoading) {
- return doLoadingPhase(eventHandler, eventBus, targets, testsToRun,
- labelsToLoadUnconditionally, keepGoing, options.loadingPhaseThreads, callback);
- } else {
- return doSimpleLoadingPhase(eventHandler, eventBus, targets, testsToRun, keepGoing);
- }
- }
-
- private void freeMemoryAfterLoading(LoadingCallback callback, Set<PackageIdentifier> visitedPackages) {
- if (callback != null) {
- callback.notifyVisitedPackages(visitedPackages);
- }
- // Clear some targets from the cache to free memory.
- packageManager.partiallyClear();
+ return doSimpleLoadingPhase(eventHandler, eventBus, targets, testsToRun, keepGoing);
}
- /**
- * Simplified version of {@code doLoadingPhase} method. This method does not load targets.
- * It only does test_suite expansion and emits necessary events and logging messages for legacy
+ /**
+ * Perform test_suite expansion and emits necessary events and logging messages for legacy
* support.
*/
- private LoadingResult doSimpleLoadingPhase(EventHandler eventHandler, EventBus eventBus,
- ResolvedTargets<Target> targets, ImmutableSet<Target> testsToRun, boolean keepGoing)
- throws InterruptedException, LoadingFailedException {
+ private LoadingResult doSimpleLoadingPhase(
+ EventHandler eventHandler,
+ EventBus eventBus,
+ ResolvedTargets<Target> targets,
+ ImmutableSet<Target> testsToRun,
+ boolean keepGoing)
+ throws InterruptedException, LoadingFailedException {
Stopwatch timer = preLoadingLogging(eventHandler);
ImmutableSet<Target> targetsToLoad = targets.getTargets();
@@ -228,36 +215,6 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner {
expandedResult.getTargets(), testsToRun, getWorkspaceName(eventHandler));
}
- /**
- * Visit the transitive closure of the targets, populating the package cache
- * and ensuring that all labels can be resolved and all rules were free from
- * errors.
- */
- private LoadingResult doLoadingPhase(EventHandler eventHandler, EventBus eventBus,
- ResolvedTargets<Target> targets, ImmutableSet<Target> testsToRun,
- ListMultimap<String, Label> labelsToLoadUnconditionally, boolean keepGoing,
- int loadingPhaseThreads, @Nullable LoadingCallback callback)
- throws InterruptedException, LoadingFailedException {
- Stopwatch timer = preLoadingLogging(eventHandler);
-
- TransitivePackageLoader pkgLoader = packageManager.newTransitiveLoader();
- BaseLoadingResult baseResult = performLoadingOfTargets(eventHandler, eventBus, pkgLoader,
- targets.getTargets(), labelsToLoadUnconditionally, keepGoing, loadingPhaseThreads);
- ResolvedTargets<Target> expandedResult;
- try {
- expandedResult = expandTestSuites(eventHandler, baseResult.getTargets(), keepGoing);
- } catch (TargetParsingException e) {
- // This shouldn't happen, because we've already loaded the targets successfully.
- throw (AssertionError) (new AssertionError("Unexpected target failure").initCause(e));
- }
- freeMemoryAfterLoading(callback, pkgLoader.getVisitedPackageNames());
-
- postLoadingLogging(eventBus, baseResult.getTargets(), expandedResult.getTargets(), timer);
- return new LoadingResult(targets.hasError(),
- !baseResult.isSuccesful() || expandedResult.hasError(),
- expandedResult.getTargets(), testsToRun, getWorkspaceName(eventHandler));
- }
-
private Stopwatch preLoadingLogging(EventHandler eventHandler) {
eventHandler.handle(Event.progress("Loading..."));
LOG.info("Starting loading phase");
@@ -273,50 +230,6 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner {
LOG.info("Loading phase finished");
}
- private BaseLoadingResult performLoadingOfTargets(EventHandler eventHandler, EventBus eventBus,
- TransitivePackageLoader pkgLoader, ImmutableSet<Target> targetsToLoad,
- ListMultimap<String, Label> labelsToLoadUnconditionally, boolean keepGoing,
- int loadingPhaseThreads) throws InterruptedException, LoadingFailedException {
- Set<Label> labelsToLoad = ImmutableSet.copyOf(labelsToLoadUnconditionally.values());
-
- // For each label in {@code targetsToLoad}, ensure that the target to which
- // it refers exists, and also every target in its transitive closure of label
- // dependencies. Success guarantees that a call to
- // {@code getConfiguredTarget} for the same targets will not fail; the
- // configuration process is intolerant of missing packages/targets. Before
- // calling getConfiguredTarget(), clients must ensure that all necessary
- // packages/targets have been visited since the last sync/clear.
- boolean loadingSuccessful = pkgLoader.sync(eventHandler, targetsToLoad, labelsToLoad,
- keepGoing, loadingPhaseThreads, Integer.MAX_VALUE);
-
- ImmutableSet<Target> targetsToAnalyze;
- if (loadingSuccessful) {
- // Success: all loaded targets will be analyzed.
- targetsToAnalyze = targetsToLoad;
- } else if (keepGoing) {
- // Keep going: filter out the error-free targets and only continue with those.
- targetsToAnalyze = filterErrorFreeTargets(eventHandler, eventBus, pkgLoader, targetsToLoad,
- labelsToLoadUnconditionally);
- reportAboutPartiallySuccesfulLoading(targetsToLoad, targetsToAnalyze, eventHandler);
- } else {
- throw new LoadingFailedException("Loading failed; build aborted");
- }
- return new BaseLoadingResult(targetsToAnalyze, loadingSuccessful);
- }
-
- private void reportAboutPartiallySuccesfulLoading(ImmutableSet<Target> requestedTargets,
- ImmutableSet<Target> loadedTargets, EventHandler eventHandler) {
- // Tell the user about the subset of successful targets.
- int requested = requestedTargets.size();
- int loaded = loadedTargets.size();
- if (0 < loaded) {
- String message = String.format("Loading succeeded for only %d of %d targets", loaded,
- requested);
- eventHandler.handle(Event.info(message));
- LOG.info(message);
- }
- }
-
private ResolvedTargets<Target> expandTestSuites(EventHandler eventHandler,
ImmutableSet<Target> targets, boolean keepGoing)
throws LoadingFailedException, TargetParsingException {
@@ -329,65 +242,6 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner {
return expandedResult;
}
- private static class BaseLoadingResult {
- private final ImmutableSet<Target> targets;
- private final boolean succesful;
-
- BaseLoadingResult(ImmutableSet<Target> targets, boolean succesful) {
- this.targets = targets;
- this.succesful = succesful;
- }
-
- ImmutableSet<Target> getTargets() {
- return targets;
- }
-
- boolean isSuccesful() {
- return succesful;
- }
- }
-
- private static Set<Target> getTargetsForLabels(
- LoadedPackageProvider loadedPackageProvider, Collection<Label> labels)
- throws InterruptedException {
- Set<Target> result = new HashSet<>();
- for (Label label : labels) {
- try {
- result.add(loadedPackageProvider.getLoadedTarget(label));
- } catch (NoSuchThingException e) {
- throw new IllegalStateException(e); // The target should have been loaded
- }
- }
- return result;
- }
-
- private ImmutableSet<Target> filterErrorFreeTargets(
- EventHandler eventHandler,
- EventBus eventBus,
- TransitivePackageLoader pkgLoader,
- Collection<Target> targetsToLoad,
- ListMultimap<String, Label> labelsToLoadUnconditionally)
- throws LoadingFailedException, InterruptedException {
- // Error out if any of the labels needed for the configuration could not be loaded.
- Multimap<Label, Label> rootCauses = pkgLoader.getRootCauses();
- for (Map.Entry<String, Label> entry : labelsToLoadUnconditionally.entries()) {
- Label label = entry.getValue();
- if (rootCauses.containsKey(label)) {
- throw new LoadingFailedException(
- String.format("Failed to load required %s target: '%s'", entry.getKey(), label));
- }
- }
-
- // Post root causes for command-line targets that could not be loaded.
- for (Map.Entry<Label, Label> entry : rootCauses.entries()) {
- eventBus.post(new LoadingFailureEvent(entry.getKey(), entry.getValue()));
- }
-
- LoadedPackageProvider packageProvider = new LoadedPackageProvider(packageManager, eventHandler);
- return ImmutableSet.copyOf(Sets.difference(ImmutableSet.copyOf(targetsToLoad),
- getTargetsForLabels(packageProvider, rootCauses.keySet())));
- }
-
/**
* Interpret the command-line arguments.
*
@@ -431,24 +285,6 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner {
return finalBuilder.build();
}
- /**
- * Emit a warning when a deprecated target is mentioned on the command line.
- *
- * <p>Note that this does not stop us from emitting "target X depends on deprecated target Y"
- * style warnings for the same target and it is a good thing; <i>depending</i> on a target and
- * <i>wanting</i> to build it are different things.
- */
- // Public for use by skyframe.TargetPatternPhaseFunction until this class goes away.
- public static void maybeReportDeprecation(EventHandler eventHandler, Collection<Target> targets) {
- for (Rule rule : Iterables.filter(targets, Rule.class)) {
- if (rule.isAttributeValueExplicitlySpecified("deprecation")) {
- eventHandler.handle(Event.warn(rule.getLocation(), String.format(
- "target '%s' is deprecated: %s", rule.getLabel(),
- NonconfigurableAttributeMapper.of(rule).get("deprecation", Type.STRING))));
- }
- }
- }
-
private String getWorkspaceName(EventHandler eventHandler)
throws InterruptedException, LoadingFailedException {
try {
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingCallback.java b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingCallback.java
index 5b4538399c..56ac260947 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingCallback.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingCallback.java
@@ -13,11 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.pkgcache;
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.Target;
-
import java.util.Collection;
-import java.util.Set;
/**
* A callback interface to notify the caller about specific events.
@@ -29,12 +26,4 @@ public interface LoadingCallback {
* the list before proceeding.
*/
void notifyTargets(Collection<Target> targets) throws LoadingFailedException;
-
- /**
- * Called after loading has finished, to notify the caller about the visited packages.
- *
- * <p>The set of visited packages is the set of packages in the transitive closure of the
- * union of the top level targets.
- */
- void notifyVisitedPackages(Set<PackageIdentifier> visitedPackages);
} \ No newline at end of file
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java
index 210b154ec5..7c7fbcad1d 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java
@@ -29,10 +29,8 @@ import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
-
import java.util.Collection;
import java.util.List;
-
import javax.annotation.Nullable;
/**
@@ -56,14 +54,20 @@ import javax.annotation.Nullable;
public abstract class LoadingPhaseRunner {
/**
* Performs target pattern evaluation, test suite expansion (if requested), and loads the
- * transitive closure of the resulting targets as well as of the targets needed to use the
- * given build configuration provider.
+ * transitive closure of the resulting targets as well as of the targets needed to use the given
+ * build configuration provider.
*/
- public abstract LoadingResult execute(EventHandler eventHandler, EventBus eventBus,
- List<String> targetPatterns, PathFragment relativeWorkingDirectory, LoadingOptions options,
- ListMultimap<String, Label> labelsToLoadUnconditionally, boolean keepGoing,
- boolean enableLoading, boolean determineTests, @Nullable LoadingCallback callback)
- throws TargetParsingException, LoadingFailedException, InterruptedException;
+ public abstract LoadingResult execute(
+ EventHandler eventHandler,
+ EventBus eventBus,
+ List<String> targetPatterns,
+ PathFragment relativeWorkingDirectory,
+ LoadingOptions options,
+ ListMultimap<String, Label> labelsToLoadUnconditionally,
+ boolean keepGoing,
+ boolean determineTests,
+ @Nullable LoadingCallback callback)
+ throws TargetParsingException, LoadingFailedException, InterruptedException;
/**
* Returns a map of collected package names to root paths.
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
index 1c3901408b..0664229913 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
@@ -27,7 +27,6 @@ import com.google.devtools.common.options.Converters;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParsingException;
-
import java.util.List;
/**
@@ -111,26 +110,6 @@ public class PackageCacheOptions extends OptionsBase {
help = "Number of threads to use for glob evaluation.")
public int globbingThreads;
- @Option(name = "min_pkg_count_for_ct_node_eviction",
- defaultValue = "3700",
- // Why is the default value 3700? As of December 2013, a medium target loads about this many
- // packages, uses ~310MB RAM to only load [1] or ~990MB to load and analyze [2,3]. So we
- // can likely load and analyze this many packages without worrying about Blaze OOM'ing.
- //
- // If the total number of unique packages so far [4] is higher than the value of this flag,
- // then we evict CT nodes [5] from the Skyframe graph.
- //
- // [1] blaze -x build --nobuild --noanalyze //medium:target
- // [2] blaze -x build --nobuild //medium:target
- // [3] according to "blaze info used-heap-size"
- // [4] this means the number of unique packages loaded by builds, including the current one,
- // since the last CT node eviction [5]
- // [5] "CT node eviction" means clearing those nodes from the Skyframe graph that correspond
- // to ConfiguredTargets; this is done using SkyframeExecutor.resetConfiguredTargets
- category = "undocumented",
- help = "Threshold for number of loaded packages before skyframe-m1 cache eviction kicks in")
- public int minLoadedPkgCountForCtNodeEviction;
-
@Option(name = "fetch",
defaultValue = "true",
category = "undocumented",
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java
index ace63f8173..18903e8c8b 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java
@@ -65,7 +65,6 @@ import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
-
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -85,11 +84,6 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
private static final Logger LOG = Logger.getLogger(SequencedSkyframeExecutor.class.getName());
- /** Lower limit for number of loaded packages to consider clearing CT values. */
- private int valueCacheEvictionLimit = -1;
-
- /** Union of labels of loaded packages since the last eviction of CT values. */
- private Set<PackageIdentifier> allLoadedPackages = ImmutableSet.of();
private boolean lastAnalysisDiscarded = false;
// Can only be set once (to false) over the lifetime of this object. If false, the graph will not
@@ -259,7 +253,6 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
Path outputBase, Path workingDirectory, String defaultsPackageContents, UUID commandId,
TimestampGranularityMonitor tsgm)
throws InterruptedException, AbruptExitException {
- this.valueCacheEvictionLimit = packageCacheOptions.minLoadedPkgCountForCtNodeEviction;
super.sync(eventHandler, packageCacheOptions, outputBase, workingDirectory,
defaultsPackageContents, commandId, tsgm);
handleDiffs(eventHandler, packageCacheOptions.checkOutputFiles);
@@ -618,45 +611,6 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
}
}
- /**
- * Returns true if the old set of Packages is a subset or superset of the new one.
- *
- * <p>Compares the names of packages instead of the Package objects themselves (Package doesn't
- * yet override #equals). Since packages store their names as a String rather than a Label, it's
- * easier to use strings here.
- */
- @VisibleForTesting
- static boolean isBuildSubsetOrSupersetOfPreviousBuild(Set<PackageIdentifier> oldPackages,
- Set<PackageIdentifier> newPackages) {
- if (newPackages.size() <= oldPackages.size()) {
- return Sets.difference(newPackages, oldPackages).isEmpty();
- } else if (oldPackages.size() < newPackages.size()) {
- // No need to check for <= here, since the first branch does that already.
- // If size(A) = size(B), then then A\B = 0 iff B\A = 0
- return Sets.difference(oldPackages, newPackages).isEmpty();
- } else {
- return false;
- }
- }
-
- @Override
- public void updateLoadedPackageSet(Set<PackageIdentifier> loadedPackages) {
- Preconditions.checkState(valueCacheEvictionLimit >= 0,
- "should have called setMinLoadedPkgCountForCtValueEviction earlier");
-
- // Make a copy to avoid nesting SetView objects. It also computes size(), which we need below.
- Set<PackageIdentifier> union = ImmutableSet.copyOf(
- Sets.union(allLoadedPackages, loadedPackages));
-
- if (union.size() < valueCacheEvictionLimit
- || isBuildSubsetOrSupersetOfPreviousBuild(allLoadedPackages, loadedPackages)) {
- allLoadedPackages = union;
- } else {
- dropConfiguredTargets();
- allLoadedPackages = loadedPackages;
- }
- }
-
@Override
public void deleteOldNodes(long versionWindowForDirtyGc) {
// TODO(bazel-team): perhaps we should come up with a separate GC class dedicated to maintaining
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index bc358f8a03..5c11cc2440 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -1626,15 +1626,6 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
return memoizingEvaluator;
}
- /**
- * Stores the set of loaded packages and, if needed, evicts ConfiguredTarget values.
- *
- * <p>The set represents all packages from the transitive closure of the top-level targets from
- * the latest build.
- */
- @ThreadCompatible
- public abstract void updateLoadedPackageSet(Set<PackageIdentifier> loadedPackages);
-
public void sync(EventHandler eventHandler, PackageCacheOptions packageCacheOptions,
Path outputBase, Path workingDirectory, String defaultsPackageContents, UUID commandId,
TimestampGranularityMonitor tsgm)
@@ -1762,10 +1753,16 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
}
@Override
- public LoadingResult execute(EventHandler eventHandler, EventBus eventBus,
- List<String> targetPatterns, PathFragment relativeWorkingDirectory, LoadingOptions options,
- ListMultimap<String, Label> labelsToLoadUnconditionally, boolean keepGoing,
- boolean enableLoading, boolean determineTests, @Nullable LoadingCallback callback)
+ public LoadingResult execute(
+ EventHandler eventHandler,
+ EventBus eventBus,
+ List<String> targetPatterns,
+ PathFragment relativeWorkingDirectory,
+ LoadingOptions options,
+ ListMultimap<String, Label> labelsToLoadUnconditionally,
+ boolean keepGoing,
+ boolean determineTests,
+ @Nullable LoadingCallback callback)
throws TargetParsingException, LoadingFailedException, InterruptedException {
Stopwatch timer = Stopwatch.createStarted();
SkyKey key = TargetPatternPhaseValue.key(ImmutableList.copyOf(targetPatterns),