Bazel cache analysis - magma/magma GitHub Wiki
Bazel cache analysis
Bazel uses remote and disk caches. In case you have to debug something cache related or want to monitor cache usage for different artifacts, then the easiest way to do is with BuildBuddy. It is free and can be used without creating an account.
Setup
Getting BuildBuddy flags
- Go to BuildBuddy
- "Get started for free"
- "Use BuildBuddy without an account"
- "Enable cache" -> "Full cache"
- Copy the provided build flags to your
.bazelrc
The result should look similar to this:
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://remote.buildbuddy.io
build --remote_cache=grpcs://remote.buildbuddy.io
build --remote_timeout=3600
Removing other cache options
The .bazelrc
should already contain some cache related setup. These should be removed so that it does not collide with what you just pasted there. Comment out any lines which start with one of the followings:
- build:disk_cache
- common:disk_cache
- build:remote_caching_ro
- build:remote_download_optimization
- run:remote_download_optimization
- import %workspace%/bazel/bazelrcs/cache.bazelrc
Remove any bazel caches from your system
cd $MAGMA_ROOT
bazel clean --expunge
rm -rf .bazel-cache*
git restore .bazel-cache-repo/.gitignore .bazel-cache/.gitignore
Using BuildBuddy
After the setup is done, you can execute a bazel build and it will use BuildBuddy as remote cache.
bazel build //lte/gateway/python/magma/monitord
The first build will fill up the caches and every subsequent build will read from these caches. Among the first few lines from the build there will be a line similar to this one:
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/43d5d90e-9bbd-48e7-81d1-e08d77718d7d
You can follow the link and there you can find a lot of useful data about your build, for example how much cache and data was used.