From 269c70bb63bce060ff2daac7dee1ff5e124eab58 Mon Sep 17 00:00:00 2001 From: "bazel.build machine account" <15028808+bazel-io@users.noreply.github.com> Date: Fri, 19 Jan 2024 17:35:40 +0100 Subject: [PATCH] [7.1.0] Cherry-pick the change to reduce repository invalidations to Bazel 7.1 (#20949) HEAD is wasteful because sometimes just checking the up-to-dateness of fetched repositories takes a lot of time (if there is a lot of hashing to be done), so it's better to get a Skyframe cache hit if at all possible. This is not the full answer because repositories that depend only on unchanged environment variables will still need to be re-checked if there is an environment variable that does change, but it's still a step forward. RELNOTES: None. Commit https://github.com/bazelbuild/bazel/commit/80a4a1483e38353e9472ed8bfd5261efe1a6e23b PiperOrigin-RevId: 599242763 Change-Id: I895c5793ed06ef2c7a3337ef232ab13a7596b325 Co-authored-by: Googler --- .../build/lib/rules/repository/RepositoryFunction.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java index 06288b6206805a..c5ab58ca1a7c09 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java @@ -308,6 +308,10 @@ public static RootedPath getRootedPathFromLabel(Label label, Environment env) protected Map declareEnvironmentDependencies( Map markerData, Environment env, Set keys) throws InterruptedException { + if (keys.isEmpty()) { + return ImmutableMap.of(); + } + ImmutableMap envDep = getEnvVarValues(env, keys); if (envDep == null) { return null; @@ -349,6 +353,10 @@ public static ImmutableMap getEnvVarValues(Environment env, Set< protected boolean verifyEnvironMarkerData( Map markerData, Environment env, Set keys) throws InterruptedException { + if (keys.isEmpty()) { + return true; + } + ImmutableMap environ = ActionEnvironmentFunction.getEnvironmentView(env, keys); if (env.valuesMissing()) { return false; // Returns false so caller knows to return immediately