diff options
author | 2017-12-21 10:35:08 -0800 | |
---|---|---|
committer | 2017-12-21 10:36:34 -0800 | |
commit | 62dfea75efc831b153306985241d24ee7deb5bc5 (patch) | |
tree | 9b40b77e3a9d133eed09855fe6b54e93eab4d459 /src/main/java/com/google/devtools/build/lib/sandbox | |
parent | b30b9335ab185837e03527b4bf9c3c40b41db767 (diff) |
Remove cached version of FileSystemUtils#createDirectoryAndParents.
Only the sandbox uses the cached version. We can let it do its own caching of the top-level directory. It won't help with higher-level directories, but if there are a lot of inputs in the same directory we'll avoid I/O there.
PiperOrigin-RevId: 179830651
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java b/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java index 0beed3f0fa..80db422dbf 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java @@ -78,7 +78,7 @@ public class SymlinkedSandboxedSpawn implements SandboxedSpawn { public void createFileSystem() throws IOException { Set<Path> createdDirs = new HashSet<>(); cleanFileSystem(inputs.keySet()); - FileSystemUtils.createDirectoryAndParentsWithCache(createdDirs, sandboxExecRoot); + createDirectoryAndParentsWithCache(createdDirs, sandboxExecRoot); createParentDirectoriesForInputs(createdDirs, inputs.keySet()); createInputs(inputs); createWritableDirectories(createdDirs, writableDirs); @@ -126,7 +126,7 @@ public class SymlinkedSandboxedSpawn implements SandboxedSpawn { Path dir = sandboxExecRoot.getRelative(inputPath).getParentDirectory(); Preconditions.checkArgument( dir.startsWith(sandboxExecRoot), "Bad relative path: '%s'", inputPath); - FileSystemUtils.createDirectoryAndParentsWithCache(createdDirs, dir); + createDirectoryAndParentsWithCache(createdDirs, dir); } } @@ -156,7 +156,7 @@ public class SymlinkedSandboxedSpawn implements SandboxedSpawn { throws IOException { for (Path writablePath : writableDirs) { if (writablePath.startsWith(sandboxExecRoot)) { - FileSystemUtils.createDirectoryAndParentsWithCache(createdDirs, writablePath); + createDirectoryAndParentsWithCache(createdDirs, writablePath); } } } @@ -165,7 +165,7 @@ public class SymlinkedSandboxedSpawn implements SandboxedSpawn { private void createDirectoriesForOutputs(Set<Path> createdDirs, Collection<PathFragment> outputs) throws IOException { for (PathFragment output : outputs) { - FileSystemUtils.createDirectoryAndParentsWithCache( + createDirectoryAndParentsWithCache( createdDirs, sandboxExecRoot.getRelative(output.getParentDirectory())); } } @@ -208,4 +208,11 @@ public class SymlinkedSandboxedSpawn implements SandboxedSpawn { // on here. } } + + private static void createDirectoryAndParentsWithCache(Set<Path> cache, Path dir) + throws IOException { + if (cache.add(dir)) { + FileSystemUtils.createDirectoryAndParents(dir); + } + } } |