Skip to content

Improve build speed by altering gradle.properties#1091

Merged
breedx-splk merged 2 commits into
open-telemetry:mainfrom
embrace-io:fractalwrench/alter-gradle-properties
Jul 28, 2025
Merged

Improve build speed by altering gradle.properties#1091
breedx-splk merged 2 commits into
open-telemetry:mainfrom
embrace-io:fractalwrench/alter-gradle-properties

Conversation

@fractalwrench

@fractalwrench fractalwrench commented Jul 24, 2025

Copy link
Copy Markdown
Member

Goal

This PR attempts to improve the build speed and overall build performance of the project by adopting Gradle's suggested practices. This is loosely based on the performance tweaks we've adopted at Embrace over the last couple of years. Changes include:

  1. Increasing the maximum heap size of the build
  2. Various tweaks to JVM options for Gradle and the Gradle daemon that allow it to obtain more memory, if required
  3. Enables parallel execution, which allows unrelated Gradle tasks to run in parallel rather than sequentially
  4. Enables build caching
  5. Enables configuration caching, which can drastically reduce the time required for the configuration phase of the build
  6. Enables parallel storing of the configuration cache

Not all gradle plugins/build scripts are compatible with Gradle's configuration cache as the ecosystem has been moving over. The build has been configured to fail if known problems are detected.

Testing

I used the following command on my local machine:
./gradlew assembleRelease check --no-configuration-cache --no-build-cache --rerun-tasks --scan

A baseline took 6m39s, and with the changeset this took 5m19s. I would expect more performance gains than this in practice given that the benchmarking command disabled configuration/build cache & ran all tasks from scratch.

Future work

The demo-app could have the same settings applied as it's a separate Gradle project. Or, we could consider combining it into one Gradle project so that it's not necessary to run two gradle builds sequentially.

@fractalwrench fractalwrench requested a review from a team as a code owner July 24, 2025 10:16
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 24, 2025

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@bidetofevil bidetofevil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. A completely unscientific perusal of the past ~10 "PR build" GitHub action runs suggest that this will improve things, so it feels right to do, especially since we are just following the Gradle recommendations

@LikeTheSalad LikeTheSalad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that enabling parallel task execution should do most of the job. Tbh I don't know enough about how GH machines work to be sure that something that's cached on one machine (regarding enabling build and config cache) would work for a further action run that might happen on a different machine?

It's not a blocker, though, I'm mostly curious. Thanks for taking the time to address this issue 🙏

@fractalwrench

Copy link
Copy Markdown
Member Author

@LikeTheSalad the setup-gradle action stores build state in Github's cache so it's available for subsequent runs. For a real-life example, here's Embrace's CI caches.

@LikeTheSalad

Copy link
Copy Markdown
Contributor

@LikeTheSalad the setup-gradle action stores build state in Github's cache so it's available for subsequent runs. For a real-life example, here's Embrace's CI caches.

Sounds good, thanks for the explanation!

@breedx-splk breedx-splk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm down to try this for sure. My only hesitation is that we probably still want to make sure that we're NOT caching when we run the final release build, right? In that case, we probably want to add --no-build-cache to the release.yml too?

@fractalwrench

Copy link
Copy Markdown
Member Author

That sounds sensible. I've updated the release command so that it doesn't use build cache, parallel execution, or configuration cache.


- name: Build and publish artifacts
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pfinal=true
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pfinal=true --no-build-cache --no-configuration-cache --no-parallel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Unfortunately, I think this is the safest way to get a consistent build output.

@breedx-splk breedx-splk merged commit 609547d into open-telemetry:main Jul 28, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants