Slower builds with transform-api and AGP 8
Gimbergsson opened this issue ยท 6 comments
How frequently does the bug occur?
Always
Description
Hi, I'm working on a project where we use Realm and now when we shifting to AGP 8 and using the transformer-api
version of realm I've noticed and measured that builds is taking a lot longer to finish. For clean builds it takes about 40s-1m more and the same with incremental builds (just commenting out some code).
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
I've measured it like this.
- Run
gradlew clean && gradlew --profile --offline --rerun-tasks :app:assembleDevDebug
which took 5m 28s with10.14.0-transformer-api
and 4m 47s with10.12.0
- Comment some code and run
gradlew --profile --offline :app:assembleDevDebug
which took 1m 57s with10.14.0-transformer-api
version and 52s with10.12.0
Version
10.14.0-transformer-api
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Windows 10
Build environment
Android Studio version: Flamingo | 2022.2.1
Android Build Tools version: 34.0.0-rc3
Gradle version: 8 and 7.4.2
Looking a bit into this. This is the test data from trying to compile all our samples:
./gradlew clean && ./gradlew --offline --profile --rerun-tasks assemble
Realm Java 10.12.0
Gradle 7.3.3
AGP 7.1.0
Java 11
~1 minute and 4 seconds
Realm Java 10.15.1
Gradle 8.1.1
AGP 8.0.0
Java 17
~ 40 seconds
So at least for our samples, it appears faster to use the new transformer APIs.
That said, the performance profile might change depending on the layout of the project, the number of dependencies and modules, and so on.
@Gimbergsson can you provide a bit more context about your project? How big it is it roughly? How many modules does it consist of? How many Realm model classes do you have? How is the Realm logic structured, is it confined to a single module or spread out among many modules?
@cmelchior Thanks for getting back of this issue. The project has 8 modules were one is the app module and 5 of them are library modules the two other are benchmarking and some in-house cli tool. It's has around 1200 Kotlin and 180 java classes with total of 140k lines of code.
Here is list of dependencies, dependency_list.txt
We have 81 tables/realm models which is confined to the app module.
But in my team I'm the only one noticing that the build speed is dramatically slower and I'm the only one using Windows. My team mates too mentioned that they also notices an improvement with the new transformer APIs. So I have a hunch that it might only be for Windows users?
A team member that is using a mac got back and said they too get this now, (probably was like it the whole time).
I also found that that we can provide gradle scans of the builds, which are below.
Clean build | Incremental | |
---|---|---|
old-transformer-api | https://scans.gradle.com/s/iv6267wggi4tw | https://scans.gradle.com/s/gdh64cri6fju2 |
new-transformer-api | https://scans.gradle.com/s/lgzfw5sxrfpoi | https://scans.gradle.com/s/gmdmkplwqqo2u |
Notice that the new-transformer-api is faster on a clean build but more than 2x slower when doing a incremental build (as described in the issue).
Thank you very much for those build scans, that is super valuable ๐
The issue is that our gradle plugin based on the new transformer API does not support incremental builds.
We are currently investigating a solution.
@Gimbergsson We have added support to incremental builds in the following PR #7816 and it will be available in the next minor release. However, if you like to try it out you can do so using the latest snapshot release.