Search code examples
linuxubuntuintellij-idearamdisktmpfs

IntelliJ IDEA compilation speedup in Linux


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?


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 ;)