How can I speed up compilation (Java & Kotlin)?

Answered

For teaching I livecode lots of small programms in class, modifying and re-running them dozens of times during a lesson. I used to use Eclipse for this where recompilation is *instantaneous* for such small programs. For slightly more advanced progams *hot reload*, in particular, is a great feature when compilation is fast and students can see the behaviour of the program change immediately.

IntelliJ, on the other hand, takes at least 2-4 *seconds* for (re-)compiling even the simplest "hello world" programs and sometimes substantially longer. And, although I love the great features of IntelliJ, this is pretty much a show stopper for teaching, analogous to having a several seconds pause in a conversation every few sentences!  So, these are my questions:

Is what I experience normal? (I've tried several machines, Windows and Linux, with 8-16 GB RAM, and several versions of IntelliJ, but can see no big difference, never getting down to milliseconds compile time like in Eclipse.) 

Can I do anything to increase the compilation speed? I read somewhere that switching to the Eclipse compiler would help, but I can't confirm that.

If not, can somebody explain why IntelliJ is so slow when compiling incremental changes?  My examples never use a build system, usually a single Java or Kotlin file has to be (re-)compiled. 

Thanks in advance for your help,

Michael

6
9 comments

Hello  Michael,

Do you face the same issue with plain Java project (without Kotlin)? Also please attach screenshot from "File | Settings | Build, Execution, Deployment | Compiler"

 

0
Avatar
Permanently deleted user

Yes, it's the same with plain Java projects. I've just recreated a project with the pre-defined HelloWorld template. First compilation using javac took 18 seconds, after a one letter change 5 seconds, then subsequently gets down to 2.3 seconds. When I change to Eclipse compiler the same thing happens, but the best time I can get is 3.5 seconds. (Numbers from a 4GB RAM Windows machine at work.)

This is not much, of course, but for HelloWorld...

Screenshot attached. I've turned off everything that I thought could cause slowdown.

0

Michael,

Seems there is nothing that could be done to remove that 2 sec delay.

Feel  free to create request on YouTrack: http://youtrack.jetbrains.com/issues/IDEA.

 

0

I'm really surprised there is not more discussion about this, considering IntelliJ is used mainly in JVM-based languages, primarily Java. Despite the fact that my machine is within top-line (2017 MacBook Pro : 16G RAM, 2.9 Ghz 4 core, SSD), I often find myself waiting for compiler to pick up my change and recompile even the simplest code (as Michael mentioned, even Hello World is taking long)

I've tried to change the resource pattern to include only basic Java-related extensions (*.java + *.class) , increased the heap size from (default) 700M to 1024M and Build project automatically is checked.

I'm also from the Eclipse background, but over past 3-4 years I'm on IntelliJ. I love this product for all sorts of features, but it's a bit sad that the very primary way of how the code gets interpreted from developer to the machine takes long.

0

Does it slow to build or to detect the changes? Automatic compilation is controlled by many options and there are explicit delays involved so that compiler is not invoked on every type.

There are options to control these delays in Help | Find Action | Registry:

compiler.document.save.enabled
compiler.document.save.trigger.delay
compiler.automake.postpone.when.idle.less.than
compiler.automake.allow.when.app.running
0
Avatar
Permanently deleted user

i ues intellji 2020 and my problem is same ..Eclipse is very faster than intellji in compile and Run..i have 2 laptop one Good Resource and one poor Resource 4GB RAM due core pentium Both eclipse java programming for helloworld is very faster than intellji

for example build+compile+result for helloworld.java 

in intellji 2020 is 4s 414 ms but in eclipse 2020 less than 2s.also eclipse use les ram and cpu it very good on 4GB PC without Hanging and sound of CPU cooler

 

0

@Sooonaaal what is your OS? Do you have antivirus.firewall? Please check https://intellij-support.jetbrains.com/hc/en-us/articles/360006298560

If you have antivirus/firewall, try with it disabled or make sure the IDE settings directories IDE installation home, the IDE executable and project files are excluded from the scan.

For big projects increasing builder process heap size could help (Settings (Preferences on macOS) | Build, Execution, Deployment | Compiler | Build process heap size (Mbytes)).

0
Avatar
Permanently deleted user

We are experiencing a similar problem, especially with autocompletion and code analysis 
Is there any other suggestions fo speed things out? 
It's really hard to work this way

0

Roiw Please submit a ticket with the problem details and the CPU snapshot per https://intellij-support.jetbrains.com/hc/articles/207241235.

0

Please sign in to leave a comment.