Intellij slowish compiles
During regular java programming i had a feeling intellij was a bit sluggish. After trying some settings (without any improvements) i decided to see how a basic hello world program would compile. When changing a single letter it takes about 2.5 sec to compile. I'm not that inpatient that i regard that as unbearable, but i wondered why this was.
I disabled the anitivirus, since i've seen it making build waaaaay slower. I even installed it on an idle computer with a clean windows (32gb ram, i5, nvme) and pretty much the same results. Both computers using intellij 2020 and 2021 version and have plenty of horsepower i would say.
I looked at the build process and it always does seemingly a lot when chaning only a single letter in the hello world program:
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Searching for compilable files...
Parsing java... [proj]
Writing classes... [proj]
Checking dependencies... [proj]
Dependency analysis found 0 affected files
Updating dependency information... [proj]
Adding @NotNull assertions... [proj]
Adding pattern assertions... [proj]
Running 'after' tasks
javac 11.0.4 was used to compile java sources
Finished, saving caches...
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
Just for comparison i also did the same test on a new netbeans install (which (also?) uses ant if i am not mistaken) and speed wise it flies comparatively. I don't event have to compile, it actually "warns" me that compiling is not needed since it does so in the background, so pressing run instantly runs the application.
I was wondering if somebody could elaborate why intellij is spending 99% of the time on *not* compiling the java file and doing stuff like "Synchronizing output directories" and "Finished, saving caches". Is there any setting to "just compile".
I've mostly been using the 2020 version since last time i checked, 2021 was crazy slow even in basic usage and autocompleting, seemingly caused by the collaboration plugin (iirc).
From what i've found searching, people regards 2.5 sec for helloworld.java (the build in template) normal. It still make me wonder why it needs to do all that stuff and why it cant be turned off.
Please sign in to leave a comment.
The output prints the full cycle of the build. The incremental build IDE feature requires collecting the dependencies information and some analysis. In medium and big projects it significantly decreases subsequent build times after the project has been fully built. Btw, the fact that there is Ant task execution phase does not mean that IDE actually executes Ant tasks. It is just a status message of the phase IDE builder passes.
As for the 2.5 seconds time of the build - need to investigate each case individually. For example what plugins are installed in IDE, what is the project configuration, environment etc. You can try disabling all plugins for the technologies you do not use, including Kotlin plugin if you do not use Kotlin - it might improve the build speed.
Thx for your answer. I was hesitant to ask about this, because i assumed it indeed is one of my settings or plugins that might be messing things up. However the 2nd computer i tested on, was a completely fresh install of windows and hardly had anything on it. I tried both 2020, 2021 (eval ultimate and community ed) and all of them behaved the same. Default plugins etc.
(I try not to be unfair in my expectations and i fully understand intellij is way more advanced then many IDE's, which always comes at a price of course.)
I searched for "incremental" to disable incremental build to see if that helps (since you mention it), but the feature is only for scala and kotlin and not java? (q1)
Although i totally not expected anything to change, i did install a much newer 17 jdk from here: https://adoptium.net/?variant=openjdk17&jvmVariant=hotspot
Strangely enough my build process looks a bit different now and much snapier (400ms)
Is it now doing a different build task, since its much quicker and show completely different lines then before? What did i do to trigger this? Can this be cause by a plugin (q2)
Where are the build-process defined anyway. I did a couple of full searches on key phrases (including binary files) on the install dir of intellij but nothing showed up. (q3)
Its not just about speed, its also about understanding what it actually tries to do. In the modern era, 2.5 sec is a long time for a single java file on 4000MB/s nvme's and 6core intels with 32GB ram.
When im back home ill try your suggestions and disable kotlin plugins and whatever i feel like might influence it. I dont use kotlin myself (one of the few languages i never touched, but by build script is using a "build.gradle.kts" so i think it needs kotlin for gradle?
You might be wondering why i want intellij to build the java if it has a gradle task... It used to be that native task build a bit faster then using the gradle build, but more importantly, when i run the task "Run" in gradle, it runs properly but never stops when "Terminating" it until i use windows taskmanager. Even after i close intellij it still runs. Also "rerun" doesnt work, and it states the destination port is in used (which makes sense if the old process hangs). When i try to debug button, it never triggers on the breakpoints, so using intellij build seemed a good alternative since it does close the process and does allow debugging.
edit: to be clear, the real project has a gradle build file, but the tests i did after (to pinpoint the cause) were done with freshly created projects from the intellij helloworld template java app. I created a fresh project about 10 times to makes sure its "clean".
edit2 I should have mentioned it before, but the only way i could find in intellij to build/run the java app is by using the the template from Run/debug configurations called "Application". It has many templates but nothing else seemed fitting for it. I would expect to see some barebones "java build&run" template there but application seemed the only one fitting. Maybe there is a better way ? (q4)
>Strangely enough my build process looks a bit different now and much snapier (400ms)
This is the build from Gradle. Looks like you ahve opened a Gradle project? In such a case IDE by default delegate the build actions to Gradle. You can change the behaviour in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using.
Incremental build is always used by IDE and cannot be disabled. It works for Java as well.
Thx for your answer. In the [Build tools] > [Gradle] i indeed had set it before to use intellij as the compiler but apparently it snapped back (or maybe i did it myself during all testing) .
I understand you can't elaborate on all questions i had before, but let me stick to the core issue. If i understand you correctly, even the most basic helloworld.java application build by intellij will always do all "incremental build" steps and there is nothing that can be done to make the build process more bare bones. That this will take 2.5 sec on a clean windows with bulky hardware and clean intellij is by design and regarded as acceptable?
If this is correct it is at least clear why this happens. I noticed other people also wondering about this during my google searching. If i have some time ill try to investigate why the gradle run task cant be terminated from within intellij and doesn't debug out of the box either, because it suddenly became more attractive to use.
>will always do all "incremental build" steps and there is nothing that can be done to make the build process more bare bones.
Yes IDE needs all the phases to be executed. Please try disabling plugins for the technologies you do not use to make the build process faster. Disabling Kotlin plugin should help to make time less.
>If i have some time ill try to investigate why the gradle run task cant be terminated from within intellij and doesn't debug out of the box either, because it suddenly became more attractive to use.
Task termination and debugging is working fine for me. Please add more details and the steps about the problem.