Boosting performance of IntelliJ IDEA …and the rest of JetBrains’ IDEs

Serhii Prodan
6 min readJun 16, 2019
Photo by David Rangel on Unsplash

Recently I had to reinstall my main IDE app — IntelliJ Idea — and I usually take some time to tweak the apps after a fresh install, this was no exception since I spend most of my work day in the IDE.

I’m not going to divulge into discussions about what an IntelliJ IDEA is, if you’re reading this — chances are very high that you’re already familiar with this IDE. Otherwise just visit JetBrains website for more information. Nor will I argue for the benefits of using IntelliJ instead of any other IDE for java development — I think it’s a matter of taste and you can be as productive in VSCode or Eclipse, for example, if that’s what you’re used to. What I want to share is how to make your IDE perform faster.

Disclaimer: I’m running Ubuntu 18.04 as my primary OS and some of the tweaks here will not apply to Windows without modifications. I’m also mostly using IntelliJ IDEA but most of these tweaks should apply to other JetBrains IDEs. Also note that everything that you do — you do at your own risk and I will neither be responsible nor held accountable for anything that you do to your own software and hardware.

Moving Caches and Index directories to RAM

By default IntelliJ will write its temporary files in your home dir. You can speed up the IDE and reduce disk writes by moving this cache into RAM.

1. Create a mount point for RAM under `/tmp`

Open (with root rights) etc/fstab in your favorite editor, i.e. $ sudo vim /etc/fstab, and add the following line:

# RAM mount for Intellij Idea
tmpfs /tmp/ramdisk tmpfs noexec,defaults,noatime,size=1024M,x-gvfs-show,mode=1777 0 0

You can change the size as per your needs, but I really doubt you’ll need more than 1gb, I think even 512mb should be enough, but since I have plenty of ram on my machine I just put 1gb.

x-gvfs-show is optional — it will allow you to browse the partition in the file manager.

We can also change swappiness by modifying the /etc/sysctl.conf file. This can be done in one line with: $ sudo bash -c "echo 'vm.swappiness = 10' >> /etc/sysctl.conf"

Note: don’t forget to remount your partitions with $ sudo mount -a and run $ sudo sysctl -p to activate new swappiness. Otherwise these things will be done on next boot.

2. Create `caches` and `index` directories for intellij on the mounted partition.

We need to create the directories on the RAM mount point where IntelliJ will write cache and index files:

$ sudo mkdir -p /tmp/ramdisk/intellij/caches
$ sudo mkdir -p /tmp/ramdisk/intellij/index

2a. Creating directories on boot.

Since /tmp gets cleaned on reboot, our newly created directories will be deleted and if we try to launch IntelliJ an exception will be thrown since our symlinks (read on) will point to nothing.

To create the directories on boot we can use tmpfiles.d. Create a new config file under /usr/lib/tmpfiles.d/, i.e. $ sudo vim /usr/lib/tmpfiles.d/intellij.conf, with the following contents:

#Type Path Mode UID GID Age Argument
d /tmp/ramdisk/intellij/caches 0777 root root — -
d /tmp/ramdisk/intellij/index 0777 root root — -

And now the directories we need are re-created on each boot.

3. Move IntelliJ caches and index to RAM mount

(Assuming we have IntelliJ Idea Community 2019.1 version installed.)

First remove the original directories in your intellij config dir (usually ~/.IdeaIC2019.1 in Linux). For more info see: Directories used by the IDE to store settings, caches, plugins and logs.

$ rm -rf ~/.IdeaIC2019.1/system/caches
$ rm -rf ~/.IdeaIC2019.1/system/index

Then symlink the directories on the RAM mount point:

$ ln -s /tmp/ramdisk/intellij/caches ~/.IdeaIC2019.1/system/caches
$ ln -s /tmp/ramdisk/intellij/index ~/.IdeaIC2019.1/system/index

Now IntelliJ will use RAM for all I/O operations with cache and index files. I haven’t done any benchmarks but visually this has been the biggest improvement on the overall performance for me. I think if using an HDD the difference will be even more noticeable.

This tweak should also prolong the life of your SSD as were not using it for caches and indexes anymore, however I don’t think that this is really an issue with newer SSD drives.

