Skip to content

[Dont merge] Add a third-party library keep ratio report - #221

Open
AjeshRPai wants to merge 2 commits into
r8-modular-regression-gatefrom
third-party-keep-ratio-report
Open

AjeshRPai wants to merge 2 commits into
r8-modular-regression-gatefrom
third-party-keep-ratio-report

Conversation

@AjeshRPai

Copy link
Copy Markdown
Contributor

Adds a report-only section to the R8 regression gate's pull request comment: the keep ratio of the app's third-party libraries, measured with android analyze. Builds on #219.

What it does

  • Lists the third-party AARs and JARs in the app's release runtime classpath with Gradle's built-in dependencies report, and finds them in the Gradle cache.
  • Runs android analyze on them in batches, and calculates each keep ratio: the R8 DEX size divided by the D8 DEX size of the library analyzed on its own. It's the share of a library that its own keep rules force into every app that uses it.
  • Lists only the libraries that keep part of their code, highest keep ratio first.
  • Compares the results with third-party-keep-ratios.json, and shows the added, removed, and updated libraries whose kept code changed.
  • Never fails the gate. After a merge to main where the checks pass, the workflow updates third-party-keep-ratios.json along with r8-baseline.json.

Files

File Change
scripts/report_library_keep_ratios.py New report script
third-party-keep-ratios.json New baseline with the 319 libraries the app ships
.github/workflows/r8_regression_check.yml Runs the report after the library check, and updates the baseline after a merge to main

Demo

The second commit makes the camera feature depend on WorkManager 2.11.2, the version that the Wear OS app uses, instead of the 2.7.0 that ML Kit pulls in. In a local run, the report shows:

Library Version Keep Ratio R8 Kept DEX Change
androidx.work:work-multiprocess 2.7.0 → 2.11.2 0.03 → 0.03 1.87 KB → 2.58 KB +0.71 KB
androidx.work:work-runtime 2.7.0 → 2.11.2 0.02 → <0.01 5.07 KB → 0.52 KB -4.55 KB

List the app's third-party AARs and JARs with Gradle's dependencies
report, and run android analyze on them. The report lists the libraries
that keep part of their code with their own keep rules, highest keep
ratio first, and compares them with third-party-keep-ratios.json to show
how added, removed, and updated libraries changed the kept code.

The report never fails the gate. After a merge to main where the checks
pass, the workflow updates third-party-keep-ratios.json along with
r8-baseline.json.
ML Kit pose detection pulls in WorkManager 2.7.0. Depend on the version
that the Wear OS app already uses, to show how the keep ratio report
compares an updated library with the baseline.
@github-actions

Copy link
Copy Markdown

🛡️ R8 Optimization & Shrinking Gate (android analyze)

📦 App Bundle R8 Scores & DEX Size

  • Package: com.android.developers.androidify
  • Compiler: AGP 9.3.2 / R8 9.3.16 (Full Mode: True)
  • Baseline: r8-baseline.json
Metric Baseline Current Delta Threshold Status
Shrinking Score 52.49% 51.76% -0.73% pts max -2.00% pts ✅ PASS
Optimization Score 52.15% 51.42% -0.73% pts max -2.00% pts ✅ PASS
Obfuscation Score 52.45% 51.73% -0.72% pts max -2.00% pts ✅ PASS
Uncompressed DEX Size 17.99 MB 17.72 MB -0.27 MB (-1.5%) max +5.0% / +500KB ✅ PASS

📚 Library Shrinking Percentage (Min Threshold: 90.0%)

Library (.aar / .jar) D8 DEX R8 Kept DEX DEX Shrinking % Classes Shrunk Methods Shrunk Pkg-Wide Rules Status
network-release.aar 64.39 KB 0.00 KB 100.00% 100.0% (49/49) 100.0% (250/250) 0 ✅ PASS
testing-release.aar 29.22 KB 0.00 KB 100.00% 100.0% (17/17) 100.0% (119/119) 0 ✅ PASS
theme-release.aar 209.49 KB 0.00 KB 100.00% 100.0% (51/51) 100.0% (405/405) 0 ✅ PASS
util-release.aar 44.73 KB 0.00 KB 100.00% 100.0% (24/24) 100.0% (111/111) 0 ✅ PASS
xr-release.aar 44.74 KB 0.00 KB 100.00% 100.0% (13/13) 100.0% (64/64) 0 ✅ PASS
data-release.aar 55.19 KB 0.00 KB 100.00% 100.0% (54/54) 100.0% (193/193) 0 ✅ PASS
camera-release.aar 289.75 KB 0.00 KB 100.00% 100.0% (93/93) 100.0% (550/550) 0 ✅ PASS
creation-release.aar 343.21 KB 0.00 KB 100.00% 100.0% (86/86) 100.0% (610/610) 0 ✅ PASS
home-release.aar 186.55 KB 0.00 KB 100.00% 100.0% (47/47) 100.0% (310/310) 0 ✅ PASS
results-release.aar 602.10 KB 0.00 KB 100.00% 100.0% (200/200) 100.0% (1127/1127) 0 ✅ PASS
watchface-release.aar 72.23 KB 2.73 KB 96.21% 95.7% (44/46) 96.1% (246/256) 11 ⚠️ WARN
common-release.aar 45.38 KB 0.00 KB 100.00% 100.0% (31/31) 100.0% (229/229) 0 ✅ PASS

📦 Third-Party Library Keep Ratios (Report Only)

20 of 291 third-party libraries with code keep part of it with their own keep rules (969.62 KB in total). The keep ratio is the R8 DEX size divided by the D8 DEX size of each library analyzed on its own.

Changes since the baseline

Library Version Keep Ratio R8 Kept DEX Change
androidx.work:work-multiprocess 2.7.0 → 2.11.2 0.03 → 0.03 1.87 KB → 2.58 KB +0.71 KB
androidx.work:work-runtime 2.7.0 → 2.11.2 0.02 → <0.01 5.07 KB → 0.52 KB -4.55 KB

Libraries that keep code

Libraries that keep none of their code aren't listed.

Library Keep Ratio R8 Kept DEX D8 DEX
com.google.ar:core:1.53.0 0.91 163.04 KB 179.05 KB
com.google.ar:impress:0.0.14 0.76 48.89 KB 64.64 KB
androidx.xr.runtime:runtime-openxr:1.0.0-alpha14 0.74 7.44 KB 10.07 KB
com.google.firebase:firebase-ai:17.12.1 0.52 557.04 KB 1.05 MB
com.google.mlkit:mediapipe-internal:17.0.0-beta10 0.43 119.21 KB 275.32 KB
androidx.xr.runtime:runtime:1.0.0-alpha14 0.19 33.30 KB 174.53 KB
com.github.zjupure:webpdecoder:2.7.4.16.0 0.17 10.75 KB 61.77 KB
androidx.graphics:graphics-path:1.0.1 0.10 1.71 KB 17.57 KB
androidx.versionedparcelable:versionedparcelable:1.1.1 0.09 2.95 KB 34.36 KB
androidx.xr.arcore:arcore-runtime:1.0.0-alpha14 0.07 2.38 KB 36.07 KB
androidx.lifecycle:lifecycle-runtime-android:2.11.0-beta02 0.04 2.18 KB 48.65 KB
androidx.work:work-multiprocess:2.11.2 0.03 2.58 KB 95.88 KB
androidx.annotation:annotation-jvm:1.10.0 0.02 0.55 KB 25.18 KB
androidx.xr.arcore:arcore-openxr:1.0.0-alpha14 0.02 2.09 KB 97.25 KB
androidx.recyclerview:recyclerview:1.3.0 0.01 3.67 KB 332.29 KB
androidx.window:window:1.5.1 0.01 2.44 KB 404.44 KB
androidx.camera:camera-camera2:1.6.1 0.01 5.12 KB 913.82 KB
com.github.bumptech.glide:glide:4.16.0 0.01 2.62 KB 511.78 KB
com.google.android.gms:play-services-basement:18.10.0 <0.01 1.14 KB 264.81 KB
androidx.work:work-runtime:2.11.2 <0.01 0.52 KB 588.61 KB

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant