Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Baseline profile - Faster apps in one afternoon

Baseline profile - Faster apps in one afternoon

Seyyed davud hosseiny

December 06, 2024
Tweet

More Decks by Seyyed davud hosseiny

Other Decks in Programming

Transcript

  1. Baseline profile Faster Apps in one afternoon ینیسح دواد دیس

    همانرب سیون دیوردنا رازاب هفاک زا @davud_hosseiny
  2. Story: Bazaar Debug GPU overdraw Memory profiler and leak canary

    Android Studio CPU profiler CPU profiling Memory leaks Overdraw
  3. Story: Bazaar Debug GPU overdraw Memory profiler and leak canary

    Android Studio CPU profiler CPU profiling Memory leaks Overdraw
  4. Performance improvements 40% Faster App startup Why? Casestudy: Play store

    Library load time improvement Uses jetpack compose
  5. Why? “Zomato’s performance gains helped them create a much smoother

    experience. Further UI improvements and caching, reduced the janking too.” “These relatively simple improvements led to a dramatic 21% average reduction in app startup time and a 5% increase in driver sessions. ” Casestudy: Others
  6. Audiences ؟نتسه دیوردنا ناسیون همانرب ایک ؟ندروخ یسنمروفرپ لکشم هب

    ایک ؟نیتفر یلح هار هچ ؟نراد ییانشآ لیافورپ نیال سیب اب ایک
  7. Overview How to Implement? What? How to test? 02 03

    01 What baseline is and how it affects our app How to implement baseline profile? How to test baseline profile
  8. What? List of classes and methods for AOT(Ahead of time)

    complation Improve performance Ship with your app or library
  9. What? Process Slow Start the app .dex Interpret .odex Start

    the app No Interpret Install time .dex .odex Large disk size Android 1.0 Android 5.0 Android 7.0 Install time .dex .odex Baseline profile .dex Start the app Less Interpret .odex .dex Small Disk Size Fast Fast
  10. How To? @Test fun generate() { rule.collect( packageName = InstrumentationRegistry.getArguments().getString("targetAppId")!!

    ) { pressHome() // Start default activity for your app startActivityAndWait() device.wait(Until.hasObject(By.res("movieImage")), 2_000) } } Implement
  11. How To? Implement LazyVerticalGrid( modifier = Modifier.semantics { testTagsAsResourceId =

    true }, ) { items(… Image( modifier = Modifier.testTag("movieImage"), // … ) ) }
  12. How To? @Test fun generate() { rule.collect( packageName = InstrumentationRegistry.getArguments().getString("targetAppId")!!,

    stableIterations = 3, maxIterations = 15, strictStability = false, includeInStartupProfile = true ) { pressHome() // Start default activity for your app startActivityAndWait() device.wait(Until.hasObject(By.res("movieImage")), 2_000) } Implement
  13. private fun benchmark() { rule.measureRepeated( packageName = InstrumentationRegistry.getArguments().getString("targetAppId")!!, metrics =

    listOf(StartupTimingMetric()), compilationMode = CompilationMode.Partial(BaselineProfileMode.Require), iterations = 10, startupMode = StartupMode.COLD, setupBlock = { pressHome() }, measureBlock = { startActivityAndWait() device.wait(Until.hasObject(By.res("movieImage")), 2_000) } ) } How To? Test
  14. private fun benchmark(complationMode: ComplationMode) { rule.measureRepeated( packageName = InstrumentationRegistry.getArguments().getString("targetAppId")!!, metrics

    = listOf(StartupTimingMetric()), compilationMode = complationMode, iterations = 10, startupMode = StartupMode.COLD, setupBlock = { pressHome() }, measureBlock = { startActivityAndWait() device.wait(Until.hasObject(By.res("movieImage")), 2_000) } ) } How To? Test
  15. @Test fun startupCompilationNone() = benchmark(CompilationMode.None()) @Test fun startupCompilationBaselineProfiles() = benchmark(CompilationMode.Partial(BaselineProfileMode.Require))

    private fun benchmark(complationMode: ComplationMode) { rule.measureRepeated( packageName = InstrumentationRegistry.getArguments().getString("targetAppId")!!, metrics = listOf(StartupTimingMetric()), compilationMode = complationMode, // ... How To? Test
  16. How To? Test Time to initial display (TTID): is the

    time it takes to display the first frame of the app's UI.
  17. How To? Implement LazyVerticalGrid( modifier = Modifier.semantics { testTagsAsResourceId =

    true }, ) { // items (… Image( modifier = Modifier.testTag("movieImage"), // … ) ReportDrawn() }
  18. Notes • Non-Google-Play-Store app distribution channels might not support using

    Baseline Profiles at installation. Users of apps installed through these channels don't see the benefits until background dexopt runs—which is likely overnight. • Baseline generation on any rooted device or Android 13 or higher(Macrobenchmark 1.2.0-alpha06). Test on Real device. • Repetitively Update baseline profile. • Mock api requests to have stable generation and test.
  19. RESOURCES Videos • https://www.youtube.com/watch?v=WWdDzX grkmg • https://www.youtube.com/watch?v=yJm5On5 Gp4c Other resources

    • https://developer.android.com/topic/performa nce/baselineprofiles/overview • نیبج قرع