android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
15.92k stars 2.81k forks source link

Apply App startup library #1493

Closed Jaehwa-Noh closed 3 weeks ago

Jaehwa-Noh commented 4 weeks ago

What I have done and why

Apply App startup library to optimize startup time.

I think the StartupBenchmark_startupPrecompiledWithBaselineProfile is the main factor. See the StartupBenchmark_startupPrecompiledWithBaselineProfile's median, It reduces 5%(1,769.8 -> 1,680.1) startup time.

StartupBenchmark_startupPrecompiledWithBaselineProfile

Before min median max
timeToFullDisplayMs 701.6 1,769.8 1,924.9
timeToInitialDisplayMs 448.0 566.5 676.9
Startup min median max
timeToFullDisplayMs 759.7 1,680.1 1,777.3
timeToInitialDisplayMs 496.0 558.7 660.6

StartupBenchmark_startupWithoutPreCompilation

Before min median max
timeToFullDisplayMs 2,173.6 2,255.0 2,475.4
timeToInitialDisplayMs 570.0 604.4 770.7
Startup min median max
timeToFullDisplayMs 2,120.6 2,186.8 2,333.1
timeToInitialDisplayMs 581.5 632.0 759.7

StartupBenchmark_startupWithPartialCompilationAndDisabledBaselineProfile

Before min median max
timeToFullDisplayMs 1,613.9 1,700.4 1,857.5
timeToInitialDisplayMs 490.2 561.3 668.8
Startup min median max
timeToFullDisplayMs 1,483.5 1,723.0 1,919.9
timeToInitialDisplayMs 439.7 576.1 669.0

StartupBenchmark_startupFullyPrecompiled

Before min median max
timeToFullDisplayMs 1,758.4 1,924.0 2,098.2
timeToInitialDisplayMs 617.4 682.1 907.3
Startup min median max
timeToFullDisplayMs 1,692.9 1,775.5 2,039.0
timeToInitialDisplayMs 577.1 661.8 794.9
SimonMarquis commented 4 weeks ago

AppStartup is no magic. Here, it even increases the complexity because more code needs to be executed. The main goal of this library is to merge ContentProviders (which are heavy objects to create) into a single one. The metrics displayed here do not show any meaningful improvement, and the new API choices are questionable 😕

Jaehwa-Noh commented 4 weeks ago

Thanks for your comment. Yes, I know the app startup library isn't magic. As you said, this is for expensive object initialization. Initialize as fast as possible as app is starting up. Actually I disappoint from results, it improve a little bit the startup time. It looks like not expensive to initialize the ProfileVerifierLogger.

I would just. do one more test manual initialize WorkManager, then if there's no improved results then this, I will consider close this PR.

Jaehwa-Noh commented 3 weeks ago

It seems no different even apply custom initialize WorkManager. I close this PR.