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
The Kotlin and Groovy DSLs should have similar performance characteristics #15886
Comments
thanks for the benchmark @eskatos Any issues filed on the youtrack issue tracker against Kotlin compiler related to kotlin dsl performance? if so please link the associated issues. |
random thoughts from a lambda Kotlin dev: It could be a useful addition to add a variant for kotlin and groovy on this benchmark: org.gradle.vfs.watch=true
kapt.use.worker.api=true
kapt.include.compile.classpath=false
org.gradle.parallel=true
org.gradle.caching=true (btw its unclear whether kapt.include.compile.classpath=false is still useful in 6.8 given compiler avoidance) Also worth exploring would be to benchmark with the new compiler backend and the new compiler frontend finally setting a continuous benchmark (in CI) of this would be useful for showing progress and for catching regressions! note1: I cannot see the linked benchmark results,
https://docs.gradle.org/nightly/userguide/performance.html#compiler_daemon note3: minor: I wonder whether using the Kotlin BOM incurs a slowdown vs not using it |
maybe worth adding one more case, change build.gradle file (not src), I think it even more common comparing to buildSrc |
Guest access to our CI is currently temporarily disabled, it'll be enabled back soon. @kaushalyap there's already a link to https://youtrack.jetbrains.com/issue/KT-24668. I'm not aware of other Youtrack issues related to this. @LifeIsStrange this issue is about the Gradle Kotlin DSL performance, not the Kotlin Gradle Plugin performance in general. For instance KAPT is out of the picture. Also, the embedded Kotlin compiler used internally by the Gradle Kotlin DSL isn't ready to be moved to the new compiler infrastructure. The numbers above represent the default Gradle user experience which is a good thing. @gildor yes this use case is missing from the set above and I agree it's very common. We started with the |
@eskatos I know about that issue. Hope Kotlin team close that issue in the first half of this year with the movement to new compiler as mentioned in the roadmap, so android devs can move to kotlin dsl for android projects without increased build time. |
@kaushalyap This is the new backend of the compiler, it has nothing to do with compilation speed. You probably talk about the new frontend of the compiler, which promises up to 2 times faster compilation, but it will not be ready in 6 months, in the best case it would be some experimental version available this year |
I wonder if this is still an issue. Gradle 7 has been out for a while and it boosts massive performance improvements for Kotlin DSL script compilation. An updated benchmark would be very appreciated :). |
Those benchmarks are automated and constantly run against Gradle as it evolves. You can browse the results on our CI, e.g. here https://builds.gradle.org/buildConfiguration/Gradle_Master_Check_PerformanceTestSlowLinux_Trigger/46861573?buildTab=report_project55641_Performance Here I captured the current state:
Things indeed got better since Gradle 7, especially the non-abi change scenarios. The performance isn't similar though. |
Could you explain what ABI / Nop-ABI means |
@rowi1de sure thing! ABI stands for Application Binary Interface. An ABI change is a change that modifies the ABI, iow the "public api" that downstream consumers compile against. All consumers need to be recompiled. A non-ABI change is a change that does not modify the ABI, iow only touches the "private implementation". Consumers compilation can be skipped. |
@blundell that individual run got garbage collected, here you can see the list of runs https://builds.gradle.org/buildConfiguration/Gradle_Master_Check_PerformanceTestSlowLinux_Trigger?branch=master&buildTypeTab=overview&mode=builds |
I think I've done this right :D Gradle 7.4/7.5 numbers
Info from 11th Feb 2022 CI run For example, from the performance tab, I looked up the buildSrc abi change and took the first row, here. |
@blundell , could you please explain the difference calculations? In the previous results: 21s VS 4.3s - 4.8x faster. I get it. |
@eugene-krivobokov Sorry about that, wrong equation. Updated to calculate as a percentage. |
does it private? seems unable to open with my team city account |
Is there any sort of break down on what goes in "first use" and why it is so much slower? |
@liutikas I guess "first use" is slower with Kotlin DSL as that needs to be compiled. |
build.gradle.kts configuration files was replaced by build.gradle # Ref: gradle/gradle#15886 (comment)
* build: speed up build time (part 1) # Ref: https://habr.com/ru/company/yandex/blog/678786/ * build: speed up build time (part 2) build.gradle.kts configuration files was replaced by build.gradle # Ref: gradle/gradle#15886 (comment)
Here are numbers updated for Gradle 8.0
This is not looking great. The upgrade to Kotlin 1.8 in Gradle 8.0 caused a regression in Kotlin DSL script compilation. Also those scenarios are not the best at representing reality as they don't even use the The gap is not just the Kotlin compiler performance change. Groovy got faster. There are also some changes due to other areas of Gradle at play. But there definitely was a performance regression with 1.8 in our isolated tests. We are discussing this with the compiler team and will try to mitigate. |
@eskatos could you please check gradle 8.1 performance |
Expected Behavior
The Kotlin and Groovy DSLs have as much as possible similar performance characteristics.
IOW there's no outlier use case for which the performance characteristics make using one or the other DSL a penalty.
Current Behavior
What follows is the current state of affairs as Gradle 6.8 for four use cases:
The data below comes from performance tests run on the Gradle CI. Those tests use a build with a large number of projects and build scripts, the build scripts being rather simple, and they run on both the Groovy and Kotlin DSL for comparison.
buildSrc
abi changebuildSrc
non-abi changeContext
The numbers above are, at the time of writing, for current
release
branch of Gradle that is the upcoming 6.8.1. See:Use Login as guest and note that these links will eventually get outdated.
This issue is a follow up to gradle/kotlin-dsl-samples#902 which resides in an archived repository.
One of the reasons the Kotlin DSL is slower when it is is the time it takes to the Kotlin compiler to compile the scripts.
See https://youtrack.jetbrains.com/issue/KT-24668
The text was updated successfully, but these errors were encountered: