autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.66k stars 116 forks source link

Stuck in computeActualUsageDebug for many minutes #1186

Open juliocbcotta opened 1 month ago

juliocbcotta commented 1 month ago

Build scan link

Plugin version 1.31.0

Gradle version 8.6

JDK version 21.0.2 (BellSoft 21.0.2+14-LTS)

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 1.9.23

(Optional) Android Gradle Plugin (AGP) version 8.3.2

Describe the bug The task computeActualUsageDebug gets stuck for a long time. This module contains only android resources(images, vector drawables, translations and theme definitions), no code, so I don't understand why it takes so long. It has around 250 files on it and it takes around 5-10 min to run in a M1 machine doing no other heavy compilation. The same task in other big modules with lots of code and dependencies takes way less time. I checked the memory usage in the gradle daemon and it seemed fine (not a lot of GCs happening).

Is there any debug flag I could pass to the build that could give me infos about what is happening?

Expected behavior To run the analysis faster?

Additional context My gradle.properties has, if I remove this flag, computeActualUsageRelease also gets stuck. dependency.analysis.android.ignored.variants=release

autonomousapps commented 1 month ago

Thanks for the issue. My first thought was memory, and it still might be the case. Do you have a build scan you can share?

You could use gradle-profiler to profile the build for CPU and memory usage and see what seems to be taking so long. I would run just the task in question to keep the profile useful. I'm happy to take a look if you're willing to share the reports. I have done so in the past.

juliocbcotta commented 1 month ago

hey @autonomousapps , I sent you some data by email a few days ago using your email listed on your profile. Did you check that? I will try to find time for a better analyses if it is not enough.

ParaskP7 commented 1 month ago

👋 @autonomousapps !

I too I am currently experiencing similar issues when running the buildHealth task. I am working on this woocommerce-android open source project and trying to set-up the plugin. It seems to be taking too long, the computeActualUsage* per se. Previously, about a year ago, when I tried running the plugin again, everything worked as expected (much faster).

You will find these changes within the build/dependency-analysis-android-gradle-plugin branch, just in case you would like to clone/pull the repo/branch and experienced it for yourself.

[!NOTE] Pulling this branch you will also notice that in order to make buildHealth more efficient, I had to exclude all other variants using a custom configuration (commit). This is because the dependency.analysis.android.ignored.variants=variant1,variant2,variant3 flag is not working as expected for this project. I'll leave another comment about it within #945.


Build scan link (GRADLE_PROFILER) https://gradle.com/s/j73i5752pltng

Plugin version 1.32.0

Gradle version 8.2.1

JDK version openjdk 17.0.11 2024-04-16

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 1.9.22

(Optional) Android Gradle Plugin (AGP) version 8.1.0


You could use gradle-profiler to profile the build for CPU and memory usage and see what seems to be taking so long.

I am also providing you with a profile.log report, which I generated running the below gradle-profile command, you'll find the build scans links within:

gradle-profiler --profile buildscan --project-dir ../woocommerce-android buildHealth

profile.log


I hope all this info will somewhat help you with your investigation, and thank you! 🙏

autonomousapps commented 1 month ago

hey @autonomousapps , I sent you some data by email a few days ago using your email listed on your profile. Did you check that? I will try to find time for a better analyses if it is not enough.

I did see the email, thanks!

ParaskP7 commented 2 weeks ago

👋 @autonomousapps !

To follow-up on this, today I was trying older versions on the plugin and the problem persisted till version 1.30.0.

Now, that doesn't mean that version 1.29.0 worked, actually this version produced a could not determine the dependencies of task kind of failure (see dependency-analysis-failure-v1.29.0.txt).

But then, version 1.28.0 worked as expected, with the buildHealth task no longer being stuck in computeActualUsage phase for minutes. 🤔


I hope the above will help you somehow and many thanks for all the work with this plugin! 🥇

autonomousapps commented 2 weeks ago

--profile buildscan isn't super userful for investigating this, unfortunately. I need to know what's happening in the CPU -- the build scan is too coarse grained. Can someone run gradle-profiler --profile async-profiler on their project?