Use persistent gradle home between invocations#1473
Merged
shs96c merged 5 commits intoNov 23, 2025
Merged
Conversation
Collaborator
|
I think we should leave the runfiles alone, but perhaps we can create a temporary cache in a well known location in |
Contributor
Author
I like that idea, so I'll make that change. |
Contributor
Author
|
Updated to use a persistent directory under /tmp, which has a hash generated from the repo directory under which bazel is run. |
shs96c
requested changes
Nov 19, 2025
Collaborator
shs96c
left a comment
There was a problem hiding this comment.
Two minor nits, but otherwise LGTM. Thank you!
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.
By default, we create a isolated temp dir for each run of lockfile pinning for the gradle resolver for
gradle.home. This means a ton of stuff is redundantly downloaded and is slow on incremental runs too without usingRJE_UNSAFE_CACHE.For the coursier resolver, we seem to be using a directory under
external/by default https://github.com/bazel-contrib/rules_jvm_external/blob/master/private/rules/coursier.bzl#L801 so incremental runs are pretty fast.Instead we could use a directory within the runfiles of this binary so that we still keep some level of hermeticity by having this isolated but continue to leverage it on incremental runs (reuse the gradle daemon and the caches). We can chose a unique directory under/tmpthat's persistent between invocations by hashing the workspace root from where thebazel runcommand runs and use that in the generated directory names. Doing this delivers a pretty significant performance benefit on the second and further runs. Note that temp directories are wiped out between restarts on mac, but this should provide a health improvement.Before (2nd run), about ~2 min
After (2nd run and every run after until
bazel cleanis run), ~30 secondsThe gradle home will be in a directory like this
Additonally this speedens the up the unit tests significantly because the gradle daemon is re-used between tests.
Before
Now
I realize this could be controversial perhaps, so opening it in draft for comment.
Note that
RJE_UNSAFE_CACHEwill still be respected and it will use the gradle cache underuser.home.