Speed up your Bazel builds with Namespace - Namespace Documentation

Getting Started

Configure access

Generate a bazelrc that points Bazel at Namespace. Start with the cache, and add remote execution when you want the actions to run on Namespace compute too.

nsc bazel setup --remote=false --bazelrc=~/.namespace.bazelrc

This command provisions a remote Bazel cache, if needed, and writes a bazelrc with the relevant configuration options.

nsc bazel setup --bazelrc=~/.namespace.bazelrc

This command provisions the execution cluster if needed, and writes a bazelrc with the remote executor, remote cache, and credentials.

Run Bazel

bazel --bazelrc=~/.namespace.bazelrc build //...

You can pass multiple --bazelrc flags if you need to combine Namespace’s generated configuration with your existing project configuration. Bazel reads the files in the order it is given them, and where two files set the same option, the last one read wins. See bazelrc files for the full order, which also covers the workspace and home rc files Bazel picks up on its own.

Caching and Remote Execution

The Bazel cache shares action results across invocations and machines. It applies to any action Bazel can cache, and the saving is largest where compilation is slow, such as Rust and C++ codebases. The cache is shared, so CI and local builds reuse each other’s results. Remote Execution runs the actions themselves on Namespace compute, scaling a build across many workers for high parallelism. Its workers keep low-latency access to the cache, so remotely executed actions read and write the same artifacts as everything else. Actions can also be routed to workers on a different platform than the machine running Bazel, which is how a Linux host can drive a macOS build.

Common setups

Bazel cache from GitHub Actions
Turn on Bazel caching in your Namespace runner profile. Your workflow needs no changes.

Cross-platform builds
Drive a macOS or iOS build from a Linux host by routing actions to macOS workers.

GitHub Actions on GitHub-hosted runners
Reach the Namespace cache from GitHub’s own runners, to try it before moving your runners.

Bazel from a Devbox
Enable Bazel caching when creating a Devbox, and builds use it with no further setup.