From 96be0c17f0f5576b6c16aa954590c0ecbadb2c8b Mon Sep 17 00:00:00 2001 From: Nathan Harmata Date: Fri, 11 Sep 2015 22:15:50 +0000 Subject: Minor simple optimization in FileFunction: don't bother getting a FileStateValue for a path realpath 'parent/child' if 'parent' is known to not exist. This saves a stat for each ancestor path. -- MOS_MIGRATED_REVID=102881929 --- .../java/com/google/devtools/build/lib/skyframe/FileFunction.java | 5 ++++- .../java/com/google/devtools/build/lib/skyframe/FileStateValue.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/google/devtools') diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java index 32cce31b85..bec8ed358e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java @@ -145,6 +145,9 @@ public class FileFunction implements SkyFunction { RootedPath parentRealRootedPath = parentFileValue.realRootedPath(); realRootedPath = RootedPath.toRootedPath(parentRealRootedPath.getRoot(), parentRealRootedPath.getRelativePath().getRelative(baseName)); + if (!parentFileValue.exists()) { + return Pair.of(realRootedPath, FileStateValue.NONEXISTENT_FILE_STATE_NODE); + } } FileStateValue realFileStateValue = (FileStateValue) env.getValue(FileStateValue.key(realRootedPath)); @@ -155,7 +158,7 @@ public class FileFunction implements SkyFunction { && parentFileValue != null && !parentFileValue.isDirectory()) { String type = realFileStateValue.getType().toString().toLowerCase(); String message = type + " " + rootedPath.asPath() + " exists but its parent " - + "directory " + parentFileValue.realRootedPath().asPath() + " doesn't exist."; + + "path " + parentFileValue.realRootedPath().asPath() + " isn't an existing directory."; throw new FileFunctionException(new InconsistentFilesystemException(message), Transience.TRANSIENT); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java index 3d06d7c01f..0be5c318c6 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java @@ -175,8 +175,8 @@ public abstract class FileStateValue implements SkyValue { String errorMessage = e.getMessage() != null ? "error '" + e.getMessage() + "'" : "an error"; throw new InconsistentFilesystemException("'stat' said " + path + " is a file but then we " - + "later encountered " + errorMessage + " which indicates that " + path + " no longer " - + "exists. Did you delete it during the build?"); + + "later encountered " + errorMessage + " which indicates that " + path + " is no " + + "longer a file. Did you delete it during the build?"); } } -- cgit v1.2.3