perf(ci): reduce build memory and CPU allocations
Scale down memory limits and parallelization settings across CI build pipeline. Reduce heap from 8g to 4g, metaspace from 1g to 512m, worker count from 4 to 2, and CMAKE build parallel level from 8 to 4. Remove Gradle caching and update web export to use explicit NODE_OPTIONS for memory allocation. These optimizations reduce resource usage while maintaining stable builds.
This commit is contained in:
@@ -99,12 +99,11 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: reactnativecommunity/react-native-android:latest
|
image: reactnativecommunity/react-native-android:latest
|
||||||
env:
|
env:
|
||||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4 -Xmx8g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:ReservedCodeCacheSize=512m"
|
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.workers.max=2 -Xmx4g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:ReservedCodeCacheSize=256m"
|
||||||
_JAVA_OPTIONS: "-Xmx8g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:ReservedCodeCacheSize=512m"
|
_JAVA_OPTIONS: "-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:ReservedCodeCacheSize=256m"
|
||||||
NODE_OPTIONS: "--max-old-space-size=8192"
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||||
NODE_ENV: "production"
|
NODE_ENV: "production"
|
||||||
NDK_NUM_JOBS: "4"
|
CMAKE_BUILD_PARALLEL_LEVEL: "4"
|
||||||
CMAKE_BUILD_PARALLEL_LEVEL: "8"
|
|
||||||
GRADLE_USER_HOME: /root/.gradle
|
GRADLE_USER_HOME: /root/.gradle
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -126,17 +125,6 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Cache Gradle
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
~/.android/build-cache
|
|
||||||
key: ${{ runner.os }}-gradle-${{ hashFiles('package-lock.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-gradle-
|
|
||||||
|
|
||||||
- name: Generate Android native project
|
- name: Generate Android native project
|
||||||
run: npx expo prebuild --platform android
|
run: npx expo prebuild --platform android
|
||||||
|
|
||||||
@@ -243,10 +231,10 @@ jobs:
|
|||||||
# Update gradle.properties (without secrets for better cache hit rate)
|
# Update gradle.properties (without secrets for better cache hit rate)
|
||||||
cat > gradle.properties << 'PROPS_EOF'
|
cat > gradle.properties << 'PROPS_EOF'
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=false
|
||||||
org.gradle.configureondemand=true
|
org.gradle.configureondemand=true
|
||||||
org.gradle.workers.max=4
|
org.gradle.workers.max=2
|
||||||
org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError
|
||||||
android.enableJetifier=false
|
android.enableJetifier=false
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
hermesEnabled=true
|
hermesEnabled=true
|
||||||
@@ -278,7 +266,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd android
|
cd android
|
||||||
chmod +x gradlew
|
chmod +x gradlew
|
||||||
./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a --max-workers=4 --parallel
|
./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a --max-workers=2
|
||||||
|
|
||||||
- name: Upload APK artifact
|
- name: Upload APK artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ COPY package.json package-lock.json ./
|
|||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npx expo export --platform web --output-dir dist-web
|
RUN NODE_OPTIONS="--max-old-space-size=2048" node /app/node_modules/.bin/expo export --platform web --output-dir dist-web
|
||||||
|
|
||||||
FROM nginx:1.27-alpine
|
FROM nginx:1.27-alpine
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const { withDangerousMod } = require('@expo/config-plugins');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const MAX_JOBS = '8';
|
const MAX_JOBS = '4';
|
||||||
|
|
||||||
// React Native's hermes-engine build hardcodes
|
// React Native's hermes-engine build hardcodes
|
||||||
// Runtime.getRuntime().availableProcessors()
|
// Runtime.getRuntime().availableProcessors()
|
||||||
|
|||||||
Reference in New Issue
Block a user