notes: ship baseline and startup profiles for cold start
- Commit
d8480f24bbe3f66801feefaaf5fba0d932745aad- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 23:03 UTC (4 hours ago)
- Parents
af43a53
No app in the repo shipped a Baseline or Startup Profile, so ART had no AOT/DEX-layout guidance for the pre-Activity and class-load segment that dominates cold start. Shared seam (common-conventions-app): every app now ships androidx.profileinstaller:profileinstaller 1.4.1, and an app opts in by dropping HRF files at src/main/baseline-prof.txt and src/main/startup-prof.txt, which AGP compiles into the release APK with no per-app build wiring. Automated generation still needs a device via a Macrobenchmark baselineprofile module; that is documented in the convention and in the profile files, and authoring HRF by hand does not need a device. Reference profile (:notes): baseline-prof.txt covers the cold-start path (MainActivity, MaActivity shell, DynamicTheme, Navigation, NotesListPage/Screen, NotesViewModel, NotesRepository) with editor/sync classes as post-startup, and startup-prof.txt carries the startup subset for primary-DEX layout. Verified: :notes:assembleRelease succeeds and the APK contains assets/dexopt/baseline.prof (4677 bytes) and baseline.profm; apkanalyzer shows the startup classes in the single primary DEX. :notes lint, lintVitalRelease and testDevUnitTest pass.
Diff
build-logic/src/main/kotlin/common-conventions-app.gradle.kts
diff --git a/build-logic/src/main/kotlin/common-conventions-app.gradle.kts b/build-logic/src/main/kotlin/common-conventions-app.gradle.ktsindex e1a8cdbd3f..8394b98167 100644--- a/build-logic/src/main/kotlin/common-conventions-app.gradle.kts+++ b/build-logic/src/main/kotlin/common-conventions-app.gradle.kts@@ -560,6 +560,21 @@ dependencies { // Kotlin Serialization implementation(libs.kotlinx.serialization.json) + // Baseline + Startup Profiles (Android App Performance Score): every app+ // ships the ProfileInstaller runtime. An app opts into profiles by+ // dropping human-readable rule files at src/main/baseline-prof.txt+ // (methods/classes ART should AOT-compile) and src/main/startup-prof.txt+ // (startup classes AGP orders into the primary DEX); AGP compiles them+ // into assets/dexopt/baseline.prof / startup.prof in release APKs with+ // no per-app build wiring. Automated generation: add a Macrobenchmark+ // :baselineprofile module (androidx.baselineprofile plugin) that drives+ // cold start + critical journeys on a device and regenerates those files;+ // generation needs a device, authoring the HRF files does not. Reference+ // profile: notes/src/main/baseline-prof.txt + startup-prof.txt (cold-start+ // path). Verify a shipped profile with:+ // apkanalyzer dex packages <apk> / unzip -l <apk> | grep dexopt+ implementation(libs.androidx.profileinstaller)+ implementation(project(":library")) implementation(project(":library:ui")) // Repo-wide logging facade (com.vayunmathur.library.log.Log). Direct
gradle/libs.versions.toml
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 4964259be1..7c5594b726 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -96,6 +96,7 @@ carApp = "1.9.0-alpha03" # AndroidX – instrumentation test (androidTest). Shared by every app's # launch-no-crash test plus :library:map's on-device renderer harness; # they are three independently versioned artifacts, not one train.+profileinstaller = "1.4.1" androidxTestRunner = "1.7.0" androidxTestCore = "1.7.0" androidxTestExtJunit = "1.3.0"@@ -336,6 +337,9 @@ androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "a # Versioned by the Compose BOM. androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-test-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "uiautomator" }+# Baseline/Startup profile runtime installer: compiles a shipped baseline.prof+# on install on Android versions where ART does not do it itself.+androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version.ref = "profileinstaller" } # Google libraries protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobufVersion" }
notes/AGENTS.md
diff --git a/notes/AGENTS.md b/notes/AGENTS.mdindex a379be9f80..a9c727297d 100644--- a/notes/AGENTS.md+++ b/notes/AGENTS.md@@ -58,6 +58,7 @@ routing, so every entry point is inert on the wrong form factor. ## Key files ### Root — entry + navigation - com/vayunmathur/notes/MainActivity.kt+- src/main/baseline-prof.txt + src/main/startup-prof.txt — cold-start Baseline/Startup Profiles (HRF, hand-authored from the startup classpath; AGP compiles them into the release APK, ProfileInstaller ships via common-conventions-app) - com/vayunmathur/notes/Navigation.kt - com/vayunmathur/notes/Route.kt ### data/ — Room entities + repository
notes/src/main/baseline-prof.txt
diff --git a/notes/src/main/baseline-prof.txt b/notes/src/main/baseline-prof.txtnew file mode 100644index 0000000000..2c95926c47--- /dev/null+++ b/notes/src/main/baseline-prof.txt@@ -0,0 +1,32 @@+# Baseline profile for :notes cold start (human-readable HRF).+# Generated by hand from the known startup classpath (no device was used):+# MainActivity -> MaActivity shell -> DynamicTheme -> Navigation ->+# NotesListPage/Screen -> NotesViewModel -> NotesRepository (Room opens lazily).+# Flags: H=hot (AOT compile), S=startup, P=post-startup, L=class.+# Regenerate on a device with a Macrobenchmark baselineprofile module driving+# cold start + open-note + editor journeys when one is added; until then keep+# this list in step with the startup path above.+Lcom/vayunmathur/notes/MainActivity;+HSPLcom/vayunmathur/notes/MainActivity;-><init>()V+Lcom/vayunmathur/notes/NavigationKt;+Lcom/vayunmathur/notes/Route;+Lcom/vayunmathur/notes/ui/NotesListPageKt;+Lcom/vayunmathur/notes/ui/NotesListScreenKt;+Lcom/vayunmathur/notes/platform/NotesViewModel;+Lcom/vayunmathur/notes/platform/NotesViewModelFactory;+Lcom/vayunmathur/notes/data/NotesRepository;+Lcom/vayunmathur/notes/data/Note;+Lcom/vayunmathur/notes/data/NoteBlock;+Lcom/vayunmathur/library/ui/MaActivity;+Lcom/vayunmathur/library/ui/StartupTiming;+Lcom/vayunmathur/library/ui/StartupMarks;+Lcom/vayunmathur/library/ui/FirstFrameGate;+Lcom/vayunmathur/library/ui/DynamicThemeKt;+Lcom/vayunmathur/library/ui/AppScaffoldKt;+Lcom/vayunmathur/library/ui/LazyListScaffoldKt;+Lcom/vayunmathur/library/ui/FullyDrawnKt;+Lcom/vayunmathur/notes/ui/NotePageKt;+Lcom/vayunmathur/notes/ui/NoteScreenKt;+Lcom/vayunmathur/notes/data/NoteDatabase;+Lcom/vayunmathur/notes/platform/NoteImageStore;+Lcom/vayunmathur/notes/sync/WearNotesSync;
notes/src/main/startup-prof.txt
diff --git a/notes/src/main/startup-prof.txt b/notes/src/main/startup-prof.txtnew file mode 100644index 0000000000..8150b6422d--- /dev/null+++ b/notes/src/main/startup-prof.txt@@ -0,0 +1,17 @@+# Startup profile for :notes (DEX layout optimization).+# Classes needed between process start and the notes list being interactive,+# in dependency order as far as it is known. AGP places these in the primary+# DEX so cold start avoids secondary-DEX class loading. Keep this a subset of+# baseline-prof.txt: only the cold-start path, no editor/sync classes.+Lcom/vayunmathur/notes/MainActivity;+Lcom/vayunmathur/library/ui/MaActivity;+Lcom/vayunmathur/library/ui/StartupTiming;+Lcom/vayunmathur/library/ui/StartupMarks;+Lcom/vayunmathur/library/ui/FirstFrameGate;+Lcom/vayunmathur/library/ui/DynamicThemeKt;+Lcom/vayunmathur/notes/NavigationKt;+Lcom/vayunmathur/notes/ui/NotesListPageKt;+Lcom/vayunmathur/notes/ui/NotesListScreenKt;+Lcom/vayunmathur/notes/platform/NotesViewModel;+Lcom/vayunmathur/notes/data/NotesRepository;+Lcom/vayunmathur/library/ui/FullyDrawnKt;