Skip to content

Parallelize Gradle API runtime jar generation#36952

Merged
blindpirate merged 2 commits intomasterfrom
jvandort/hacks/parallelize-gradle-api-generation
Mar 6, 2026
Merged

Parallelize Gradle API runtime jar generation#36952
blindpirate merged 2 commits intomasterfrom
jvandort/hacks/parallelize-gradle-api-generation

Conversation

@jvandort
Copy link
Copy Markdown
Member

@jvandort jvandort commented Mar 4, 2026

Whenever a distribution is used for the first time on a machine, Gradle needs to generate the Gradle API jar. In future changes, we may consider computing this jar at build-time, however this requires extensive changes. Currently however, this generation process takes ~3.5 seconds.

We parallelize this process, reducing the generation time to ~1.5-2 seconds. In addition, we remove a regex from a very often called method in ImplementationDependencyRelocator, replacing it with an implementation that performs minimal allocation, reducing the GC pressure impact we add due to parallelizing this process.

For a simple build with one kotlin build file and one settings script file, this reduces first use (cold daemon, empty GUH) from ~12.5 seconds to ~10.5 seconds, a ~15% improvement.
image

Before:
image

After:
image

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

Whenever a distribution is used for the first time on a machine, Gradle needs to generate the Gradle API jar.
In future changes, we may consider computing this jar at build-time, however this requires extensive changes.
Currently however, this generation process takes ~3.5 seconds.

We parallelize this process, reducing the generation time to ~1.5-2 seconds. In addition, we remove a regex
from a very often called method in ImplementationDependencyRelocator, replacing it with an implementation
that performs minimal allocation, reducing the GC pressure impact we add due to parallelizing this process.

For a simple build with one kotlin build file and one settings script file, this reduces first use
(cold daemon, empty GUH) from ~12.5 seconds to ~10.5 seconds, a ~18% improvement.
@jvandort jvandort force-pushed the jvandort/hacks/parallelize-gradle-api-generation branch from 1c8657f to c812d5c Compare March 4, 2026 23:54
@jvandort jvandort self-assigned this Mar 4, 2026
@jvandort jvandort modified the milestones: 8.x backport, 9.5.0 RC1 Mar 4, 2026
@jvandort
Copy link
Copy Markdown
Member Author

jvandort commented Mar 5, 2026

@bot-gradle test this

@bot-gradle

This comment has been minimized.

@jvandort jvandort marked this pull request as ready for review March 5, 2026 01:27
@jvandort jvandort requested a review from a team as a code owner March 5, 2026 01:27
@jvandort jvandort requested a review from octylFractal March 5, 2026 01:27
@bot-gradle
Copy link
Copy Markdown
Collaborator

The following builds have passed:

Use final class
Increase timeout to 5 minutes
Use priority queue instead of tree set
@jvandort jvandort requested a review from octylFractal March 5, 2026 15:41
@jvandort jvandort added this pull request to the merge queue Mar 5, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 5, 2026
@blindpirate blindpirate added this pull request to the merge queue Mar 6, 2026
Merged via the queue into master with commit e08f009 Mar 6, 2026
26 checks passed
@blindpirate blindpirate deleted the jvandort/hacks/parallelize-gradle-api-generation branch March 6, 2026 04:52
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