Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weakly cache runfiles mappings of tools #23774

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,17 @@ public String getWorkspaceName() {
private final CommandLine args;
private final ActionEnvironment actionEnvironment;

// Only cache runfiles if there is more than one test runner action. Otherwise, there is no chance
// for reusing the runfiles within a single build, so don't pay the overhead of a weak reference.
// Only cache mappings if there is a chance that more than one action will use it within a single
// build. This helps reduce peak memory usage, especially when the value of --jobs is high, but
// avoids the additional overhead of a weak reference when it is not needed.
private static boolean cacheRunfilesMappings(RuleContext ruleContext) {
if (!TargetUtils.isTestRule(ruleContext.getTarget())) {
return false;
// Runfiles trees of non-test rules are tools and can thus be used by multiple actions.
return true;
}

// Test runfiles are only used by a single test runner action unless there are multiple runs or
// shards.
if (TestActionBuilder.getRunsPerTest(ruleContext) > 1) {
return true;
}
Expand Down
Loading