Repository navigation
[9.3.0] Prefetch the targets of symlinked .bzl files in the RRCC - #30713
Merged
Merged
Conversation
fmeum
marked this pull request as ready for review
August 13, 2026 16:02
Collaborator
Author
|
@iancha1992 This replaces #30579 |
iancha1992
enabled auto-merge
August 13, 2026 21:33
Contributor
|
@fmeum Could you please resolve the merge conflicts? Thanks! |
Validate node names in remote tree to ensure they don't contain separators, uplevel references, or absolute paths. Ensure injected paths and symlink targets remain within the repository directory. PiperOrigin-RevId: 956519847 Change-Id: I0a2a91dd827be37fff78146637c7e55dc9c876df (cherry picked from commit c37a6a1)
…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)
auto-merge was automatically disabled
August 25, 2026 12:43
Head branch was pushed to by a user without write access
Collaborator
Author
|
@iancha1992 Resolved |
iancha1992
enabled auto-merge
August 25, 2026 18:34
Contributor
|
@fmeum Could you please resolve the merge conflict? Thanks! |
auto-merge was automatically disabled
September 1, 2026 19:28
Head branch was pushed to by a user without write access
Collaborator
Author
|
@iancha1992 done |
iancha1992
enabled auto-merge
September 1, 2026 21:58
meteorcloudy
approved these changes
Sep 2, 2026
iancha1992
added this pull request to the merge queue
Sep 2, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Sep 2, 2026
iancha1992
added this pull request to the merge queue
Sep 2, 2026
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
Closes #30517.
PiperOrigin-RevId: 958506915
Change-Id: Ic9e740883683a626aebc17d5686f7c3e3426878c
(cherry picked from commit 61574a9)
This PR also carries the prerequisite commit c37a6a1 ("Improve path validation in remote repository contents cache."), which touches the same injection code path and landed on master first.
Replaces #30579, which bundles the same two commits but does not build on this branch: it hand-authors a new
remote_external_overlay_file_systemtarget insrc/main/java/com/google/devtools/build/lib/remote/BUILDthat 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 usesEventBusEventHandler, which does not exist on this branch.9.3.0 adaptation: The
src/main/java/com/google/devtools/build/lib/remote/BUILDsplit is not needed because that package still has a single monolithicremotetarget here, which already coversRemoteExternalOverlayFileSystem.java; the same goes for theremote_external_overlay_file_systementry insrc/test/java/com/google/devtools/build/lib/remote/BUILD, where only the new//src/main/java/com/google/devtools/build/lib/cmdlinedep is required. The new test constructs theReporterasnew Reporter(new EventBus())sinceEventBusEventHandlerwas introduced by a master-only refactoring.Closes #30520