spring-gradle-plugins / dependency-management-plugin

A Gradle plugin that provides Maven-like dependency management functionality
686 stars 85 forks source link

High CPU usage when identifying local projects in large multi-project builds #289

Closed kazuki-ma closed 3 years ago

kazuki-ma commented 3 years ago

I noticed that adding spring-boot-dependency plugin makes IntelliJ gradle project reloading longer.

In summary, I found 2 major reason.

(I wrote some things in https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/288)

This PR introduces a cache of local project names. (This is the same thing of already done for directDependencies https://github.com/spring-gradle-plugins/dependency-management-plugin/blame/master/src/main/java/io/spring/gradle/dependencymanagement/internal/VersionConfiguringAction.java#L86-L96)

This value must be the same in project global but caching it in VersionConfiguringAction is enough for performance.

AS-IS: .getAllprojects() called every project x configuration x dependency TO-BE: .getAllprojects() called every project x configuration (I'm not sure about this)

Profiler result (n = 1)

Condition:

x Total samples profiler isDependencyOnLocalProject ex isDependencyOnLocalProject (calculated) Reload time on my machine
Before 25,460 12,540 12,920 41s
After 13,042 (-49%) 177 12,865 21s

Frame graph / Before

image

Frame graph / After

image

wilkinsona commented 3 years ago

Thanks very much for the pull request, @kazuki-ma.

kazuki-ma commented 3 years ago

I applied it to my project today and got positive feedback from my colleagues. Thank you @wilkinsona.