diff options
author | janakr <janakr@google.com> | 2017-09-22 16:17:07 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-09-25 09:38:44 -0400 |
commit | c6ff86fa17b8372bad1311601ef3db96a74b968e (patch) | |
tree | 9837c2aa602affa2e6854a27f31ac905c83e4a69 /src/main | |
parent | d8ba904a3b0598e97601bc670840e39f21799ead (diff) |
Remove BuildInfoFactory precomputed value.
PiperOrigin-RevId: 169728184
Diffstat (limited to 'src/main')
3 files changed, 23 insertions, 30 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionFunction.java index 79011a82a9..6fcd4c65e3 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionFunction.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.skyframe; import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactFactory; import com.google.devtools.build.lib.actions.Root; @@ -28,7 +29,6 @@ import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; -import java.util.Map; /** * Creates a {@link BuildInfoCollectionValue}. Only depends on the unique @@ -39,10 +39,14 @@ public class BuildInfoCollectionFunction implements SkyFunction { // Supplier only because the artifact factory has not yet been created at constructor time. private final Supplier<ArtifactFactory> artifactFactory; private final Supplier<Boolean> removeActionsAfterEvaluation; + private final ImmutableMap<BuildInfoKey, BuildInfoFactory> buildInfoFactories; BuildInfoCollectionFunction( - Supplier<ArtifactFactory> artifactFactory, Supplier<Boolean> removeActionsAfterEvaluation) { + Supplier<ArtifactFactory> artifactFactory, + ImmutableMap<BuildInfoKey, BuildInfoFactory> buildInfoFactories, + Supplier<Boolean> removeActionsAfterEvaluation) { this.artifactFactory = artifactFactory; + this.buildInfoFactories = buildInfoFactories; this.removeActionsAfterEvaluation = Preconditions.checkNotNull(removeActionsAfterEvaluation); } @@ -54,11 +58,6 @@ public class BuildInfoCollectionFunction implements SkyFunction { if (infoArtifactValue == null) { return null; } - Map<BuildInfoKey, BuildInfoFactory> buildInfoFactories = - PrecomputedValue.BUILD_INFO_FACTORIES.get(env); - if (buildInfoFactories == null) { - return null; - } WorkspaceNameValue nameValue = (WorkspaceNameValue) env.getValue(WorkspaceNameValue.key()); if (nameValue == null) { return null; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java index ff5dc00884..7e6b7acae8 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java @@ -434,14 +434,12 @@ public final class SkyframeBuildView { */ // TODO(bazel-team): Allow analysis to return null so the value builder can exit and wait for a // restart deps are not present. - private static boolean getWorkspaceStatusValues(Environment env, BuildConfiguration config) + private static boolean getWorkspaceStatusValues( + Environment env, + BuildConfiguration config, + ImmutableMap<BuildInfoKey, BuildInfoFactory> buildInfoFactories) throws InterruptedException { env.getValue(WorkspaceStatusValue.SKY_KEY); - Map<BuildInfoKey, BuildInfoFactory> buildInfoFactories = - PrecomputedValue.BUILD_INFO_FACTORIES.get(env); - if (buildInfoFactories == null) { - return false; - } // These factories may each create their own build info artifacts, all depending on the basic // build-info.txt and build-changelist.txt. List<SkyKey> depKeys = Lists.newArrayList(); @@ -463,7 +461,8 @@ public final class SkyframeBuildView { Environment env, BuildConfiguration config) throws InterruptedException { - if (config != null && !getWorkspaceStatusValues(env, config)) { + if (config != null + && !getWorkspaceStatusValues(env, config, skyframeExecutor.getBuildInfoFactories())) { return null; } boolean extendedSanityChecks = config != null && config.extendedSanityChecks(); 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 dc1ca91ea7..a25c8c2721 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 @@ -236,7 +236,8 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { new AtomicReference<>(); protected final AtomicReference<Map<String, String>> clientEnv = new AtomicReference<>(); - private final ImmutableList<BuildInfoFactory> buildInfoFactories; + private final ImmutableMap<BuildInfoKey, BuildInfoFactory> buildInfoFactories; + // Under normal circumstances, the artifact factory persists for the life of a Blaze server, but // since it is not yet created when we create the value builders, we have to use a supplier, // initialized when the build view is created. @@ -322,7 +323,11 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { this.resourceManager = ResourceManager.instance(); this.skyframeActionExecutor = new SkyframeActionExecutor(eventBus, statusReporterRef); this.directories = Preconditions.checkNotNull(directories); - this.buildInfoFactories = buildInfoFactories; + ImmutableMap.Builder<BuildInfoKey, BuildInfoFactory> factoryMapBuilder = ImmutableMap.builder(); + for (BuildInfoFactory factory : buildInfoFactories) { + factoryMapBuilder.put(factory.getKey(), factory); + } + this.buildInfoFactories = factoryMapBuilder.build(); this.allowedMissingInputs = allowedMissingInputs; this.extraSkyFunctions = extraSkyFunctions; this.extraPrecomputedValues = extraPrecomputedValues; @@ -438,7 +443,8 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { map.put(SkyFunctions.ARTIFACT, new ArtifactFunction(allowedMissingInputs)); map.put( SkyFunctions.BUILD_INFO_COLLECTION, - new BuildInfoCollectionFunction(artifactFactory, removeActionsAfterEvaluation)); + new BuildInfoCollectionFunction( + artifactFactory, buildInfoFactories, removeActionsAfterEvaluation)); map.put(SkyFunctions.BUILD_INFO, new WorkspaceStatusFunction(removeActionsAfterEvaluation)); map.put(SkyFunctions.COVERAGE_REPORT, new CoverageReportFunction(removeActionsAfterEvaluation)); ActionExecutionFunction actionExecutionFunction = @@ -714,7 +720,6 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { protected void maybeInjectPrecomputedValuesForAnalysis() { if (needToInjectPrecomputedValuesForAnalysis) { - injectBuildInfoFactories(); injectExtraPrecomputedValues(extraPrecomputedValues); needToInjectPrecomputedValuesForAnalysis = false; } @@ -736,18 +741,8 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { return CacheBuilder.newBuilder().build(); } - /** - * Injects the build info factory map that will be used when constructing build info - * actions/artifacts. Unchanged across the life of the Blaze server, although it must be injected - * each time the evaluator is created. - */ - private void injectBuildInfoFactories() { - ImmutableMap.Builder<BuildInfoKey, BuildInfoFactory> factoryMapBuilder = - ImmutableMap.builder(); - for (BuildInfoFactory factory : buildInfoFactories) { - factoryMapBuilder.put(factory.getKey(), factory); - } - PrecomputedValue.BUILD_INFO_FACTORIES.set(injectable(), factoryMapBuilder.build()); + public ImmutableMap<BuildInfoKey, BuildInfoFactory> getBuildInfoFactories() { + return buildInfoFactories; } private void setShowLoadingProgress(boolean showLoadingProgressValue) { |