From 399da799a66af60df3175808eae98d08c5fcae06 Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Sat, 23 Mar 2024 15:12:05 +0530 Subject: [PATCH] speed up android debug builds (#19335) fixes #19081 ## Summary This PR aims to improve android build step for debug variants by ensuring we do not rebuild the android derivation for any change made to `clojurescript` code. We also do the following things : - enable `JVM` parallel garbage collector. - get rid of `dexOptions` which was deprecated in `gradle 8`. - add additional `parallel` flag to `gradle` to speed up builds. ## Review notes - `make run-clojure` - `make run-android` - ctrl + C on android terminal and edit any `cljs` file - `make run-android` ( should build almost instantly ) --- android/app/build.gradle | 4 ---- android/build.gradle | 17 +++++++++++++++++ android/gradle.properties | 2 +- nix/mobile/android/build.nix | 6 +++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3e21fe6dc8..b7b7d05bb4 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -199,10 +199,6 @@ android { doNotStrip '*/mips/*.so' doNotStrip '*/mips64/*.so' } - dexOptions { - jumboMode true - javaMaxHeapSize "8g" - } splits { abi { reset() diff --git a/android/build.gradle b/android/build.gradle index 37b2240dc4..17890dface 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -44,6 +44,23 @@ subprojects { defaultConfig { targetSdkVersion rootProject.ext.targetSdkVersion } + + // Speed up Tests Stage + tasks.withType(Test).configureEach { + // https://docs.gradle.org/current/userguide/performance.html#execute_tests_in_parallel + maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + // https://docs.gradle.org/current/userguide/performance.html#fork_tests_into_multiple_processes + forkEvery = 100 + // https://docs.gradle.org/current/userguide/performance.html#disable_reports + reports.html.required = false + reports.junitXml.required = false + } + // Speed up Java Compile Stage + // https://docs.gradle.org/current/userguide/performance.html#run_the_compiler_as_a_separate_process + tasks.withType(JavaCompile).configureEach { + options.fork = true + } + } } } diff --git a/android/gradle.properties b/android/gradle.properties index d8b5ad4e6d..5fd5209294 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -43,7 +43,7 @@ ANDROID_ABI_SPLIT=false # Some platforms are excluded though ANDROID_ABI_INCLUDE=armeabi-v7a;arm64-v8a;x86;x86_64 -org.gradle.jvmargs=-Xmx8704M +org.gradle.jvmargs=-Xmx8704M -XX:+UseParallelGC versionCode=9999 commitHash=unknown diff --git a/nix/mobile/android/build.nix b/nix/mobile/android/build.nix index a11dba4509..0a89e92fb3 100644 --- a/nix/mobile/android/build.nix +++ b/nix/mobile/android/build.nix @@ -26,9 +26,10 @@ let inherit (lib) toLower optionalString stringLength makeLibraryPath elem; + notDebug = (buildType != "debug"); # Pass secretsFile for POKT_TOKEN to jsbundle build - builtJsBundle = jsbundle { inherit secretsFile; }; + builtJsBundle = lib.optionals notDebug jsbundle { inherit secretsFile; }; # Map ANDROID_ABI_INCLUDE to status-go targets androidAbiIncludeSplit = lib.splitString ";" androidAbiInclude; @@ -119,8 +120,10 @@ in stdenv.mkDerivation rec { # Export all vars from .env file export $(cut -d= -f1 .env) + ${lib.optionalString notDebug '' # Symlink React Native entrypoint. cp -Lr ${builtJsBundle} ./result + ''} # Copy android/ directory mkdir -p ./android/build @@ -153,6 +156,7 @@ in stdenv.mkDerivation rec { --no-scan \ --no-watch-fs \ --no-build-cache \ + --parallel \ -Dmaven.repo.local='${deps.gradle}' \ assemble${gradleBuildType} '';