Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

KT-24668 - Kotlin DSL 3-4x slower than Groovy DSL on FIRST USE on many simple projects build #902

Open
eskatos opened this issue May 31, 2018 · 10 comments

Comments

@eskatos
Copy link
Member

eskatos commented May 31, 2018

Groovy DSL ~18s
scenario: first use of largeJavaMultiProject
template: largeJavaMultiProject
performance test results

Kotlin DSL ~75s
scenario: first use of largeJavaMultiProjectKotlinDsl
template: largeJavaMultiProjectKotlinDsl
performance test results

Both with:

  • clean checkout
  • empty local caches
  • cold daemon

The compilation of the 500 build scripts of the example build by the Kotlin compiler dominates wall clock. Note that script compilation is not parallelized in Kotlin nor Groovy.

See the upstream KT-24668 investigation issue.

@JLLeitschuh
Copy link
Contributor

Is this also true with importing into the IntelliJ?

@hansd
Copy link
Member

hansd commented May 31, 2018

It might be helpful to do a similar measurement with the following parameters:

  • warm daemon
  • everything has been compiled before
  • a change to buildSrc that in my understanding will trigger a full recompile.

@eskatos
Copy link
Member Author

eskatos commented Jul 9, 2018

Ways to improve the situation include:

@joshuadeguzman
Copy link

Hi @eskatos , I am curious if this issue was already resolved?

@eskatos
Copy link
Member Author

eskatos commented Jun 13, 2019

@joshuadeguzman first use is still that slower, dominated by the Kotlin compiler. It could still benefit from parallel compilation and incremental changes to build logic could still benefit from compilation avoidance as linked above.

@joshuadeguzman
Copy link

Great! Thank you for the confirmation @eskatos .

@kaushalyap
Copy link

@eskatos Any plans to get this done (seems repo is not active)? I think this may be the reason Android Studio Kotlin DSL support lagging behind?

@eskatos
Copy link
Member Author

eskatos commented Oct 1, 2019

We have two performance tests running respectively the Groovy DSL and the Kotlin DSL on the same large project for a first use use case:

Those links (use Login as guest) are for current master branch of Gradle that is ~6.0.

There we can see that the Kotlin DSL build is still ~3x slower than the Groovy DSL build on first use.

Then, on repeated use without changes, this performance test compares Groovy DSL vs. Kotlin DSL:

In that use case, we can see that the Kotlin DSL build is ~10% slower than the Groovy DSL build.

That's it for the current state of affairs.

Now on how to make the situation better, my #902 (comment) above still stands.

In any case the best bet to make the situation better across all use cases would be for the Kotlin compiler itself to get faster, this is in JetBrains hands.

Otherwise, compiling the scripts in parallel gradle/gradle#9225 could also make all use cases faster (most probably benefiting to the Groovy DSL too 😃) but this isn't trivial and will require deep changes in Gradle. IOW it'll take time.

The most probable next step is some form of compilation avoidance for Kotlin DSL scripts gradle/gradle#9224 that will make the change in build logic use case faster (not scheduled for now but I'll push for it).

I hope the above clarifies the situation.

@kaushalyap
Copy link

@eskatos Thanks for the detailed response!

@mochadwi
Copy link

mochadwi commented Feb 19, 2020

thanks for the detailed explanations @eskatos & an alternative workaround

EDITED:

  • after reading from below youtrack, looks like there's a performance improvement for Kotlin 1.3.61

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants