Question

I'm working with IntelliJ IDEA on Linux and recently I've got 16 GB of RAM, so is there any ways to speed up my projects compilation using this memory?

Was it helpful?

Solution

First of all, in order to speedup IntelliJ IDEA itself, you may find this discussion very useful.

The easiest way to speedup compilation is to move compilation output to RAM disk.

RAM disk setup

Open fstab

$ sudo gedit /etc/fstab

(instead of gedit you can use vi or whatever you like)

Set up RAM disk mount point

I'm using RAM disks in several places in my system, and one of them is /tmp, so I'll just put my compile output there:

tmpfs /var/tmp tmpfs defaults 0 0

In this case your filesystem size will not be bounded, but it's ok, my /tmp size right now is 73MB. But if you afraid that RAM disk size will become too big - you can limit it's size, e.g.:

tmpfs /var/tmp tmpfs defaults,size=512M 0 0

Project setup

In IntelliJ IDEA, open Project Structure (Ctrl+Alt+Shift+S by default), then go to Project - 'Project compiler output' and move it to RAM disk mount point:

/tmp/projectName/out

(I've added projectName folder in order to find it easily if I need to get there or will work with several projects at same time)

Then, go to Modules, and in all your modules go to Paths and select 'Inherit project compile output path' or, if you want to use custom compile output path, modify 'Output path' and 'Test output path' the way you did it to project compiler output before.

That's all, folks!

P.S. A few numbers: time of my current project compilation in different cases (approx):

HDD:     80s
SSD:     30s
SSD+RAM: 20s

P.P.S. If you use SSD disk, besides compilation speedup you will reduce write operations on your disk, so it will also help your SSD to live happily ever after ;)

OTHER TIPS

Yes you can. There is several ways to do this. First you can fine tune the JVM for the amount of memory you have. Take this https://gist.github.com/zafarella/43bc260c3c0cdc34f109 one as example.

In addition depending on what linux distribution you use there is a way creating RAM disk and rsyncing content into HDD. Basically you will place all logs and tmp files (including indexes) into RAM - your Idea will fly.

Use something like this profile-sync-daemon to keep files synced. It is possible easily add Idea as an app. Alternatively you can use anything-sync-daemon

You need to change "idea.system.path" and "idea.log.path" More details on Idea settings could be found at their docs. The idea is to move whatever changes often into RAM.

More RAM Disk alternatives https://wiki.debian.org/SSDOptimization#Persistent_RAMDISK

The bad about this solution is that when you run out of space in RAM OS will page things and it will slow down everything.

Hope that helps.

In addition to ramdisk approach, you might speedup compilation by giving its process more memory (but not too much) and compiling independent modules in parallel. Both options can be found on Settings | Compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top