Code completion still very slow in IDEA


#1

We just started a project using Kotlin and after copuple of days of coding I must say code completion slownes is becoming very frustrating. It seem s like 10 times slower then code completion with java.

Is there something we can do to make it faster? Enable/disable some options ?  Any suggestions?
I assume the cause is Kotlin compiler still being much slower then Java compiler. Can we expect improvements on compiler performance soon?

Thanks,
Igor


#2

Is this something that got worse as your codebase grew, or it's always been slow?

For me it is quite fast, I noticed only a small slowdown I’d say and often none at all. I’m on a Core i7 with 16 GB of RAM, SSD disk (MBP).


#3

Kotln codebase is still very small. But we have tons of java dependencies. I am on i5, 8G RAM, in Java project code completition is very fast


#4

I am experiencing the same issue on Android projects. Tested with Android Studio and IDEA 13.1.5, small and medium projects. Java completion works well in the same projects. Plugin 0.9.74, 0.9.223

Syntax highliting also works slow. I didn’t pay attention to this issues with M8.


#5

I have created an issue KT-6135 with a general description about completion perfomance issue in M9. Could you please attach a cpu snapshot (how to take snapshot in IDEA) to it with some short description of your project. You can find the place where completion is slow, start profiling and do some cycles of Ctrl + Space (wait for completion popup is ready) -> Enter -> Ctrl + Z.

Thank you.


#6

Hello, Nikolay The project is a bit modified https://github.com/philipto/Kotime


#7

After a brief look I found found that completion is a bit laggy inside KotimeActivity.onCreate() function. I've updated the issue with mentioning this case. Thank you for the project!


#8

I should have mentioned here that for taking snapshots in Android Studio or Communuty IDEA IDE it's possible to use evaluation version of YourKit Profiler or to try opening your project in recent IDEA Ultimate EAP. Mentioned "how to" has this information but I personaly didn't noticed the paragraph when tried it myself for the first time :)


#9

Things that help performance when we ran into some issues with completion speed:

  1. Move to more current plugin (I'm using 0.9.999 now)
  2. If using Gradle or Maven, generate static project files instead of opening the build.gradle or pom.xml files directly
  3. Disable the Scala plugin (this is good for your health in many ways, but when we used libraries that include Scala code, for example Spark, we had issues with this plugin cooperating)

Some or none of those are possible for you to try, but if you can, see which help and report to the youtrack issue mentioned above.


#10

Thanks for your suggestions! Can you please tell, how to generate static project files? Can someone confirm, that cache invalidation helps?


#11

For static project files in Gradle, add the "idea" or "eclipse" plugins (if using spring prop-deps plugin then use their version of these).  Then there are tasks to generate and merge with project files:

http://www.gradle.org/docs/current/userguide/idea_plugin.html
http://www.gradle.org/docs/current/userguide/eclipse_plugin.html

Basically…

apply plugin: "idea" apply plugin: "eclipse"

then

gradle idea

or

gradle eclipse

And you'll end up with files.  Read the pages above for more details on updating just parts of the projects and how they merge with pre-existing projects.  

If you have old project files from dynamically created projects (from opening build.gradle or pom.xml), you may want to clear them first, not sure how they would collide.

For Maven, there are idea and eclipse plugins as well, but I am not sure if Maven has the same potential slowdown as Gradle has (Gradle was mentioned in the YouTrack issue above, not Maven).  And I haven’t used Maven in 2 years so can’t help much more.  Other than to say “move to Gradle, why are you suffering?!?”


#12

Thank you for suggestion. Unfortunately I can't confirm that completion or error analysis became faster.


#13

I’m running on same slow problem! I’ve basically migrated all java code to kotlin, however the compilation time is super slow even for autocompletition which blocks for a few seconds very often. My project uses many java libs and akka.

I have a multi module project on IntelliJ Ultimate 2017.2.1 + Java 8 + Kotlin 1.1.3-2 + Gradle 3.5 and incremental compilation is checked.

I’m loving kotlin so far and we’re considering it for real. It’s great to write much less code, although it’s really frustrating to have a much slower IDE in comparison to java coding. Is there anything we can do to fix this other than the suggestions above?


#14

I don’t know about compilation speed, but I think speed of code completion and typing has improved in the 1.1.4 EAP versions of the plugin.


#15

A post was split to a new topic: Compilation takes too long