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

SOLR-15603: Activate Gradle build cache #277

Merged
merged 4 commits into from Sep 6, 2021

Conversation

alextu
Copy link
Contributor

@alextu alextu commented Aug 30, 2021

https://issues.apache.org/jira/browse/SOLR-15603

Description

Activate gradle local build cache to take advantage of re-using past build executions on a single machine, it improves build time when switching between branches for example.

Solution

Set the gradle build cache flag, upgrade gradle to 6.9.1, upgrade a 3rd party plugin and make some tasks cacheable when easily doable. More context below:

  • the most costly task is solr:core:test, it takes advantage of up-to-date checks and local cache if the tests.seedproperty is set to a fixed value. That said it does not take advantage of remote cache because some system properties use absolute path.
    Using a remote cache would be interesting since you have a CI that could publish to a remote cache node, remote developpers would then have faster local builds.
  • checkBrokenLinks, renderJavadoc, renderSiteJavadoc, buildLocalJavadocLinksSite, buildSite, prepareLocalJavadocLinksSiteSources, prepareSiteSources tasks are now cacheable, but still :solr:solr-ref-guide:jrubyPrepare is always executed and quite heavy (dowloading/installing gems).

Tests

Manually checked the build performance improvement:

./gradlew clean check -Ptests.seed=DEADBEE
BUILD SUCCESSFUL in 27m 26s
409 actionable tasks: 351 executed, 13 from cache, 45 up-to-date
./gradlew clean check -Ptests.seed=DEADBEE
BUILD SUCCESSFUL in 45s
409 actionable tasks: 260 executed, 99 from cache, 50 up-to-date

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

build.gradle Outdated
@@ -20,7 +20,7 @@ import java.time.format.DateTimeFormatter

plugins {
id "base"
id "com.palantir.consistent-versions" version "1.14.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a patch upgrading this plugin (and all of gradle infrastructure) here - #275. It'll conflict with your PR, once applied. I'll cherry pick relevant areas if you don't want to spend any more time on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho, I missed this effort upgrading to 7.x, good stuff ! I can wait for your branch to be merged and I'll fix my branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to merge tomorrow, sorry for not mentioning this earlier.

@@ -42,6 +42,7 @@ configure(rootProject) {
"systemProp.file.encoding=UTF-8",
"org.gradle.jvmargs=-Xmx3g", // TODO figure out why "gradlew check" runs out of memory if 2g
"org.gradle.parallel=true",
"org.gradle.caching=true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables local caches, right? I'm not sure folks will be enthusiastic about their home folders increasing in size so dramatically - solr build outputs are pretty heavy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so if you're afraid of this, I can remove this setting and you can enable it through the command line when building, check after a few weeks of dev if it's acceptable. It's hard to predict the size, currently I see on my machine it's about 400Mb (after removing the cache directory and running a few solr builds)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be left commented out in the generated user defaults - let it be an opt-in. I plan to commit gradle 7.2 path tomorrow and reiterate on your patch, cherry picking the obvious parts of it. Stay tuned. :)

@@ -40,11 +41,13 @@ class CheckBrokenLinksTask extends DefaultTask {
@InputFile
File script = project.rootProject.file("dev-tools/scripts/checkJavadocLinks.py")

@OutputFile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this is good, thanks.

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this alone won't work - requires a new checksum too (dont in that other PR).

solr/solr-ref-guide/build.gradle Show resolved Hide resolved
abstract class PrepareSources extends DefaultTask {
// Original Source files we'll be syncing <b>FROM</b>
@InputDirectory
public DirectoryProperty srcDir = project.objects.directoryProperty()
abstract DirectoryProperty getSrcDir()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these abstract properties automatically injected if you declare them like this? Where is the gradle docs that explains this (and which properties can be injected like so)? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly, so the docs are here but afaik it does not explain the runtime magical injection happening.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see it now. Yeah - it'd be good to require the Inject annotation on those abstract properties too. This would be more intuitive (to me at least).

@dweiss
Copy link
Contributor

dweiss commented Sep 1, 2021

Hi Alexis. I've rebased your patch on top of main (gradle 7.2) and cleaned up some minor noise here and there. The build currently fails though - not sure which normalization strategy would be suitable here.

A problem was found with the configuration of task ':solr:solrj:renderSiteJavadoc' (type 'RenderJavadocTask').
  - Type 'RenderJavadocTask' property 'srcDirSet' is annotated with @InputFiles but missing a normalization strategy.

@alextu
Copy link
Contributor Author

alextu commented Sep 1, 2021

Hi Dawid, I will rebase locally and investigate (today hopefuly)

@dweiss
Copy link
Contributor

dweiss commented Sep 1, 2021

Hey, no rush. I don't think you need to rebase - just pull the changes? I pushed the cleanups directly to your branch (PRs allow for this).

@alextu
Copy link
Contributor Author

alextu commented Sep 1, 2021

Ho right, I missed it, after rebasing I've managed to fix those issues locally, is it ok for you if I force push my changes with a clean commit ?

@dweiss
Copy link
Contributor

dweiss commented Sep 1, 2021

Sure, go ahead.

checkBrokenLinks, renderJavadoc, renderSiteJavadoc, buildLocalJavadocLinksSite, buildSite, prepareLocalJavadocLinksSiteSources, prepareSiteSources tasks are now cacheable.
To take real advantage of the cache between builds, the seed property should be fixed, for example: ./gradlew clean check -Ptests.seed=DEADBEE
@alextu
Copy link
Contributor Author

alextu commented Sep 1, 2021

@dweiss ok it's pushed, it should be fine now

@dweiss dweiss merged commit c3bef8c into apache:main Sep 6, 2021
epugh pushed a commit to epugh/solr that referenced this pull request Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants