Introduce a FileSystemCalls.getType() function that just returns the type of a
file in question. In quite a few places that is sufficient and we might be able
to get the result based on a previously existing readdir() or stat() request if
we have either of them cached.
While at it, re-use the PerBuildSysCall cache inside of FileStateFunction in
order to profit from this.
This can prevent a whole bunch of unnecessary stat() calls, especially for
whether or not a BUILD file is present and for creating the FileStateValue for
symlinks and directories (for regular files we still need to stat() in order to
get modification time information).
RELNOTES: None.
PiperOrigin-RevId: 240794051
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
index 30ac67f..022867a 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
@@ -126,7 +126,9 @@
skyFunctions.put(
FileStateValue.FILE_STATE,
new FileStateFunction(
- new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper));
+ new AtomicReference<TimestampGranularityMonitor>(),
+ new AtomicReference(UnixGlob.DEFAULT_SYSCALLS),
+ externalFilesHelper));
skyFunctions.put(FileValue.FILE, new FileFunction(pkgLocator));
skyFunctions.put(SkyFunctions.DIRECTORY_LISTING, new DirectoryListingFunction());
skyFunctions.put(