Optimizing Bazel Sandboxing with a FUSE File System Overview of Bazel Sandboxing and sandboxfs By Julio Merino (jmmv) for FOSDEM on 2020-02-01 What is Bazel? https:bazel.build What is an Action in Bazel? Action cc -I. -c parser.c -o
"Optimizing Bazel Sandboxing with a FUSE File" is the property of its rightful owner. Permission is granted to
download and print the materials on this website for personal, non-commercial use only, and to display it
on your personal computer provided you do not modify the materials and that you retain all copyright
notices contained in the materials. By downloading content from our website, you accept the terms of this
agreement.
Presentation Transcript
01
Optimizing Bazel Sandboxing with a FUSE File System Overview of Bazel Sandboxing and sandboxfs
By Julio Merino (@jmmv) for FOSDEM on 2020-02-01<br>
02
What is Bazel? https://bazel.build/<br>
03
What is an Action in Bazel? Action
cc -I. -c parser.c -o parser.o Inputs
/usr/bin/cc
./parser.h
./parser.c Outputs
./parser.o Bazel In-Memory Data Structures<br>
04
Why Do We Sandbox Actions? Action
cc -I. -c parser.c -o parser.o Inputs
/usr/bin/cc
./parser.h
./parser.c Outputs
./parser.o Workspace
./lexer.h
./lexer.c
./parser.h
./parser.c Bazel In-Memory Data Structures File System<br>
05
Action Sandboxing: Process Isolation Sandbox Process
clever-cc input.c -o output.o Mock hostname Network input.c /dev/random output.o Real hostname On Linux: user namespaces – On macOS: sandbox-exec
https://blog.bazel.build/2015/09/11/sandboxing.html, https://jmmv.dev/2019/11/macos-sandbox-exec.html<br>
Performance Results (macOS, circa 2018) https://blog.bazel.build/2018/04/13/preliminary-sandboxfs-support.html<br>
13
Performance Results (macOS, circa 2018) https://blog.bazel.build/2018/04/13/preliminary-sandboxfs-support.html<br>
14
Performance Results (macOS, circa 2018) https://blog.bazel.build/2018/04/13/preliminary-sandboxfs-support.html<br>
15
Rewriting sandboxfs from Go to Rust Go
Easy to write (intern project!)
VSCode has great support
Hit scalability problems
Started to become hard to maintain (few annotations in the code) https://jmmv.dev/2018/07/rust-vs-go.html<br>
16
Rewriting sandboxfs from Go to Rust Go
Easy to write (intern project!)
VSCode has great support
Hit scalability problems
Started to become hard to maintain (few annotations in the code) Rust
Harder to write
VSCode has support but is very slow
Much more confident in the code
In translating the old Go code, Rust uncovered many concurrency issues in it https://jmmv.dev/2018/07/rust-vs-go.html<br>
17
Rewriting sandboxfs from Go to Rust Go
Easy to write (intern project!)
VSCode has great support
Hit scalability problems
Started to become hard to maintain (few annotations in the code) Rust
Harder to write
VSCode has support but is very slow
Much more confident in the code
In translating the old Go code, Rust uncovered many concurrency issues in it Commonalities
pprof for finding performance issues
FUSE bindings not first-class https://jmmv.dev/2018/07/rust-vs-go.html<br>
18
Future Work Optimize further
Current Bazel ↔ sandboxfs protocol very inefficient
pkg_comp
Other sandboxing approaches (Microsoft's BuildXL)
But... beware of OSXFUSE and kexts on Mac<br>