Skip to content

Commit

Permalink
Remove dead code.
Browse files Browse the repository at this point in the history
`omittedFiles` and `omittedTreeRoots` are always empty.

PiperOrigin-RevId: 670959452
Change-Id: I02b3c3ebbb085677d4d38c128664758511603bbb
  • Loading branch information
coeuvre authored and copybara-github committed Sep 4, 2024
1 parent dc216aa commit 4ab411c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile;
import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile.LocalFileType;
Expand All @@ -42,7 +41,6 @@
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.remote.util.TracingMetadataUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.XattrProvider;
import io.netty.util.AbstractReferenceCounted;
import io.netty.util.ReferenceCounted;
Expand Down Expand Up @@ -82,8 +80,6 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted
private final AtomicBoolean shutdown = new AtomicBoolean();
private final Scheduler scheduler;

private final Set<PathFragment> omittedFiles = Sets.newConcurrentHashSet();
private final Set<PathFragment> omittedTreeRoots = Sets.newConcurrentHashSet();
private final XattrProvider xattrProvider;
private final RemoteBuildEventUploadMode remoteBuildEventUploadMode;

Expand Down Expand Up @@ -111,20 +107,6 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted
this.remoteBuildEventUploadMode = remoteBuildEventUploadMode;
}

public void omitFile(Path file) {
Preconditions.checkState(
remoteBuildEventUploadMode != RemoteBuildEventUploadMode.MINIMAL,
"Cannot omit file in MINIMAL mode");
omittedFiles.add(file.asFragment());
}

public void omitTree(Path treeRoot) {
Preconditions.checkState(
remoteBuildEventUploadMode != RemoteBuildEventUploadMode.MINIMAL,
"Cannot omit tree in MINIMAL mode");
omittedTreeRoots.add(treeRoot.asFragment());
}

/** Returns {@code true} if Bazel knows that the file is stored on a remote system. */
private static boolean isRemoteFile(Path file) throws IOException {
return file.getFileSystem() instanceof RemoteActionFileSystem
Expand All @@ -138,7 +120,6 @@ private static final class PathMetadata {
private final boolean directory;
private final boolean symlink;
private final boolean remote;
private final boolean omitted;
private final boolean isBuildToolLog;
private final DigestFunction.Value digestFunction;

Expand All @@ -148,15 +129,13 @@ private static final class PathMetadata {
boolean directory,
boolean symlink,
boolean remote,
boolean omitted,
boolean isBuildToolLog,
DigestFunction.Value digestFunction) {
this.path = path;
this.digest = digest;
this.directory = directory;
this.symlink = symlink;
this.remote = remote;
this.omitted = omitted;
this.isBuildToolLog = isBuildToolLog;
this.digestFunction = digestFunction;
}
Expand All @@ -181,10 +160,6 @@ public boolean isRemote() {
return remote;
}

public boolean isOmitted() {
return omitted;
}

public boolean isBuildToolLog() {
return isBuildToolLog;
}
Expand Down Expand Up @@ -212,7 +187,6 @@ private PathMetadata readPathMetadata(Path path, LocalFile file) throws IOExcept
/* directory= */ true,
/* symlink= */ false,
/* remote= */ false,
/* omitted= */ false,
/* isBuildToolLog= */ false,
/* digestFunction= */ digestUtil.getDigestFunction());
}
Expand All @@ -223,24 +197,10 @@ private PathMetadata readPathMetadata(Path path, LocalFile file) throws IOExcept
/* directory= */ false,
/* symlink= */ true,
/* remote= */ false,
/* omitted= */ false,
/* isBuildToolLog= */ false,
/* digestFunction= */ digestUtil.getDigestFunction());
}

PathFragment filePathFragment = path.asFragment();
boolean omitted = false;
if (omittedFiles.contains(filePathFragment)) {
omitted = true;
} else {
for (PathFragment treeRoot : omittedTreeRoots) {
if (path.startsWith(treeRoot)) {
omittedFiles.add(filePathFragment);
omitted = true;
}
}
}

