Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.

Improve GRADLE build Performance #353

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shisheng-1
Copy link

Process forking options. Gradle will run all tests in a single forked VM by default. This can be problematic if there are a lot of tests or some very memory-hungry ones. We can fork a new test VM after a certain number of tests have run by setting forkEvery.

=====================
If there are any inappropriate modifications in this PR, please give me a reply and I will change them.

@jzheaux
Copy link
Contributor

jzheaux commented Nov 24, 2021

Hi, @shisheng-1! Thanks for the suggestion.

I think we could get a greater performance boot from parallelizing the build. Would you be able to instead change build.properties to have the line:

org.gradle.parallel=true

I prefer this solution since it allows Gradle to decide how best to parallelize things.

@shisheng-1
Copy link
Author

Hi @jzheaux !
In GRADLE, As we can see here, there are two different levels of parallel : test and project

On parallel at TEST level GRADLE also provides another parameter configuration: maxParallelForks


First, I'd like to discuss the improvements that come with using Process forking options
By use ./gradlew test --scan , we can get the data:

with forkEvery without forkEvery
1m 16s 1m 19s

By use ./gradlew clean build, we can get the data:

with forkEvery without forkEvery
2m 33s 3m 40s

@shisheng-1
Copy link
Author

As I mentioned above,GRADLE also provides another configuration for Parallel at the TEST level : Parallel test execution maxParallelForks.
Gradle can run multiple test cases in parallel by setting maxParallelForks

We can add maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 in tasks.withType(Test).configureEach{}

Build the project by ./gradlew clean build, the build time is 2m 24s


and if we add org.gradle.parallel=true in gradle.properties, the build time is 2m 18s

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

2 participants