Speed up steps using a RAM disk

Optimize step performance

Tasks which are heavily dependent on disk IO can be sped up by performing those operations in memory and avoiding the disk. This is especially true if you're using the Docker executor on CircleCI, we have an in depth blog post here about the issue.

Docker Executor

On the docker executor we have enabled an available RAM disk by default which you can use to dramatically increase step speeds. This is highly encouraged for steps like cache/workspace restores. You can read about configuring it in our docs here.

The short version is that you have access to a special directory,  /mnt/ramdisk, which acts as any other directory. Files stored here will use the machines assigned resource class memory. For instance, you can set your entire working directory to be stored in memory with working_directory: /mnt/ramdisk in your job configuration.

Other executors

The RAM disk is not configured by default on other executors. It's less likely that you'll need it because they operate as isolated VMs, and avoid the issues outlined in the blog post mentioned above. You may still find that a RAM disk offer performance benefits over utilizing the hard disk. In other executors (Machine,  MacOS, etc) you have far more control over the environment, so it's possible to configure a RAM disk yourself. Using instructions such as this stack exchange answer for Linux based systems.

Windows

To configure a RAM disk on windows please see our guide linked here.

Caution:

/mnt/ramdisk is owned by root which can cause issues when using the default circleci user. Such as using checkout while within the /mnt/ramdisk directory.

You can check the current user by adding the following run step below:

- run: whoami 

If the user is circleci you may have permissions issues when /mnt/ramdisk is owned by root.

You can check the owner of the ramdisk by running.

- run: ls -lah /mnt/ramdisk

Was this article helpful?
1 out of 3 found this helpful

Comments

0 comments

Article is closed for comments.