Digest digest = digestUtil.compute(path);
boolean isBuildToolLog =
file.type == LocalFileType.LOG || file.type == LocalFileType.PERFORMANCE_LOG;
Expand All @@ -250,7 +210,6 @@ private PathMetadata readPathMetadata(Path path, LocalFile file) throws IOExcept
/* directory= */ false,
/* symlink= */ false,
isRemoteFile(path),
omitted,
isBuildToolLog,
digestUtil.getDigestFunction());
}
Expand All @@ -270,7 +229,6 @@ private static void processQueryResult(
file.isDirectory(),
file.isSymlink(),
/* remote= */ true,
file.isOmitted(),
file.isBuildToolLog(),
file.getDigestFunction());
knownRemotePaths.add(remotePathMetadata);
Expand All @@ -280,11 +238,7 @@ private static void processQueryResult(

private boolean shouldUpload(PathMetadata path) {
boolean result =
path.getDigest() != null
&& !path.isRemote()
&& !path.isDirectory()
&& !path.isSymlink()
&& !path.isOmitted();
path.getDigest() != null && !path.isRemote() && !path.isDirectory() && !path.isSymlink();

if (remoteBuildEventUploadMode == RemoteBuildEventUploadMode.MINIMAL) {
result = result && (path.isBuildToolLog() || isBuildOrTestLog(path));
Expand All @@ -304,8 +258,7 @@ private Single<List<PathMetadata>> queryRemoteCache(
List<PathMetadata> filesToQuery = new ArrayList<>();
Set<Digest> digestsToQuery = new HashSet<>();
for (PathMetadata path : paths) {
// Query remote cache for files even if omitted from uploading
if (shouldUpload(path) || path.isOmitted()) {
if (shouldUpload(path)) {
filesToQuery.add(path);
digestsToQuery.add(path.getDigest());
} else {
Expand Down Expand Up @@ -369,7 +322,6 @@ private Single<List<PathMetadata>> uploadLocalFiles(
// set remote to true so the PathConverter will use bytestream://
// scheme to convert the URI for this file
/* remote= */ true,
path.isOmitted(),
path.isBuildToolLog(),
path.getDigestFunction()))
.onErrorResumeNext(
Expand Down Expand Up @@ -425,7 +377,6 @@ private Single<PathConverter> doUpload(Map<Path, LocalFile> files) {
/* directory= */ false,
/* symlink= */ false,
/* remote= */ false,
/* omitted= */ false,
/* isBuildToolLog= */ false,
DigestFunction.Value.SHA256);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.AnalysisResult;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.analysis.ConfiguredAspect;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.CoreOptions;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions;
import com.google.devtools.build.lib.authandtls.CallCredentialsProvider;
import com.google.devtools.build.lib.authandtls.GoogleAuthUtils;
Expand Down Expand Up @@ -71,7 +69,6 @@
import com.google.devtools.build.lib.remote.options.RemoteOutputsMode;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.remote.util.TracingMetadataUtils;
import com.google.devtools.build.lib.remote.util.Utils;
import com.google.devtools.build.lib.runtime.BlazeModule;
import com.google.devtools.build.lib.runtime.BlazeRuntime;
import com.google.devtools.build.lib.runtime.BlockWaitingModule;
Expand Down Expand Up @@ -816,11 +813,6 @@ public void afterTopLevelTargetAnalysis(
remoteOutputChecker.afterTopLevelTargetAnalysis(
configuredTarget, request::getTopLevelArtifactContext);
}
if (shouldParseNoCacheOutputs()) {
parseNoCacheOutputsFromSingleConfiguredTarget(
Preconditions.checkNotNull(buildEventArtifactUploaderFactoryDelegate.get()),
configuredTarget);
}
}

@Override
Expand Down Expand Up @@ -854,47 +846,6 @@ public void afterAnalysis(
if (remoteOutputChecker != null) {
remoteOutputChecker.afterAnalysis(analysisResult);
}

if (shouldParseNoCacheOutputs()) {
parseNoCacheOutputs(analysisResult);
}
}

// Separating the conditions for readability.
private boolean shouldParseNoCacheOutputs() {
return false;
}

private void parseNoCacheOutputs(AnalysisResult analysisResult) {
ByteStreamBuildEventArtifactUploader uploader =
Preconditions.checkNotNull(buildEventArtifactUploaderFactoryDelegate.get());

for (ConfiguredTarget configuredTarget : analysisResult.getTargetsToBuild()) {
parseNoCacheOutputsFromSingleConfiguredTarget(uploader, configuredTarget);
}
}

private void parseNoCacheOutputsFromSingleConfiguredTarget(
ByteStreamBuildEventArtifactUploader uploader, ConfiguredTarget configuredTarget) {
// This will either dereference an alias chain, or return the final ConfiguredTarget.
ConfiguredTarget actualConfiguredTarget = configuredTarget.getActual();
if (!(actualConfiguredTarget instanceof RuleConfiguredTarget ruleConfiguredTarget)) {
return;
}

for (ActionAnalysisMetadata action : ruleConfiguredTarget.getActions()) {
boolean uploadLocalResults =
Utils.shouldUploadLocalResultsToRemoteCache(remoteOptions, action.getExecutionInfo());
if (!uploadLocalResults) {
for (Artifact output : action.getOutputs()) {
if (output.isTreeArtifact()) {
uploader.omitTree(output.getPath());
} else {
uploader.omitFile(output.getPath());
}
}
}
}
}

private static void cleanAndCreateRemoteLogsDir(Path logDir) throws AbruptExitException {
Expand Down Expand Up @@ -1110,14 +1061,6 @@ public void init(ByteStreamBuildEventArtifactUploaderFactory uploaderFactory) {
this.uploaderFactory = uploaderFactory;
}

@Nullable
public ByteStreamBuildEventArtifactUploader get() {
if (uploaderFactory == null) {
return null;
}
return uploaderFactory.get();
}

public void reset() {
this.uploaderFactory = null;
}
Expand Down

0 comments on commit 4ab411c

Please sign in to comment.