Skip to content

Commit

Permalink
Automated rollback of commit 781e862.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Memory regression.

PiperOrigin-RevId: 620802057
Change-Id: I645cfc0a817a2c5dcf47e2d34c02a77adede5b77
  • Loading branch information
jin authored and copybara-github committed Apr 1, 2024
1 parent 753dc97 commit 0f551a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,22 +320,23 @@ private PackageLookupValue getPackageLookupValue(
return null;
}

if (fileValue.isFile()) {
// Check for the existence of the project.scl file only in directories with a BUILD file.
// to avoid creating excessive FileValue nodes.
RootedPath projectFileRootedPath =
RootedPath.toRootedPath(
packagePathEntry,
packageIdentifier.getPackageFragment().getRelative(PROJECT_FILE_NAME));
FileValue projectFileValue = getFileValue(projectFileRootedPath, env, packageIdentifier);
if (projectFileValue == null) {
return null;
}
// Check for the existence of the project.scl file.
// TODO b/331316530: Temporarily removed to avoid build memory regressions. Re-enable as opt in.
/*RootedPath projectFileRootedPath =
RootedPath.toRootedPath(
packagePathEntry,
packageIdentifier.getPackageFragment().getRelative(PROJECT_FILE_NAME));
FileValue projectFileValue = getFileValue(projectFileRootedPath, env, packageIdentifier);
if (projectFileValue == null) {
return null;
} */

if (projectFileValue.exists() && !projectFileValue.isFile()) {
if (fileValue.isFile()) {
// TODO b/331316530: Temporarily removed to avoid build memory regressions. Re-enable as opt
// in.
/*if (projectFileValue.exists() && !projectFileValue.isFile()) {
return PackageLookupValue.INVALID_PROJECT_VALUE;
}

}*/
return PackageLookupValue.success(
buildFileRootedPath.getRoot(), buildFileName, /* hasProjectFile= */ false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.buildtool.util.BuildIntegrationTestCase;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
Expand All @@ -31,9 +30,7 @@
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Root;
import com.google.devtools.build.lib.vfs.RootedPath;
import com.google.devtools.common.options.Options;
import java.util.Set;
import java.util.UUID;
import org.junit.Before;
import org.junit.Ignore;
Expand Down Expand Up @@ -155,33 +152,4 @@ public void twoTargetsDifferentProjectFiles() throws Exception {
+ "For example: [foo/%s]: //foo:f [bar/%s]: //bar:g",
PROJECT_FILE_NAME, PROJECT_FILE_NAME));
}

@Test
public void ignoredProjectFileInNonPackages() throws Exception {
write("foo/bar/baz/" + PROJECT_FILE_NAME);
write("foo/bar/BUILD", "genrule(name='f', cmd = '', srcs=[], outs=['f.out'])");
write("foo/bar/" + PROJECT_FILE_NAME);
write("foo/" + PROJECT_FILE_NAME);

assertThat(
BuildTool.getProjectFile(
ImmutableList.of(Label.parseCanonical("//foo/bar:f")),
getSkyframeExecutor(),
events.reporter()))
.isEqualTo(PathFragment.create("foo/bar/" + PROJECT_FILE_NAME));

Set<RootedPath> projectRootedPaths = Sets.newConcurrentHashSet();
getSkyframeExecutor()
.getEvaluator()
.getInMemoryGraph()
.parallelForEach(
k -> {
if (k.getKey().argument() instanceof RootedPath rp) {
if (rp.getRootRelativePath().getBaseName().equals(PROJECT_FILE_NAME)) {
projectRootedPaths.add(rp);
}
}
});
assertThat(projectRootedPaths).hasSize(1);
}
}

0 comments on commit 0f551a5

Please sign in to comment.