-
-
Notifications
You must be signed in to change notification settings - Fork 274
Use persistent gradle home between invocations #1473
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
Use persistent gradle home between invocations #1473
Conversation
|
I think we should leave the runfiles alone, but perhaps we can create a temporary cache in a well known location in |
I like that idea, so I'll make that change. |
|
Updated to use a persistent directory under /tmp, which has a hash generated from the repo directory under which bazel is run. |
shs96c
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor nits, but otherwise LGTM. Thank you!
private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/gradle/GradleResolver.java
Outdated
Show resolved
Hide resolved
shs96c
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
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.