From 80a4a1483e38353e9472ed8bfd5261efe1a6e23b Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 17 Jan 2024 11:47:47 -0800 Subject: [PATCH] Do not depend on PRECOMPUTED:repo_env if the repository doesn't depend on any environment variable. 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. PiperOrigin-RevId: 599242763 Change-Id: I895c5793ed06ef2c7a3337ef232ab13a7596b325 --- .../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