tests with sysroot

This commit is contained in:
Motiejus Jakštys 2022-12-11 15:55:21 +02:00
parent 68f1293511
commit a6083e555c
2 changed files with 50 additions and 16 deletions

View File

@ -28,30 +28,35 @@ bazel --batch clean; bazel --batch build --spawn_strategy=local --platforms=@zi
INFO: Elapsed time: 17.021s, Critical Path: 1.67s
```
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 --batch 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 plain: 142 seconds. Sandbox is on a real disk, which means it will take
zig cc plain: 61 seconds. Sandbox is on a real disk, which means it will take
even longer to re-hash all its dependencies:
```
bazel --batch clean; bazel --batch build --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
INFO: Elapsed time: 142.264s, Critical Path: 20.65s
INFO: Elapsed time: 61.128s, Critical Path: 8.35s
```
Similar to `--config=hermetic-sandbox`. Which means there is something else at
play, not only re-hashing the sandbox files:
zig cc with hardlinks: `--config=hermetic-sandbox`. This uses hardlinks to
zig_sdk instead of symlinks:
```
bazel --batch clean; bazel --batch build --config=hermetic-sandbox --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28 ...
INFO: Elapsed time: 136.957s, Critical Path: 18.14s
INFO: Elapsed time: 45.886s, Critical Path: 9.56s
```
llvm with sysroot (this sysroot is about half the size of zig):
```
bazel --batch clean; bazel --batch build --config=hermetic-sandbox --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux ...
INFO: Elapsed time: 25.644s, Critical Path: 3.03s
```
Flame graphs and discussion
---------------------------
Flame graphs are in results/. As of 2022-12-11 most of the overhead comes from
creating and deleting the sandboxes. Time for a new sandboxfs!
[1]: https://sr.ht/~motiejus/bazel-zig-cc
[2]: https://github.com/grailbio/bazel-toolchain

View File

@ -19,12 +19,41 @@ bazel_toolchain_dependencies()
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
LLVM_VERSION = "14.0.0"
llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "14.0.0",
llvm_version = LLVM_VERSION,
)
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
# This sysroot is used by github.com/vsco/bazel-toolchains.
http_archive(
name = "org_chromium_sysroot_linux_x64",
build_file_content = """
filegroup(
name = "sysroot",
srcs = glob(["*/**"]),
visibility = ["//visibility:public"],
)
""",
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3",
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"],
)
llvm_toolchain(
name = "llvm_toolchain_with_sysroot",
llvm_version = LLVM_VERSION,
sysroot = {
"linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot",
},
# We can share the downloaded LLVM distribution with the first configuration.
toolchain_roots = {
"": "@llvm_toolchain_llvm//",
},
)
load("@llvm_toolchain_with_sysroot//:toolchains.bzl", "llvm_register_toolchains")
#llvm_register_toolchains()