Moving output directories to RAM

If you want to improve compilation time of your projects we can put the compilation output files to RAM as well.

After creating a mount point we need to set project and modules compiler output directories.

This is done in Project Structure Settings (Ctrl +Alt + Shift + S).

Open Project Settings -> Project -> Project compiler output and set the directory to /tmp/ramdisk/intellij/projectname/out.

Adding a project name is useful if you’re working on multiple projects at the same time and want to browse the output directories.

Then go to Project Settings -> Modules -> Paths and set Inherit project compile output path. Do this for all modules if you have a multi-module project.

Tweaking VM Options

I have found this config file for vmoptions of IntelliJ IDEA over on github. I’m using it without any modifications except for the -Xmx value and it seems to work quite well.

VM Options can be modified from one of the three places:

  • On the welcome screen: Configure -> Edit Custom VM Options...
  • From the Help menu: Help -> Edit Custom VM Options...
  • By modifying the idea64.vmoptions file in config directory.

Unloading unused modules

Working on a large multi-module project can affect performance since IDEA needs to process a large amount of files for search, inspections, refactoring code and similar operations. If you do not need all the modules at the same time it is advisable to exclude them from the IDEA’s activity. If you’re using version 2017.2 or above there is a feature called Unloaded Modules that allows you to do exactly that — exclude the modules from the project. If you need an unloaded module back you can load it back so that it will again be available to the IDE.

To load/unload modules open up actions dialogue (Shift + Shift → Actions tab) and type Load/Unload Modules. This will bring up the menu from which you can load and unload the modules in the project.

Unsurprisingly, IntelliJ IDEA is smart enough to warn you about dependencies between modules when your loading or unloading them and will also give some suggestions on the actions you can take.

Excluding project from antivirus scan

I’m not using antivirus software on Linux-based OSs however antivirus activity can result in a significant performance hit (not only for IntelliJ but the whole OS in general). For IntelliJ the problem lies in frequent I/O operations to temporary files, sources and so on. Each of these actions may potentially be intercepted by the antivirus software, therefore excluding your project from the antivirus real-time scan is usually a good idea.

Disabling unused plugins

Many people install plenty of plugins for their IDE, then these plugins get forgotten and not used on a daily basis if used at all. The number of active plugins can greatly affect performance when plugins are doing some activities. Same as with unused modules, a good rule of thumb is, if you don’t use it — disable it.

Enabling Power saving mode and disabling File Sync

You can enable Power saving mode from the File menu. This will disable many IDEAs background activities and file synchronization, which should give extra performance boost.

Additionally, disabling files sync under Settings -> Appearance & Behavior -> System Settings -> Synchronization should improve the performance even further.

Enabling zero-latency Typing

There is an experimental feature that was introduced in IntelliJ version 15 which is called Zero-latency typing.

You can try it out by adding editor.zero.latency.typing=true to the idea.properties file. I’m not sure if they’ve released it yet, but I couldn’t find it in the settings so I would assume it’s still in experimental phase. Still, it does work quite well and you can definitely see the difference.

Read more about this feature on the IntelliJ IDEA blog.

Reporting performance problems

Tips outlined here are aimed at improving the performance of the IDE rather than fixing issues. If you’re experiencing heavy performance issues with IntelliJ it’s better to analyze the problem and submit a bug report. See Reporting performance problems for more info.

Further read

IntelliJ IDEA Architecture and Performance — a rather old but still somewhat useful presentation.

Boosting IntelliJ IDEA Performance on Windows Systems — another quite old blog post explaining how to improve performance by optimizing the MFT tables, disk folder structure and Windows paging file. I’m not sure if this is applicable to newer SSD disks, but if you are using an HDD and Windows OS it might be worth a try. JetBrains claim this can improve the performance up to two times.

I hope you’ve enjoyed reading this post and hopefully you’ll be able to improve the performance of your IDE. Naturally these tips won’t make you a better programmer per se but they should improve your development environment and consequently improve your productivity. Happy coding :)

--

--

Serhii Prodan

Searching for the answer to the Ultimate Question by night, tester by calling, serendipitously became a devops lead by day. Automating things I get my hands on.