From 3d78808c90efe09ba84f4aeb1e90533fb02fcf19 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 5 Feb 2025 11:49:23 -0500 Subject: [PATCH] Add a disk cache limit of 100G for bazel (#4893) Co-authored-by: Jon Ross-Perkins --- .bazelrc | 7 +++---- scripts/clean_disk_cache.sh | 22 ---------------------- 2 files changed, 3 insertions(+), 26 deletions(-) delete mode 100755 scripts/clean_disk_cache.sh diff --git a/.bazelrc b/.bazelrc index 3648870e5bbb..94d45e91c5e4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -40,11 +40,10 @@ build --use_target_config_carbon_rules # Default to using a disk cache to minimize re-building LLVM and Clang which we # try to avoid updating too frequently to minimize rebuild cost. The location # here can be overridden in the user configuration where needed. -# -# Note that this cache will grow without bound currently. You should -# periodically run the `scripts/clean_disk_cache.sh` script or some equivalent. -# https://github.com/bazelbuild/bazel/issues/5139 tracks fixing this in Bazel. build --disk_cache=~/.cache/carbon-lang-build-cache +# If you'd like a different disk cache size, override it by copying this +# line to `user.bazelrc` in the repository root and modify the number there. +build --experimental_disk_cache_gc_max_size=100G # Enable some safety when using the build cache, likely to be defaulted in # future Bazel releases. diff --git a/scripts/clean_disk_cache.sh b/scripts/clean_disk_cache.sh deleted file mode 100755 index 3bd6ac58748a..000000000000 --- a/scripts/clean_disk_cache.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -# Clean out any files in the Bazel disk cache which haven't been used for over -# thirty days. - -set -eu - -# Default to the same directory in the project `.blazerc`, but you can set this -# environment variable to override that. -: ${BAZEL_DISK_CACHE_PATH:=~/.cache/carbon-lang-build-cache} - -# As a courtesy, compute and print some approximate stats. -total_file_count=$(find "$BAZEL_DISK_CACHE_PATH" -type f | wc -l) -stale_file_count=$(find "$BAZEL_DISK_CACHE_PATH" -type f -atime +30 | wc -l) -echo "Removing $stale_file_count files out of $total_file_count total." - -# Just re-running the find is simpler than managing any state. -find "$BAZEL_DISK_CACHE_PATH" -type f -atime +30 -delete