Ctrl-C is not very responsive when running many local actions with symlink sandbox
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the bug:
When I run a build that has a lot of local, sandboxed actions and I press Ctrl-C, it take a lot of time (double-digit seconds) for Bazel finish execution.
A lot of thread stacks look like this (obtained by pressing Ctrl-\\):
```
at com.google.devtools.build.lib.unix.NativePosixFiles.symlink(Native Method)
at com.google.devtools.build.lib.unix.UnixFileSystem.createSymbolicLink(UnixFileSystem.java:366)
at com.google.devtools.build.lib.vfs.Path.createSymbolicLink(Path.java:472)
at com.google.devtools.build.lib.sandbox.SymlinkedSandboxedSpawn.copyFile(SymlinkedSandboxedSpawn.java:229)
at com.google.devtools.build.lib.sandbox.AbstractContainerizingSandboxedSpawn.createInputs(AbstractContainerizingSandboxedSpawn.java:138)
at com.google.devtools.build.lib.sandbox.AbstractContainerizingSandboxedSpawn.createFileSystem(AbstractContainerizingSandboxedSpawn.java:117)
at com.google.devtools.build.lib.sandbox.AbstractSandboxSpawnRunner.runSpawn(AbstractSandboxSpawnRunner.java:138)
at com.google.devtools.build.lib.sandbox.AbstractSandboxSpawnRunner.exec(AbstractSandboxSpawnRunner.java:105)
at com.google.devtools.build.lib.sandbox.SandboxModule$SandboxFallbackSpawnRunner.exec(SandboxModule.java:492)
at com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:301)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:152)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:112)
...
```
And a few look like this:
```
at com.google.devtools.build.lib.unix.NativePosixFiles.deleteTreesBelow(Native Method)
at com.google.devtools.build.lib.unix.UnixFileSystem.deleteTreesBelow(UnixFileSystem.java:470)
at com.google.devtools.build.lib.vfs.FileSystem.deleteTree(FileSystem.java:215)
at com.google.devtools.build.lib.vfs.Path.deleteTree(Path.java:596)
at com.google.devtools.build.lib.sandbox.SynchronousTreeDeleter.deleteTree(SynchronousTreeDeleter.java:26)
at com.google.devtools.build.lib.sandbox.AbstractContainerizingSandboxedSpawn.delete(AbstractContainerizingSandboxedSpawn.java:161)
at com.google.devtools.build.lib.sandbox.SymlinkedSandboxedSpawn.delete(SymlinkedSandboxedSpawn.java:235)
at com.google.devtools.build.lib.sandbox.AbstractSandboxSpawnRunner.runSpawn(AbstractSandboxSpawnRunner.java:164)
at com.google.devtools.build.lib.sandbox.AbstractSandboxSpawnRunner.exec(AbstractSandboxSpawnRunner.java:105)
at com.google.devtools.build.lib.sandbox.SandboxModule$SandboxFallbackSpawnRunner.exec(SandboxModule.java:492)
at com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:301)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:152)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:112)
at com.google.devtools.build.lib.actions.SpawnStrategy.beginExecution(SpawnStrategy.java:47
...
```
### Which category does this issue belong to?
Local Execution
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
```
git clone https://pigweed.googlesource.com/pigweed/pigweed
cd pigweed
bazel build //...
```
Then press Ctrl-C while a lot of C++ compilation is happening and observe that it takes a good while for Bazel to stop doing things.
### Which operating system are you running Bazel on?
Linux
### What is the output of `bazel info release`?
Bazel 6.3.2
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?
_No response_
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.