Skip to content

Commit 80a4a14

Browse files
lberkicopybara-github
authored andcommitted
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
1 parent c9e4446 commit 80a4a14

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ public static RootedPath getRootedPathFromLabel(Label label, Environment env)
308308
protected Map<String, String> declareEnvironmentDependencies(
309309
Map<String, String> markerData, Environment env, Set<String> keys)
310310
throws InterruptedException {
311+
if (keys.isEmpty()) {
312+
return ImmutableMap.of();
313+
}
314+
311315
ImmutableMap<String, String> envDep = getEnvVarValues(env, keys);
312316
if (envDep == null) {
313317
return null;
@@ -349,6 +353,10 @@ public static ImmutableMap<String, String> getEnvVarValues(Environment env, Set<
349353
protected boolean verifyEnvironMarkerData(
350354
Map<String, String> markerData, Environment env, Set<String> keys)
351355
throws InterruptedException {
356+
if (keys.isEmpty()) {
357+
return true;
358+
}
359+
352360
ImmutableMap<String, String> environ = ActionEnvironmentFunction.getEnvironmentView(env, keys);
353361
if (env.valuesMissing()) {
354362
return false; // Returns false so caller knows to return immediately

0 commit comments

Comments
 (0)