diff options
author | Philipp Wollermann <philwo@google.com> | 2018-03-26 09:06:29 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-26 09:08:26 -0700 |
commit | 656a0bab1e025ff3c27d595284a4bf1c5a8d8028 (patch) | |
tree | 2307d1a23794923db1ab44e59f3e600abf380061 /src/main/java/com/google/devtools/build/lib/shell | |
parent | 26e7280deecc11172c1b16637d513c2d0d242c09 (diff) |
Big round of sandbox fixes / performance improvements.
- The number of stat() syscalls in the SymlinkedSandboxedSpawn was way too high. Do less, feel better.
- When using --experimental_sandbox_base, ensure that symlinks in the path are resolved. Before this, you had to check whether on your system /dev/shm is a symlink to /run/shm and then use that instead. Now it no longer matters, as symlinks are resolved.
- Remove an unnecessary directory creation from each sandboxed invocation. Turns out that the "tmpdir" that we created was no longer used after some changes to Bazel's TMPDIR handling.
- Use simpler sandbox paths, by using the unique ID for each Spawn provided by SpawnExecutionPolicy instead of a randomly generated temp folder name. This also saves a round-trip from our VFS to NIO and back. Clean up the sandbox base before each build to ensure that the unique IDs are actually unique. ;)
- Use Java 8's Process#isAlive to check whether a process is alive instead of trying to get the exitcode and catching an exception.
Closes #4913.
PiperOrigin-RevId: 190472170
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/shell')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java index 7647d17dd3..bfc867d991 100644 --- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java +++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java @@ -54,20 +54,15 @@ public class JavaSubprocessFactory implements SubprocessFactory { @Override public boolean finished() { - try { - if (deadlineMillis > 0 - && System.currentTimeMillis() > deadlineMillis - && deadlineExceeded.compareAndSet(false, true)) { - // We use compareAndSet here to avoid calling destroy multiple times. Note that destroy - // returns immediately, and we don't want to wait in this method. - process.destroy(); - } - // this seems to be the only non-blocking call for checking liveness - process.exitValue(); - return true; - } catch (IllegalThreadStateException e) { - return false; + if (deadlineMillis > 0 + && System.currentTimeMillis() > deadlineMillis + && deadlineExceeded.compareAndSet(false, true)) { + // We use compareAndSet here to avoid calling destroy multiple times. Note that destroy + // returns immediately, and we don't want to wait in this method. + process.destroy(); } + // this seems to be the only non-blocking call for checking liveness + return !process.isAlive(); } @Override |