Skip to content

perf(android): parallelize Gradle build + raise heap to fit build timeout#2432

Open
WcaleNieWolny wants to merge 1 commit into
mainfrom
wolny/android-gradle-build-perf
Open

perf(android): parallelize Gradle build + raise heap to fit build timeout#2432
WcaleNieWolny wants to merge 1 commit into
mainfrom
wolny/android-gradle-build-perf

Conversation

@WcaleNieWolny
Copy link
Copy Markdown
Contributor

@WcaleNieWolny WcaleNieWolny commented Jun 4, 2026

What

Optimize android/gradle.properties so the large multi-plugin Android build completes faster:

  • org.gradle.parallel=true (was commented out → 140 plugin modules built serially)
  • org.gradle.jvmargs: -Xmx1536m-Xmx4096m -XX:MaxMetaspaceSize=1024m
  • org.gradle.caching=true

Why

The Android cloud build for ee.forgr.capacitor_go (~140 Capacitor plugin modules) is deterministically cancelled at the 15-minute mark — that's the app's Capgo build_timeout_seconds = 900. All code blockers are fixed (manifest merge, FileProvider, etc.); the build reaches compile + D8 dexing and runs out of time (runs 26942004595 on 12.159.6 and 26946186506 on 12.159.7, both cancelled at ~19–20 min total / ~15 min build time).

minifyEnabled is already false, so R8 minification isn't the cost — it's compiling + dexing 140 modules. But the build config was under-resourced for that scale: no parallelism and only a 1.5 GB heap. Enabling parallel module builds and a larger heap are safe, standard speedups (no change to the release artifact) that should bring the build comfortably under the timeout. Cloud builder runners are multi-core with ample RAM (ubuntu-latest ≈ 16 GB).

Relationship to the timeout

This complements raising the app's Build Timeout (dashboard setting) — either one (or both) can get the build to complete:

  • Merge this → faster build that likely fits the existing 15 min, no dashboard/DB change needed.
  • Or raise Build Timeout 15 → 60 in the dashboard.

Test plan

  • Merge → new tag → run Build mobile android; confirm the build finishes (AAB produced) within the timeout, and that parallel build + 4 GB heap don't OOM the runner.

Summary by CodeRabbit

  • Chores
    • Optimized Android build configuration to enhance build performance through improved memory allocation, parallel builds, and build caching.

… set

The Android cloud build (ee.forgr.capacitor_go, ~140 Capacitor plugin
modules) was being cancelled at the 15-minute Capgo build timeout during
compile/dexing. gradle.properties was under-resourced for that scale:

- org.gradle.parallel was commented out → 140 modules built serially
- org.gradle.jvmargs=-Xmx1536m → low heap, GC pressure on a huge build

Enable parallel module builds, raise the daemon heap to 4 GB, and turn on
the build cache. These are safe, non-degrading speedups (minifyEnabled is
already false, so no R8/shrink change) that should bring the build under
the timeout. Cloud builder runners are multi-core with ample RAM.

Complements raising the app's build_timeout_seconds; either or both get
the build to complete.
@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented Jun 4, 2026

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing wolny/android-gradle-build-perf (e05f89e) with main (4eabc29)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0b27fc01-618c-485a-8647-8415ed188268

📥 Commits

Reviewing files that changed from the base of the PR and between 4eabc29 and e05f89e.

📒 Files selected for processing (1)
  • android/gradle.properties

📝 Walkthrough

Walkthrough

This PR updates Gradle build configuration settings in android/gradle.properties. The change increases JVM heap size to 4096MB and metaspace to 1024MB, enables parallel module builds, and activates Gradle build caching to improve build performance.

Changes

Gradle Build Performance Optimization

Layer / File(s) Summary
Gradle daemon and build execution settings
android/gradle.properties
JVM heap size and metaspace limits are increased, parallel builds and Gradle caching are enabled for improved build performance.

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: enabling Gradle parallelization and increasing heap size to resolve the build timeout issue.
Description check ✅ Passed The description covers the main changes, justification, and test plan, though it lacks the formal template structure (Summary, Test plan, Screenshots, Checklist sections).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 4, 2026

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.

1 participant