Cut clean probe build from 59 s to ~40 s
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,free-days-interop,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run

Build cache, Dart compile ordered first in :app, and debug APKs without
32-bit ABIs or the Vulkan validation layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-22 17:14:11 +01:00
parent 6be954afd4
commit 00cc8ca223
3 changed files with 52 additions and 0 deletions

View File

@ -184,3 +184,24 @@ leg and during a ring. `flutter build apk --debug --target`
produced an APK that ran `main.dart` instead; `flutter run -t` did not. produced an APK that ran `main.dart` instead; `flutter run -t` did not.
The phone remains the only test of the AlarmManager deadline with the The phone remains the only test of the AlarmManager deadline with the
screen off and the app swiped away. screen off and the app swiped away.
A clean-tree `flutter build apk --debug -t lib/main_session_probe.dart`
held a build slot for 62 s (board build, load ~18). Measured back to back
on 2026-11-22 at load ~12: 54.5 s at the old HEAD, 41.5 s and 35.7 s with
these three changes (59.4 s before them at load ~18):
- `org.gradle.caching=true` (`android/gradle.properties`): a fresh worktree
pulls plugin, Kotlin and dex outputs from `~/.gradle/caches/build-cache-1`.
- `app/build.gradle.kts` runs `compileFlutterBuild<Variant>` (the ~20 s Dart
kernel compile) before `pre<Variant>Build`. Gradle runs one task per
project at a time without the configuration cache, which FlutterTask does
not support; the compile used to start 8 s late and block Kotlin, dex and
manifests behind it.
- Debug APKs drop `lib/armeabi-v7a`, `lib/x86` and the engine's Vulkan
validation layer: debug installs only reach the arm64 Pixel and the
x86_64 emulator. The APK shrinks from 182 MB to 134 MB, and merging and
zipping it gets faster. Release keeps every ABI.
What stays fixed: ~20 s of Gradle start and configuration (`~/.gradle`
sets `daemon=false`, so every build pays a cold JVM) and the Dart compile
of a 106 MB `app.dill`.

View File

@ -84,3 +84,30 @@ dependencies {
// that needs a Context stays out of them. // that needs a Context stays out of them.
testImplementation("junit:junit:4.13.2") testImplementation("junit:junit:4.13.2")
} }
// Start the Dart compile first. Without the configuration cache (Flutter's
// FlutterTask does not support it) Gradle runs one :app task at a time, and
// `compileFlutterBuild<Variant>` sat ~190th in the plan: on a clean tree it
// started ~8 s in, after :app had idled waiting on plugin resources, then
// held :app for ~20 s while Kotlin, dex and manifests queued behind it.
// Running it before pre<Variant>Build overlaps it with the plugin projects.
// mustRunAfter only orders; it pulls the compile into no task graph.
tasks.matching { it.name.matches(Regex("pre\\w+Build")) }.configureEach {
val variant = name.removePrefix("pre").removeSuffix("Build")
mustRunAfter(tasks.matching { it.name == "compileFlutterBuild$variant" })
}
// Debug APKs only reach the Pixel 6a (arm64-v8a) and the x86_64 emulator.
// Flutter packs three ABIs into every debug APK (182 MB), and merging,
// stripping and zipping libraries no debug install loads cost the clean
// probe build seconds it does not have: the 32-bit ABIs, and the engine's
// 15 MB Vulkan validation layer, loaded only when the manifest sets
// io.flutter.embedding.android.EnableVulkanValidation (it does not).
// Release keeps every ABI.
androidComponents {
onVariants(selector().withBuildType("debug")) { variant ->
variant.packaging.jniLibs.excludes.addAll(
listOf("lib/armeabi-v7a/**", "lib/x86/**", "**/libVkLayer_khronos_validation.so"),
)
}
}

View File

@ -1,4 +1,8 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
# Build cache: a fresh worktree reuses plugin/Kotlin/dex task outputs from ~/.gradle/caches/build-cache-1.
# (~/.gradle/gradle.properties wins over this file, so its daemon=false and jvmargs still apply.)
org.gradle.caching=true
org.gradle.parallel=true
android.useAndroidX=true android.useAndroidX=true
# This newDsl flag was added by the Flutter template # This newDsl flag was added by the Flutter template
android.newDsl=false android.newDsl=false