Skip to content

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Aug 30, 2025

RELNOTES[NEW]: The results of reproducible repository rules without dependencies added at runtime (e.g., via repository_ctx.watch or .getenv) can now be cached in a regular HTTP or gRPC remote cache if the new --experimental_remote_repo_contents_cache startup option is provided.

The output of du -h $(bazel info output_base) after bazel build //src:bazel-dev and a fully up-to-date remote cache

  • without the flag:
$ bazel info peak-heap-size used-heap-size-after-gc
peak-heap-size: 271MB
used-heap-size-after-gc: 123MB
$ du -h $(bazel info output_base) | tail -1
1.3G	/private/var/tmp/_bazel_fmeum/507738cfc7e6cde00e4a0230e9aa0722
  • with the flag:
$ bazel info peak-heap-size used-heap-size-after-gc
peak-heap-size: 266MB
used-heap-size-after-gc: 120MB
$ du -h $(bazel info output_base) | tail -1
380M	/private/var/tmp/_bazel_fmeum/507738cfc7e6cde00e4a0230e9aa0722

Some repos are still materialized eagerly, which may not be necessary. Patched http_archive also can't be cached yet, so these numbers are likely to improve with further work on this feature.

TODO:

Fixes #6359

@fmeum fmeum force-pushed the 6359-remote-repo-contents-cache branch 2 times, most recently from bb85d69 to 17ed3a6 Compare September 1, 2025 13:53
Comment on lines 199 to 205
public FileSystem getFileSystemForBuildArtifacts(FileSystem nativeFs) {
if (!useRemoteRepoContentsCache) {
return null;
}
return new RemoteOverlayFileSystem(
outputBase.getRelative(LabelConstants.EXTERNAL_REPOSITORY_LOCATION), nativeFs);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this feels very "heavy-handed", especially after reading the fsForPath below.

What if we first refactor BlazeRuntime to add a dedicated "external repo" entry to ServerDirectories, then make it configurable 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been there, but I couldn't get it to work. The problem is that lots of SkyValues have Paths in their corresponding SkyKeys, which means that there needs to be a singleton file system used everywhere for the lifetime of the server. Otherwise you would need to keep some other global object around that knows how to map a logical path to the correct file system for the respective key and add special handling for each file operation that may cross file system boundaries. Pretty much like fsForPath, but not just in a single location.

@fmeum fmeum force-pushed the 6359-remote-repo-contents-cache branch 3 times, most recently from b79c111 to 17af177 Compare September 2, 2025 17:45
@fmeum fmeum changed the title Add an experimental remote repo contents cache Add a remote repo contents cache Sep 3, 2025
@fmeum fmeum force-pushed the 6359-remote-repo-contents-cache branch 5 times, most recently from ad8c6ba to 5b3c3d0 Compare September 4, 2025 14:32
@fmeum fmeum force-pushed the 6359-remote-repo-contents-cache branch from 5b3c3d0 to 1ba11a0 Compare September 4, 2025 14:42
@fmeum fmeum marked this pull request as ready for review September 6, 2025 19:30
@fmeum fmeum requested review from a team, Wyverald and meteorcloudy as code owners September 6, 2025 19:30
@fmeum fmeum requested review from gregestren and removed request for a team September 6, 2025 19:30
@github-actions github-actions bot added team-Performance Issues for Performance teams team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Rules-CPP Issues for C++ rules team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Performance Issues for Performance teams team-Remote-Exec Issues and PRs for the Execution (Remote) team team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow using remote cache for repository cache
2 participants