From cd477f266e9b896e290d1830b822ca392d9f2114 Mon Sep 17 00:00:00 2001 From: jhorvitz Date: Wed, 5 May 2021 10:18:22 -0700 Subject: [PATCH] Pass only the top-level artifacts to `ExecutorLifecycleListener` and make the computation more efficient. Delete the now unused `ArtifactsToOwnerLabels`. PiperOrigin-RevId: 372152937 --- .../build/lib/analysis/AnalysisResult.java | 13 +- .../lib/analysis/ArtifactsToOwnerLabels.java | 125 ------------------ .../google/devtools/build/lib/analysis/BUILD | 13 -- .../build/lib/analysis/BuildView.java | 80 +++++------ .../build/lib/analysis/OutputGroupInfo.java | 11 +- .../lib/analysis/TopLevelArtifactHelper.java | 93 ++++++------- .../build/lib/buildtool/ExecutionTool.java | 17 +-- .../com/google/devtools/build/lib/exec/BUILD | 2 +- .../lib/exec/ExecutorLifecycleListener.java | 10 +- .../devtools/build/lib/includescanning/BUILD | 2 - .../IncludeScannerSupplier.java | 2 +- .../IncludeScanningModule.java | 12 +- .../includescanning/LegacyIncludeScanner.java | 12 +- .../google/devtools/build/lib/remote/BUILD | 1 - .../remote/RemoteActionContextProvider.java | 12 +- .../analysis/ArtifactsToOwnerLabelsTest.java | 65 --------- .../build/lib/analysis/AspectTest.java | 18 +-- .../google/devtools/build/lib/analysis/BUILD | 1 - .../build/lib/analysis/BuildViewTest.java | 2 +- .../google/devtools/build/lib/buildtool/BUILD | 2 +- .../ContextProviderInitializationTest.java | 11 +- .../starlark/StarlarkDefinedAspectsTest.java | 61 ++++----- 22 files changed, 160 insertions(+), 405 deletions(-) delete mode 100644 src/main/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabels.java delete mode 100644 src/test/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabelsTest.java diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java index 3c63b346de8f85..bd6d48e56e29e3 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Sets; import com.google.devtools.build.lib.actions.ActionGraph; +import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.PackageRoots; import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection; import com.google.devtools.build.lib.server.FailureDetails.FailureDetail; @@ -37,7 +38,7 @@ public final class AnalysisResult { private final ImmutableSet targetsToSkip; @Nullable private final FailureDetail failureDetail; private final ActionGraph actionGraph; - private final ArtifactsToOwnerLabels topLevelArtifactsToOwnerLabels; + private final ImmutableSet artifactsToBuild; private final ImmutableSet parallelTests; private final ImmutableSet exclusiveTests; @Nullable private final TopLevelArtifactContext topLevelContext; @@ -55,7 +56,7 @@ public final class AnalysisResult { ImmutableSet targetsToSkip, @Nullable FailureDetail failureDetail, ActionGraph actionGraph, - ArtifactsToOwnerLabels topLevelArtifactsToOwnerLabels, + ImmutableSet artifactsToBuild, ImmutableSet parallelTests, ImmutableSet exclusiveTests, TopLevelArtifactContext topLevelContext, @@ -70,7 +71,7 @@ public final class AnalysisResult { this.targetsToSkip = targetsToSkip; this.failureDetail = failureDetail; this.actionGraph = actionGraph; - this.topLevelArtifactsToOwnerLabels = topLevelArtifactsToOwnerLabels; + this.artifactsToBuild = artifactsToBuild; this.parallelTests = parallelTests; this.exclusiveTests = exclusiveTests; this.topLevelContext = topLevelContext; @@ -120,8 +121,8 @@ public ImmutableSet getTargetsToSkip() { return targetsToSkip; } - public ArtifactsToOwnerLabels getTopLevelArtifactsToOwnerLabels() { - return topLevelArtifactsToOwnerLabels; + public ImmutableSet getArtifactsToBuild() { + return artifactsToBuild; } public ImmutableSet getExclusiveTests() { @@ -178,7 +179,7 @@ public AnalysisResult withExclusiveTestsAsParallelTests() { targetsToSkip, failureDetail, actionGraph, - topLevelArtifactsToOwnerLabels, + artifactsToBuild, Sets.union(parallelTests, exclusiveTests).immutableCopy(), /*exclusiveTests=*/ ImmutableSet.of(), topLevelContext, diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabels.java b/src/main/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabels.java deleted file mode 100644 index 12fbb160fb582a..00000000000000 --- a/src/main/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabels.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2018 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package com.google.devtools.build.lib.analysis; - -import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.SetMultimap; -import com.google.common.collect.Sets; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.cmdline.Label; -import java.util.HashSet; -import java.util.Set; -import java.util.function.Predicate; - -/** - * Morally a {@link SetMultimap} from artifacts to the labels that own them, which may not be just - * {@link Artifact#getOwnerLabel} depending on the build. Optimizes for artifacts that are owned by - * their {@link Artifact#getOwnerLabel} by storing them separately. - */ -public class ArtifactsToOwnerLabels { - private final SetMultimap artifactToMultipleOrDifferentOwnerLabels; - private final Set artifactsOwnedOnlyByTheirLabels; - - private ArtifactsToOwnerLabels( - SetMultimap artifactToMultipleOrDifferentOwnerLabels, - Set artifactsOwnedOnlyByTheirLabels) { - this.artifactToMultipleOrDifferentOwnerLabels = artifactToMultipleOrDifferentOwnerLabels; - this.artifactsOwnedOnlyByTheirLabels = artifactsOwnedOnlyByTheirLabels; - } - - public Set