ci: cap Gradle heap/workers on Linux runners (override local -Xmx46g via ~/.gradle for GitHub runners)
- Commit
410a73bb72324480614881cdb639a34dbf3aae1d- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-16 21:30 UTC (3 months ago)
- Parents
4ec63c0
Diff
.github/workflows/android.yml
diff --git a/.github/workflows/android.yml b/.github/workflows/android.ymlindex 36f2d19ac5..dbaaf29efd 100644--- a/.github/workflows/android.yml+++ b/.github/workflows/android.yml@@ -48,6 +48,23 @@ jobs: - name: Change Gradle Wrapper Permissions run: chmod +x ./gradlew + - name: Configure Gradle for CI runner+ run: |+ # GitHub-hosted Linux runners are ~16GB RAM / ~4 vCPU. The project's+ # local gradle.properties sizes the daemon at -Xmx46g for a full local+ # build of every module at once, which cannot start on a runner.+ # GRADLE_USER_HOME (~/.gradle)/gradle.properties overrides the project+ # gradle.properties, so cap heap + workers to runner-appropriate values+ # here rather than changing the local dev defaults.+ mkdir -p ~/.gradle+ {+ echo 'org.gradle.jvmargs=-Xmx6144m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -Dfile.encoding=UTF-8'+ echo 'org.gradle.workers.max=2'+ echo 'kotlin.daemon.jvm.options=-Xmx2048m'+ echo 'android.compose.screenshot.maxHeapSize=2g'+ } >> ~/.gradle/gradle.properties+ echo "CI gradle overrides:" && cat ~/.gradle/gradle.properties+ - name: Read and Inject Version id: version_info run: |@@ -221,6 +238,7 @@ jobs: # Always build release APKs for every app module. ./gradlew assembleRelease \ --no-daemon \+ --max-workers=2 \ -x lint \ -x test \ -Pandroid.enableResourceOptimizations=true \
.github/workflows/pr-compile-check.yml
diff --git a/.github/workflows/pr-compile-check.yml b/.github/workflows/pr-compile-check.ymlindex 1c04cef7a9..24f087dd4f 100644--- a/.github/workflows/pr-compile-check.yml+++ b/.github/workflows/pr-compile-check.yml@@ -27,5 +27,21 @@ jobs: - name: Change Gradle Wrapper Permissions run: chmod +x ./gradlew + - name: Configure Gradle for CI runner+ run: |+ # GitHub-hosted Linux runners are ~16GB RAM / ~4 vCPU. The project's+ # local gradle.properties sizes the daemon at -Xmx46g, which cannot+ # start on a runner. GRADLE_USER_HOME (~/.gradle)/gradle.properties+ # overrides the project gradle.properties, so cap heap + workers to+ # runner-appropriate values here (leaves the local dev defaults alone).+ mkdir -p ~/.gradle+ {+ echo 'org.gradle.jvmargs=-Xmx6144m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -Dfile.encoding=UTF-8'+ echo 'org.gradle.workers.max=2'+ echo 'kotlin.daemon.jvm.options=-Xmx2048m'+ echo 'android.compose.screenshot.maxHeapSize=2g'+ } >> ~/.gradle/gradle.properties+ echo "CI gradle overrides:" && cat ~/.gradle/gradle.properties+ - name: Check All Apps Compile- run: ./gradlew :compileDevKotlin+ run: ./gradlew :compileDevKotlin --max-workers=2
gradle.properties
diff --git a/gradle.properties b/gradle.propertiesindex 244bfdcb64..03fc140c7f 100644--- a/gradle.properties+++ b/gradle.properties@@ -1,40 +1,42 @@-# Heap sized for a full local assembleDev of all modules at once: with-# parallel=true and workers.max=4, several modules run mergeExtDex/D8-# concurrently in the same daemon heap, and 3584m was exhausted (D8 dex merge-# OutOfMemoryError). 6144m gives the concurrent D8 workers enough headroom.-# On 16GB CI runners, lower org.gradle.workers.max to 2 instead if memory is tight.-#-# MaxMetaspaceSize=1024m: the previous 512m cap was killing the daemon on-# release builds (R8 fullMode + lintVitalRelease + KSP + Kotlin compile all-# load class metadata into the same daemon's metaspace; with parallel=4 we-# easily blew past 512m).-org.gradle.jvmargs=-Xmx46144m -Xms4512m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -Dfile.encoding=UTF-8-kotlin.daemon.jvm.options=-Xmx1536m--# Use more workers in parallel for multi-module compilation.-org.gradle.parallel=true-org.gradle.caching=true--# Modern defaults-kotlin.code.style=official--# Performance & Optimization-org.gradle.configuration-cache=true-android.enableR8.fullMode=true--# Preview Support (Remove once SDK 37 is stable)-android.suppressUnsupportedCompileSdk=37.0--# Compose Preview Screenshot Testing, used by common-conventions-preview-metadata to render-# store listing images from @Preview instead of from an instrumented test on a device.-# It has to live here rather than in the android {} block: the plugin reads it when it is-# applied, which is before any DSL has been configured. Modules that don't apply the plugin-# just get an empty screenshotTest source set, which costs nothing.-android.experimental.enableScreenshotTest=true--# Preview rendering is host-side and holds whole bitmaps in memory; the listing images are-# full-screen at xxhdpi (~1080x2340), so the default test-JVM heap is not enough.-android.compose.screenshot.maxHeapSize=4g--# Enabled parallel sync for Gradle 9.4+-org.gradle.tooling.parallel=true+# Heap sized for a full local assembleDev of all modules at once: with+# parallel=true and workers.max=4, several modules run mergeExtDex/D8+# concurrently in the same daemon heap, and 3584m was exhausted (D8 dex merge+# OutOfMemoryError). 6144m gives the concurrent D8 workers enough headroom.+# On 16GB CI runners this -Xmx46g cannot start; the GitHub workflows+# (.github/workflows/android.yml + pr-compile-check.yml) override these via+# ~/.gradle/gradle.properties with a runner-appropriate heap + workers.max=2.+#+# MaxMetaspaceSize=1024m: the previous 512m cap was killing the daemon on+# release builds (R8 fullMode + lintVitalRelease + KSP + Kotlin compile all+# load class metadata into the same daemon's metaspace; with parallel=4 we+# easily blew past 512m).+org.gradle.jvmargs=-Xmx46144m -Xms4512m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -Dfile.encoding=UTF-8+kotlin.daemon.jvm.options=-Xmx1536m++# Use more workers in parallel for multi-module compilation.+org.gradle.parallel=true+org.gradle.caching=true++# Modern defaults+kotlin.code.style=official++# Performance & Optimization+org.gradle.configuration-cache=true+android.enableR8.fullMode=true++# Preview Support (Remove once SDK 37 is stable)+android.suppressUnsupportedCompileSdk=37.0++# Compose Preview Screenshot Testing, used by common-conventions-preview-metadata to render+# store listing images from @Preview instead of from an instrumented test on a device.+# It has to live here rather than in the android {} block: the plugin reads it when it is+# applied, which is before any DSL has been configured. Modules that don't apply the plugin+# just get an empty screenshotTest source set, which costs nothing.+android.experimental.enableScreenshotTest=true++# Preview rendering is host-side and holds whole bitmaps in memory; the listing images are+# full-screen at xxhdpi (~1080x2340), so the default test-JVM heap is not enough.+android.compose.screenshot.maxHeapSize=4g++# Enabled parallel sync for Gradle 9.4++org.gradle.tooling.parallel=true