typing kotlin code in intellij/AS is sooo slow. :s...
# random
c
typing kotlin code in intellij/AS is sooo slow. 😭 i have an m1 max with 64GB. whyyyyyyy is typing so laggy
e
Do you have extremely large libraries as dependency in your project?
c
Can't really say what qualifies as large. But my projects themselves are like 200kLOC max. Nothing insane.
e
Perhaps you could try increasing the heap size to 2048m? https://www.jetbrains.com/help/idea/increasing-memory-heap.html#toolbox
a
I have an intel 2019 with 8g heap. A project with. 100+ modules . Autocomplete pretty laggy too
a
I have somewhat around 20 - 30 gradle modules, a boatload of dependencies (more than 50 I can tell). Typing ain't lagy, but code completion and syntax highlighting takes too long to kick in. Nowadays it might take even a full minute to do so
c
Well. At least it's not just me. A full minute for syntax highlighting and code completion is a regular occurrence.
a
Syntax highlighting is the worst
And worst is when the file has a compile issue, it doesn't highlight anything until i fix the last syntax error
That’s what I mean, is auto complete is really slow
j
Typing is not laggy here on normal M1 Just to make sure, is everything running with Apple Silicon architecture? Check Activity Monitor if some JDK or maybe IDE itself started with Intel architecture. It was in the past easier to download Intel version before UI on website got better.
c
Yep. I don't even have rosetta installed 😄
But anyway. SOunds like it's not just me. Which is good. They keep saying the new frontend compiler will fix it. But in the latest blog post about this they said the new FE compiler basically has "only" a 2x improvement. A 2x improvement over 1 minute for code completion is still really slow and so I must be missing something right? Do the kotlin devs at jetbrains have this sort of slowness too? @Alexey Belkov [JB] sorry for the ping, but I know you helped me out in the past with getting a proper bug report submitted, but is this something that any of us can help with reporting or are basically all of these issues "known" at this point? There has to be some plugin or some memory setting we can configure that would speed this up.
m
To be fair, they mentioned 2x improvement in the whole compilation chain but 4x on the frontend. But how will it transfer to the eventual to the IDE plugin is yet another thing. Maybe switching to from JRE 11 to 17 in the IDEA will somewhat help?
c
@mcpiroman good point. I mustve misread that. Thanks for clarifying. I might try moving to 17. I'll try anything at this point. I thought my company buying me a $4,000 laptop would help... but not really. lol
a
couple of things to try: increasing IDE memory to over 16GB, disabling any nonessential plugins (ktlint, sonarqube, or anything that could analyze your code along with the IDE) , and unloading unused modules
a
I have my memory settings to 10GB, IDEA my idea hardly gets past 4GB on normal days, while observing it has maxed out to 9GB which is why I concluded that this was not a memory problem at all.
d
IntelliJ is just really, really, REALLY slow on large-ish Kotlin projects. It becomes totally unusable. I've found no real solution to this except chunking your project up into smaller compilation units (modules). Hoping for the best here but to be honest the feeling I get is that IDEA is not ready for Kotlin development at corporate scale. 🤔
1
I have a basic 20 kLOC project that takes about 10 minutes(!) to compile whereas one of our Java projects of double the size compiles in seconds. 🤷‍♂️
a
comparing just at a language level between two projects is not completely valid i think. it really depends on those two projects - does kotlin use kapt? does java only use reflection? build chain, compier deps, and modularization used will skew those.
do they both use same gradle setup?
also we're talking about ide code completion, navigation, etc. not compile times
c
FWIW I never had issues with IDE speed with java. Kotlin is always the issue.
a
ah, certainly gotta be the compiler FE, and probably why they decided to work on fixing it
using a semi large typescript project, code completion was pretty fast. also in past smaller kotlin projects were usually pretty quick....miss those days where my hands would cramp with my typing speed
😂 1
e
I work on a ~350kLOC pure Kotlin project without much issue. it is split up into ~300 modules, perhaps no single module being very large has an impact?
(not related to the IDE, the single biggest performance improvement I got was switching from macos to Linux, even with a similarly-specced machine, because filesystem operations are simply faster)
some of my coworkers saw improvement by bypassing SIP and gatekeeper, some didn't. https://news.ycombinator.com/item?id=23273247
c
I think one big issue here is that ist not documented what exactly makes editing kotlin files so slow in idea, why it is acceptable for some project and totally unacceptable slow for others. Also maybe some people are just used to it being so slow. Maybe idea should just automatically submit a performance snapshot when code completion takes more than 1 second.
💯 1
a
what exactly makes editing kotlin files so slow in idea
actually we described some reasons of slow performance that may be fixed by a user. You can see them here: https://blog.jetbrains.com/kotlin/2021/06/simple-steps-for-improving-your-ide-performance/#tips And also sometimes our perf. engineers find abuse of star imports in files. If you use just only some (not much) declaration from a package - it’s better to define them in imports block directly, and not use * for the whole package. What about other reasons - they usually lies somewhere in interaction with indexes or compiler resolve. And there’s no much ideas how it can be improved on user side. For IntelliJ Kotlin plugin team IDE performance is top-1 priority and most of our current tasks are about its improving.
c
that article seems very general and not tied to kotlin performance. I recently edited a pure java project in idea and its just so snappy. if ide performance is no1 priority what do you think about automatically submitting a perf snapshot when autocompletion takes more than 1 second? Idea already treats a non responsive ui as a bug, so why not treat that as a bug too?
c
Interesting. * in imports can cause slowness? I wonder if there's an easy way to catch/prevent *
e
I believe ktlint and detekt both do, in their default configuration
a
we have a ktlint and detekt
and thus no star imports anywhere
c
@agrosner and you still have really slow auto complete right?
a
Yeah it's brutal
Most of time faster to just type without waiting. And some files just completely fail to syntax highlight / autocomplete if there's any compile issue in the file
😭 1
a
Same here. I now even have memorised most of my import statements, I don't wait for auto complete anymore.
1
😭 1
a
@Colton Idle It’s impossible to say is this a known issue or not, unfortunately. It’s better to report issues like this to YouTrack with as much information to diagnose as possible. At least the CPU snapshot, see https://intellij-support.jetbrains.com/hc/en-us/articles/207241235-Reporting-performance-problems
c
Thanks Alexey. I will try to file a bug here with the instructions you sent and i hope others in this thread can do the same. cheers
@Alexey Belkov [JB] is there any way to diagnose why a file is essentially stuck "Analyzing"? Here's my AS activity monitor
💯 1
I captured a cpu
.snapshot
as recommended above, but I don't know how to open/read the file. 1. I would love to open the file and read it myself to know if theres somethign small/stupid its stuck on 2. Before I make a bug report, I want to make sure no personal info is in it
a
You can open such a file with YourKit profiler, for example. For “analyzing”, check IDE logs, there may be some exception from Kotlin compiler.
c
Thank you!