use bazel build --batch
This commit is contained in:
parent
89d1a4546f
commit
9015cd7dc4
@ -14,13 +14,13 @@ tasks:
|
||||
sudo apt-get purge gcc -y && sudo apt-get autoremove -y
|
||||
- llvm14: |
|
||||
cd test-zigcc; . .envrc
|
||||
bazel clean; bazel shutdown; bazel build --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux ...
|
||||
bazel clean; bazel --batch build --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux ...
|
||||
- zig_cc-no_sandbox: |
|
||||
cd test-zigcc; . .envrc
|
||||
bazel clean; bazel shutdown; bazel build --spawn_strategy=local --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
bazel clean; bazel --batch build --spawn_strategy=local --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
- zig_cc-devshm: |
|
||||
cd test-zigcc; . .envrc
|
||||
bazel clean; bazel shutdown; bazel build --sandbox_base=/dev/shm --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
bazel clean; bazel --batch build --sandbox_base=/dev/shm --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
- zig_cc-plain: |
|
||||
cd test-zigcc; . .envrc
|
||||
bazel clean; bazel shutdown; bazel build --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
bazel clean; bazel --batch build --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
|
33
README.md
33
README.md
@ -4,33 +4,46 @@ bazel-zig-cc and llvm
|
||||
bazel-zig-cc has a performance issue when compiling many files. This repository
|
||||
reproduces that.
|
||||
|
||||
The test
|
||||
--------
|
||||
|
||||
Compiles 64 small binaries with [bazel-zig-cc][1] and [llvm14][2]. The tests
|
||||
were run on an x86_64 8-core machine running Ubuntu 22.04.
|
||||
|
||||
Steps to reproduce
|
||||
------------------
|
||||
|
||||
llvm14: 12-13 seconds to compile 64 binaries on an 8-core machine:
|
||||
Baseline is llvm14: 12-13 seconds:
|
||||
|
||||
```
|
||||
$ bazel clean; bazel shutdown; bazel build --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux ...
|
||||
$ bazel clean; bazel --batch build --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux ...
|
||||
INFO: Elapsed time: 12.454s, Critical Path: 1.11s
|
||||
```
|
||||
|
||||
zig cc: 142 seconds:
|
||||
zig cc without the sandbox. Which means different invocations of `zig cc` will
|
||||
see that all files in `zig_lib_dir` are the same file. 17 seconds:
|
||||
|
||||
```
|
||||
$ bazel clean; bazel shutdown; bazel build --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
INFO: Elapsed time: 142.264s, Critical Path: 20.65s
|
||||
bazel clean; bazel --batch build --spawn_strategy=local --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
INFO: Elapsed time: 17.021s, Critical Path: 1.67s
|
||||
```
|
||||
|
||||
zig cc with `--sandbox_base=/dev/shm`: 40 seconds:
|
||||
zig cc with `--sandbox_base=/dev/shm`: all sandbox files, including the
|
||||
zig_sdk, are put to `/dev/shm`. However, they are all symlinks, which means zig
|
||||
will re-hash all it's dependencies. 42 seconds:
|
||||
|
||||
```
|
||||
bazel clean; bazel shutdown; bazel build --sandbox_base=/dev/shm --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
bazel clean; bazel --batch build --sandbox_base=/dev/shm --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
INFO: Elapsed time: 42.251s, Critical Path: 5.26s
|
||||
```
|
||||
|
||||
zig cc without the sandbox (which means zig will treat its dependencies as the same file): 17 seconds:
|
||||
zig cc plain: 142 seconds. Sandbox is on a real disk, which means it will take
|
||||
even longer to re-hash all its dependencies:
|
||||
|
||||
```
|
||||
bazel clean; bazel shutdown; bazel build --spawn_strategy=local --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
INFO: Elapsed time: 17.021s, Critical Path: 1.67s
|
||||
$ bazel clean; bazel --batch build --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
|
||||
INFO: Elapsed time: 142.264s, Critical Path: 20.65s
|
||||
```
|
||||
|
||||
[1]: https://sr.ht/~motiejus/bazel-zig-cc
|
||||
[2]: https://github.com/grailbio/bazel-toolchain
|
||||
|
Loading…
Reference in New Issue
Block a user