Skip to content

Use the runner's NDK and Gradle's build cache in Android CI - #34

Closed
janicduplessis wants to merge 2 commits into
mainfrom
@janic/android-ci-speed
Closed

janicduplessis wants to merge 2 commits into
mainfrom
@janic/android-ci-speed

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Closed without merging: neither change measurably sped up Android CI. This PR tried the two Android CI savings noted in #29. The numbers are kept here for reference.

Baseline: PRs that don't change Gradle files restore main's setup-java Gradle cache. The Gradle step then spends roughly 25–35 s from Gradle start to the RN Gradle plugin jar, 13–43 s installing NDK 27.1.12297006 (not on the runner image), and 15–30 s in CMake.

1. Use the runner's NDK (27.3.13750724) instead of 27.1 (ndkVersion in example/android/build.gradle). ubuntu-24.04 image 20260920.314 ships NDKs 27.3.13750724 (the default), 28.2.13676358 and 29.0.14206865. The install step went away, but CMake got slower every time. My guess is cold reads of the preinstalled NDK from the image disk, but I haven't confirmed that:

CMake configure → build NDK 27.1 (downloaded in the job) NDK 27.3 (preinstalled)
android 15, 22, 22, 24, 24, 27, 29 s 35, 36, 50 s
e2e 26, 30, 35, 36, 37, 37, 49 s 45, 56, 61 s

With both changes, the warm android Gradle step took 1m17s and 1m23s, against a 1m18s–2m22s baseline. The 13–25 s saved on the install went into CMake.

2. Gradle build cache (org.gradle.caching=true, with the setup-java key extended to example/android/gradle.properties so a new cache gets saved). setup-java's cache: gradle saves all of ~/.gradle/caches and ~/.gradle/wrapper, so build-cache-1 is included, but it only saves on a primary-key miss. The build cache worked (46 of 98 android tasks and 22 of 149 e2e tasks came from cache, including the plugin's compileKotlin), but the time didn't move:

warm run baseline build cache
android Gradle step 1m18s, 1m43s, 1m52s 1m18s, 1m18s
android Gradle start → plugin jar 26, 30, 38 s 23, 24 s
e2e Gradle build 4m04s (main cache) 4m10s, 3m40s

The plugin's compileKotlin tasks take only about 4 s each on a warm run. Most of the ~25 s before :app configures is spent configuring the included build, which the build cache doesn't cover. The build cache added only about 17 MB to the 1.44 GB Gradle cache.

Not tried: caching the NDK directory with actions/cache would add roughly 0.7 GB (estimated) to the repository's 10 GB cache quota to save at most the 13–25 s install, and a restore of that size takes about as long. gradle/actions/setup-gradle was left out because it defaults to a proprietary cache provider.

Runs: android + e2e with both changes / e2e, build cache only / e2e, baseline android (#33) / e2e on main. Attempt 1 of each PR run is cold; attempts 2–3 are warm reruns.

@janicduplessis janicduplessis added the e2e-android Run the Android end-to-end check on this PR label Sep 23, 2026
@janicduplessis

Copy link
Copy Markdown
Contributor Author

Closing: neither change gave a measurable gain in CI. The measurements are in the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-android Run the Android end-to-end check on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant