Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable DEX layout optimizations #1020

Closed
wants to merge 5 commits into from

Conversation

SimonMarquis
Copy link
Contributor

@SimonMarquis SimonMarquis commented Nov 6, 2023

  • Disable minification
  • Enable android.experimental.r8.dex-startup-optimization
  • Copy Move app/src/main/baseline-prof.txt to src/main/baselineProfiles/startup-prof.txt

Closes #992

- Disable minification
- Enable `android.experimental.r8.dex-startup-optimization`

Closes android#992
…eProfiles`

to avoid duplicating them.
DEX layout optimization looks at `baselineProfiles` sourceSet by default, and this prevents manually configuring the `R8Task`.
@keyboardsurfer
Copy link
Member

Thanks for spinning this up, @SimonMarquis! This change also requires AGP 8.2 as well as calling includeInStartupProfile = true in the most basic startup baseline profile generator.

@SimonMarquis
Copy link
Contributor Author

SimonMarquis commented Nov 6, 2023

@keyboardsurfer it seems like R8Task currently looks for a app/baselineProfiles/startup-prof.txt by default.
There are at least 4 solutions for that:

  • duplicate app/src/main/baseline-prof.txt to src/main/baselineProfiles/startup-prof.txt
  • move app/src/main/baseline-prof.txt to src/main/baselineProfiles/startup-prof.txt
  • create a symlink between app/src/main/baseline-prof.txt and src/main/baselineProfiles/startup-prof.txt
  • configure the R8Task

What would be the best option here?

This change also requires AGP 8.2

Do you mean it won't work on the current AGP 8.1.2? Because it does compile correclty and seems to use the startup-prof.txt when provided.

as well as calling includeInStartupProfile = true in the most basic startup baseline profile generator.

ACK, done in aeac096

@keyboardsurfer
Copy link
Member

The startup-prof.txt will be generated from the generator which has includeInStartupProfile = true.
In the long run we want to fully remove the source files and rely on the baseline profile Gradle plugin to generate fresh profiles for each release.

@SimonMarquis
Copy link
Contributor Author

The startup-prof.txt will be generated from the generator which has includeInStartupProfile = true.

Indeed, running :benchmarks:connectedDemoBenchmarkAndroidTest leads to a startup-prof.txt being generated (extracted from logcat)

2023-11-06 22:11:59.015 23686-23703 Benchmark               com....apps.nowinandroid.benchmarks  D  Moving /storage/emulated/0/Android/media/com.google.samples.apps.nowinandroid.benchmarks/BaselineProfileGenerator_generate-startup-prof.txt to /sdcard/Android/media/com.google.samples.apps.nowinandroid.benchmarks/additional_test_output/BaselineProfileGenerator_generate-startup-prof.txt
2023-11-06 22:11:59.029 23686-23703 Benchmark               com....apps.nowinandroid.benchmarks  D  Pull Baseline Profile with: `adb pull "/storage/emulated/0/Android/media/com.google.samples.apps.nowinandroid.benchmarks/BaselineProfileGenerator_generate-startup-prof-2023-11-06-21-11-59.txt" .`
2023-11-06 22:11:59.037 23686-23703 Benchmark               com....apps.nowinandroid.benchmarks  D  Moving /storage/emulated/0/Android/media/com.google.samples.apps.nowinandroid.benchmarks/BaselineProfileGenerator_generate-startup-prof-2023-11-06-21-11-59.txt to /sdcard/Android/media/com.google.samples.apps.nowinandroid.benchmarks/additional_test_output/BaselineProfileGenerator_generate-startup-prof-2023-11-06-21-11-59.txt

Unfortunately, nothing is being actually generated on my device 🤷 the directories do not exist...

In the long run we want to fully remove the source files and rely on the baseline profile Gradle plugin to generate fresh profiles for each release.

Does that mean the release process will need to spawn an emulator and run the tests before compiling/packaging the app? (this might be hard to implement correctly and reliably)

@keyboardsurfer
Copy link
Member

Does that mean the release process will need to spawn an emulator and run the tests before compiling/packaging the app? (this might be hard to implement correctly and reliably)

This is best done with the baseline profile gradle plugin. It'll take care of the entire process.

Unfortunately, nothing is being actually generated on my device 🤷 the directories do not exist...

This is really strange. Which device are you using? Does it work when using a Gradle Managed Device instead?

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.

[Bug]: Dex Layout reordering requires non-minified benchmark build
2 participants