Repository navigation
Conversation
When a repo is injected from the remote repo contents cache, `.bzl` and `REPO.bazel` files are prefetched to the native file system and all reads of such paths are redirected there. Symlinks are only injected into the in-memory overlay, so a symlinked `.bzl` file is served through its target, which bazelbuild#30031 achieved by resolving symbolic links before the redirect. That only works if the target's own name happens to make it eligible for prefetching. A symlink `helper.bzl -> helper.txt` resolves to a path that isn't prefetched and thus falls back to a lazy blob download during loading, which is exactly the sequential round-trip the prefetching is meant to avoid. Collect symlinks whose name makes them eligible during injection and, once the repo has been injected in full and their targets can be resolved, add those targets to the set of files to prefetch. The read side now considers the path before symlink resolution as well, so that the prefetched target is used no matter which end of the chain is named like a loaded file.
Collaborator
Author
|
@bazel-io fork 9.3.0 |
fmeum
marked this pull request as ready for review
July 29, 2026 12:24
fmeum
requested review from
coeuvre
and removed request for
a team,
Wyverald and
meteorcloudy
July 29, 2026 12:24
coeuvre
approved these changes
Jul 29, 2026
Contributor
|
@fmeum Could you please resolve the merge conflict? Thanks! |
…nk-targets % Conflicts: % src/main/java/com/google/devtools/build/lib/remote/RemoteExternalOverlayFileSystem.java
Collaborator
Author
|
@iancha1992 done |
iancha1992
added a commit
to iancha1992/bazel
that referenced
this pull request
Aug 4, 2026
…d#30517) ### Description When a repo is injected from the remote repo contents cache, `.bzl` and `REPO.bazel` files are prefetched to the native file system and reads of such paths are redirected there. Symlinks are only injected into the in-memory overlay, so bazelbuild#30031 made the read side resolve symbolic links first, which serves a symlinked `.bzl` file from the regular file it points at. That only helps if the target's own name happens to make it eligible for prefetching, e.g. `helper.bzl -> real_helper.bzl`. A symlink such as `helper.bzl -> real_helper.txt` resolves to a path that was never prefetched and thus falls back to a lazy blob download while the package that loads it is being evaluated. This PR collects symlinks whose name makes them eligible for prefetching during injection and, once the repo has been injected in full and their targets can be resolved, adds those targets to the set of files to prefetch. The read side now also considers the path before symlink resolution, so the prefetched target is used no matter which end of the chain is named like a loaded file. ### Motivation Loading a `.bzl` file that is a symlink to a differently named file costs a sequential round-trip to the remote cache in the middle of the loading phase, which is exactly what prefetching `.bzl` files during injection is meant to avoid: the loads between `.bzl` files form a DAG that can only be discovered layer by layer, so each such read serializes with the next. Follow-up to bazelbuild#30031. ### Build API Changes No ### Checklist - [x] I have added tests for the new use cases (if any). - [ ] I have updated the documentation (if applicable). ### Release Notes RELNOTES: None Closes bazelbuild#30517. PiperOrigin-RevId: 958506915 Change-Id: Ic9e740883683a626aebc17d5686f7c3e3426878c
1 of 2 tasks
fmeum
pushed a commit
to fmeum/bazel
that referenced
this pull request
Aug 25, 2026
…d#30517) ### Description When a repo is injected from the remote repo contents cache, `.bzl` and `REPO.bazel` files are prefetched to the native file system and reads of such paths are redirected there. Symlinks are only injected into the in-memory overlay, so bazelbuild#30031 made the read side resolve symbolic links first, which serves a symlinked `.bzl` file from the regular file it points at. That only helps if the target's own name happens to make it eligible for prefetching, e.g. `helper.bzl -> real_helper.bzl`. A symlink such as `helper.bzl -> real_helper.txt` resolves to a path that was never prefetched and thus falls back to a lazy blob download while the package that loads it is being evaluated. This PR collects symlinks whose name makes them eligible for prefetching during injection and, once the repo has been injected in full and their targets can be resolved, adds those targets to the set of files to prefetch. The read side now also considers the path before symlink resolution, so the prefetched target is used no matter which end of the chain is named like a loaded file. ### Motivation Loading a `.bzl` file that is a symlink to a differently named file costs a sequential round-trip to the remote cache in the middle of the loading phase, which is exactly what prefetching `.bzl` files during injection is meant to avoid: the loads between `.bzl` files form a DAG that can only be discovered layer by layer, so each such read serializes with the next. Follow-up to bazelbuild#30031. ### Build API Changes No ### Checklist - [x] I have added tests for the new use cases (if any). - [ ] I have updated the documentation (if applicable). ### Release Notes RELNOTES: None Closes bazelbuild#30517. PiperOrigin-RevId: 958506915 Change-Id: Ic9e740883683a626aebc17d5686f7c3e3426878c (cherry picked from commit 61574a9)
bazel-io
pushed a commit
to bazel-io/bazel
that referenced
this pull request
Sep 2, 2026
…azelbuild#30713) ### Description When a repo is injected from the remote repo contents cache, `.bzl` and `REPO.bazel` files are prefetched to the native file system and reads of such paths are redirected there. Symlinks are only injected into the in-memory overlay, so bazelbuild#30031 made the read side resolve symbolic links first, which serves a symlinked `.bzl` file from the regular file it points at. That only helps if the target's own name happens to make it eligible for prefetching, e.g. `helper.bzl -> real_helper.bzl`. A symlink such as `helper.bzl -> real_helper.txt` resolves to a path that was never prefetched and thus falls back to a lazy blob download while the package that loads it is being evaluated. This PR collects symlinks whose name makes them eligible for prefetching during injection and, once the repo has been injected in full and their targets can be resolved, adds those targets to the set of files to prefetch. The read side now also considers the path before symlink resolution, so the prefetched target is used no matter which end of the chain is named like a loaded file. ### Motivation Loading a `.bzl` file that is a symlink to a differently named file costs a sequential round-trip to the remote cache in the middle of the loading phase, which is exactly what prefetching `.bzl` files during injection is meant to avoid: the loads between `.bzl` files form a DAG that can only be discovered layer by layer, so each such read serializes with the next. Follow-up to bazelbuild#30031. ### Build API Changes No ### Checklist - [x] I have added tests for the new use cases (if any). - [ ] I have updated the documentation (if applicable). ### Release Notes RELNOTES: None Closes bazelbuild#30517. PiperOrigin-RevId: 958506915 Change-Id: Ic9e740883683a626aebc17d5686f7c3e3426878c (cherry picked from commit 61574a9) This PR also carries the prerequisite commit bazelbuild@c37a6a1 ("Improve path validation in remote repository contents cache."), which touches the same injection code path and landed on master first. Replaces bazelbuild#30579, which bundles the same two commits but does not build on this branch: it hand-authors a new `remote_external_overlay_file_system` target in `src/main/java/com/google/devtools/build/lib/remote/BUILD` that depends on `//src/main/proto:failure_details_java_proto` (the branch uses `//src/main/protobuf`), so the target does not even analyze, and its test uses `EventBusEventHandler`, which does not exist on this branch. 9.3.0 adaptation: The `src/main/java/com/google/devtools/build/lib/remote/BUILD` split is not needed because that package still has a single monolithic `remote` target here, which already covers `RemoteExternalOverlayFileSystem.java`; the same goes for the `remote_external_overlay_file_system` entry in `src/test/java/com/google/devtools/build/lib/remote/BUILD`, where only the new `//src/main/java/com/google/devtools/build/lib/cmdline` dep is required. The new test constructs the `Reporter` as `new Reporter(new EventBus())` since `EventBusEventHandler` was introduced by a master-only refactoring. Closes bazelbuild#30520 --------- Co-authored-by: twerth <[email protected]> Co-authored-by: Ian (Hee) Cha <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a repo is injected from the remote repo contents cache,
.bzlandREPO.bazelfiles are prefetched to the native file system and reads of such paths are redirected there. Symlinks are only injected into the in-memory overlay, so #30031 made the read side resolve symbolic links first, which serves a symlinked.bzlfile from the regular file it points at.That only helps if the target's own name happens to make it eligible for prefetching, e.g.
helper.bzl -> real_helper.bzl. A symlink such ashelper.bzl -> real_helper.txtresolves to a path that was never prefetched and thus falls back to a lazy blob download while the package that loads it is being evaluated.This PR collects symlinks whose name makes them eligible for prefetching during injection and, once the repo has been injected in full and their targets can be resolved, adds those targets to the set of files to prefetch. The read side now also considers the path before symlink resolution, so the prefetched target is used no matter which end of the chain is named like a loaded file.
Motivation
Loading a
.bzlfile that is a symlink to a differently named file costs a sequential round-trip to the remote cache in the middle of the loading phase, which is exactly what prefetching.bzlfiles during injection is meant to avoid: the loads between.bzlfiles form a DAG that can only be discovered layer by layer, so each such read serializes with the next.Follow-up to #30031.
Build API Changes
No
Checklist
Release Notes
RELNOTES: None