After upgrading to Kotlin 2, no performance improv...
# getting-started
r
After upgrading to Kotlin 2, no performance improvement in build time, it actually builds slower. Anyone saw improvements? Before Kotlin 2: https://github.com/wizbii/CinematicJourney/actions/runs/9269334388 After Kotlin 2: https://github.com/wizbii/CinematicJourney/actions/runs/9272294992 On the other hand, the upgrade was a bliss. Apart from the change of Compose plugin, nothing had to change, no migration needed, no problem with existing dependencies built against 1.9. Very nice!
👀 1
a
hi, just to be clear, can you state specifically what was slower? I can see that the CI/Test job was 10m 19s before and 13m 4s after. I just want to double check I'm looking at the right thing :)
I can see that the Setup Gradle step took 34 seconds before, and 1m 7 after. So that accounts for some of the time, but I also wonder if that's because the network or CI instance was slower, which could account for some of the slower time...
It also looks like the second K2 run was the first run K2 run on CI? In which case, it's going to be slower because K2 needs to download new dependencies.
☝️ 1
It'd be worth adding
--scan
to the Gradle command, to create Build Scans. Then the builds would be measured, and we could see specifically which parts have changed and are slower/faster.
r
You're right, just comparing 2 builds does not really mean anything, I just expected to see some really clear changes based on the various x1.8 or x2 announcements I saw, someone even wrote that there would no longer be time for coffee breaks 😄 I didn't think about the Gradle cache. Also, in this kind of project you can't just change the Kotlin version without changing other things so the benchmarking tools that were made available are of no use
I also don't know the details of what would make K2 faster, and I usually compare build times using "clean state to full build", ignoring cache. Maybe the improvements are mostly better cache? I mean, I know it's basically a rewrite but right now I don't see any difference yet, either when Gradle builds or in the IDE
a
Pass - hopefully someone else can answer :)
r
I triggered another build, now that K2 built once and the CI supposedly stored the Gradle cache correctly, maybe I'll see improvements there
🤞 1
a
But I see that you haven't enabled Gradle Build Cache! You've got to enable it! Your builds will be so much faster, especially when switching branches. Put
org.gradle.caching=true
in your
gradle.properties
r
Isn't that the cache in the user home? I don't really want another place to clear every time everything stops working
a
yes, it is. But build cache is really stable.
you can always disable it, if necessary :)
r
Something fucking up my environment twice a week is not stable
a
have you experienced that kind of problem with build cache?
r
I know that I regularly need to run
./gradlew clean
and
./gradlew --stop
and delete
.gradle
folder, then invalidate IDEA caches and restart it to clear broken environment
a
hmmm that sounds like a serious problem
I certainly used to have to do that, years ago, but these days it's much more stable
r
Are you using Kotlin/Native? I always had problems with it
a
yes, although I'm not doing iOS dev
r
I don't have this kind of issues in non-multiplatform projects
a
which, going back to the original topic on K2 speeds- looking at your projects and tasks I would guess that most of the time is spend doing Android/iOS compilation/linking, which will overshadow the K2 compilation speed gains.
Have you ever made a YouTrack report for IntelliJ?
r
Well I don't know what K2 impacts, but if it's only
compileKotlin*
tasks, yeah that's not where the build takes all that time
I don't have time to report all the issues I get, there are too many all the time. I try to report when it's easily reproducible, it's one of the reasons I made the project I linked
kodee sad 1
a
so yeah, the Kotlin compiler will affect Kotlin compilation tasks. But there were other improvements/fixes in non-compilation areas too that should help generally. (Like Kotlin Gradle Plugin caches better)
It really sucks that you have problems all the time. To me, that sounds really really unusual. So I really want to look into it, because I bet it's something that we can fix and then the problems will go away :)
anyway, the minimum recommendation I have is to add
--scan
to the CI Gradle commands. Because I see that the tests took 16 minutes now 🤔
r
Yeah but I don't know what to report, I'm a developer and I don't like to receive vague reports either. For all I know, sometimes everything gets red in IntelliJ IDEA, and/or Gradle just fails the build for no reason, and after clearing everything it just works again, without changing the actual code 🤷‍♂️ What would anyone do with such a report
Right, but notice how all the desktop builds were clearly faster, all 3 of them. I think they're the platforms where there is less "not compiling Kotlin" tasks
very nice 1
a
In your place, I'd be so annoyed I'd want it fixed haha. I'd create a new YouTrack issue with a screenshot, link to your repo (with a commit ID) add the IDEA version, and upload idea.log (you can set the visibility as private).
r
Just now, I opened the project in IDEA for the millionth time and it just "forgot" the project, all the files disappeared from the left panel, and it showed a notification like "Gradle build file found" with a Load Gradle Project button. Wtf? Again, I just clicked the button and it worked, but in the last few years I kinda felt more and more that IDEA is becoming like the good old days of Eclipse…
😱 1
I have an issue per hour I can't just report them
a
you're right, taking the time to report everything would be too much. But I would guess that all of these issues have a common cause, and it's just a case of finding out what the root problem is.
if you reported 1 issue with the idea.log attached, that might be able to find it, but the JetBrains support wizards would be able to help more than me :)
anyway - back to K2. Like you said, the desktop builds are faster, which is cool. (Taking screenshots because GitHub builds eventually disappear. K2 is on the left, K2-re-run is on the right)
256 Views