Skip to content

perf: ship Baseline Profiles in the library modules - #1840

Open
kikoso wants to merge 2 commits into
mainfrom
feat/baseline-profiles
Open

kikoso wants to merge 2 commits into
mainfrom
feat/baseline-profiles

Conversation

@kikoso

@kikoso kikoso commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

None of the library modules ship a Baseline Profile today, so apps using them run clustering, the GeoJSON/KML parsers and the polyline utilities interpreted/JIT until ART compiles them. This PR adds the profiles and the tooling to regenerate them, same approach as googlemaps/android-maps-compose#1063.

  • New :baselineprofile module (com.android.test, Benchmark 1.5.0) targeting the standard flavor of demo. BaselineProfileGenerator opens the demos that cover the public API (poly decode/simplify, flexible polyline, distance, KTX extensions, IconGenerator, clustering, big and custom marker clustering, zoom clustering, heatmaps, GeoJSON, KML and multi layer) and pans and zooms the map in each one.
  • New BaselineProfileConventionPlugin in build-logic, applied to library, ui, clustering, heatmaps and data. The generated src/main/generated/baselineProfiles/baseline-prof.txt gets packaged in each AAR: data 688 rules, clustering 197, library 104, heatmaps 52 and ui 37.
  • StartupBenchmark compares frame timing of the big clustering and heatmaps demos with CompilationMode.None against the Baseline Profiles. To run on a physical device: ./gradlew :baselineprofile:connectedBenchmarkReleaseAndroidTest.
  • AGENTS.md explains how to regenerate the profiles.

A few points worth to mention

  • Own classes only. The modules share packages between them and with the demo (i.e. com.google.maps.android.ktx.utils.*), and the plugin filter only supports pkg.**, pkg.* or exact class names. So the convention plugin includes com.google.maps.android.** and, after copyBaselineProfileIntoSrc, drops every rule whose class the module does not compile (Kotlin and Java outputs; D8 $$ExternalSynthetic* and $-CC classes are kept for their owner). No class ends up in two modules and no demo class ends up in any.
  • Build types in demo. With AGP 9.4.1 the plugin does not create nonMinifiedRelease and benchmarkRelease in the app, and the generation then silently runs 0 tests. They are declared explicitly in demo/build.gradle.kts with the settings the plugin would apply (not minified, not debuggable, profileable, debug signing). We can drop them once the plugin handles it.
  • Plugin classpath. androidx.baselineprofile is on the root buildscript classpath next to AGP, and in build-logic to compile the convention plugin.
  • Demos are started with am start -W instead of startActivityAndWait, which could not confirm the launch on the map screens. Street View is not part of the journey.
  • Generating needs a real MAPS_API_KEY: with a placeholder the demos close themselves and the profiles come out almost empty.
  • No new runtime dependency: the published POM and .module have no reference to :baselineprofile.

Testing

  • Profiles generated on an API 36 emulator with a real key.
  • baseline-prof.txt is present in the five release AARs.
  • spotlessCheck, build, apiCheck, koverXmlReportDebug, :library:lintDebug and :demo:lintStandardDebug pass locally.

Add a :baselineprofile module that generates the profiles from the demo app,
and a BaselineProfileConventionPlugin that packages them in the library, ui,
clustering, heatmaps and data AARs, keeping only each module's own classes.
It also contains a StartupBenchmark to measure the effect.
@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 62.54% 🍏

There is no coverage information present for the Files changed

This branch has not been deployed

No deployments
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.

3 participants