mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-13 03:51:10 +00:00
perf(lab): compile with the Kotlin daemon, since in-process Kotlin compiles always redo the whole app
This commit is contained in:
1 parent
9d73ff75bc
commit
f638979507
2 files changed
+16
-5
No files matched your search
+3
-1
@@ -52,7 +52,9 @@ tools/agent/setup
|
||||
|
||||
It installs Claude Code, git, gh and loopback adb, plus the build toolchain: JDK 17, the Android
|
||||
SDK platform, and Google's x86-64 `aapt2` run under `qemu-user`. The first Lab build compiles the
|
||||
whole app and takes about 20 minutes on a Snapdragon 865; later ones are incremental. Setup
|
||||
whole app and takes about 8 minutes on a Snapdragon 865; later ones compile only what changed.
|
||||
That needs the Kotlin daemon: Kotlin's in-process compiles always redo the whole app. BuildConfig
|
||||
is given the installed commit, so committing a change does not change it. Setup
|
||||
does that first build ahead of time with `dd-lab-build --prepare`, which compiles the installed
|
||||
commit without making a Lab build.
|
||||
`~/.cache/dd-lab-build.json` reports the stage, the current task, progress in thousandths and the
|
||||
|
||||
@@ -96,15 +96,24 @@ if [ ! -d "$ANDROID_HOME/platforms/android-34" ]; then
|
||||
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platforms;android-34" "build-tools;35.0.0" >/dev/null
|
||||
fi
|
||||
|
||||
# A full Kotlin compile of the app needs about 3 GB of heap; smaller devices get what they can spare.
|
||||
# A full Kotlin compile of the app needs about 2.5 GB of heap and Gradle about 1 GB; smaller devices get
|
||||
# what they can spare. Both daemons end with this script's process when the build is done.
|
||||
total_mb=$(awk '/^MemTotal:/ {print int($2 / 1024)}' /proc/meminfo)
|
||||
heap=$(( total_mb * 2 / 5 )); [ $heap -gt 3072 ] && heap=3072; [ $heap -lt 1536 ] && heap=1536
|
||||
heap=$(( total_mb / 2 )); [ $heap -gt 4096 ] && heap=4096; [ $heap -lt 2048 ] && heap=2048
|
||||
heap=${DD_LAB_HEAP_MB:-$heap}
|
||||
kotlin_heap=$(( heap * 2 / 3 )); gradle_heap=$(( heap - kotlin_heap ))
|
||||
|
||||
# Only the Kotlin daemon compiles incrementally; in-process compiles always redo the whole app, and the
|
||||
# caches they leave behind make the daemon's first incremental compile fail.
|
||||
if [ "$(cat "$cache/dd-lab-build-strategy" 2>/dev/null)" != daemon ]; then
|
||||
rm -rf app/build/kotlin/compileReleaseKotlin
|
||||
echo daemon > "$cache/dd-lab-build-strategy"
|
||||
fi
|
||||
|
||||
# Google publishes aapt2 for x86-64 Linux only; setup wraps it in qemu-user at ~/aapt2/aapt2.
|
||||
gradle=(./gradlew :app:processReleaseResources :app:mergeDexRelease --max-workers=2 -PskipRust=true -x buildVkBridgeServer
|
||||
-Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=in-process
|
||||
-Dorg.gradle.jvmargs=-Xmx${heap}m --console=plain)
|
||||
-Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=daemon
|
||||
-Pkotlin.daemon.jvmargs=-Xmx${kotlin_heap}m -Dorg.gradle.jvmargs=-Xmx${gradle_heap}m --console=plain)
|
||||
progress planning
|
||||
mapfile -t plan < <("${gradle[@]}" --dry-run -q 2>/dev/null | awk '/^:/ {print $1}' || true)
|
||||
total=${#plan[@]}
|
||||
|
||||
Reference in new issue
Block a user