DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Introduction to Tactical DDD With Java: Steps to Build Semantic Code
  • How to Build and Optimize AI Models for Real-World Applications
  • Part I: The Build You Can’t See Is the One That Will Kill You: Software Supply Chains, SBOMs, and the Long Reckoning After SolarWinds
  • Java Developers: Build Something Awesome with Copilot CLI and Win Big Prizes!

Trending

  • AI Paradigm Shift: Analytics Without SQL
  • Building a DevOps-Ready Internal Developer Platform: A Hands-On Guide to Golden Paths, Self-Service, and Automated Delivery Pipelines
  • Architecting Sub-Microsecond HFT Systems With C++ and Zero-Copy IPC
  • Java in a Container: Efficient Development and Deployment With Docker

Accelerating Build Using a RAM Disk

Learn how to speed up your build time using RAM memory as a filesystem, on Windows or Linux, in this quick tutorial.

By 
Dmitry Egorov user avatar
Dmitry Egorov
DZone Core CORE ·
May. 22, 18 · Tutorial
Likes (11)
Comment
Save
Tweet
Share
26.3K Views

Join the DZone community and get the full member experience.

Join For Free

Yes, RAM memory can be used as a filesystem! RAM memory, in comparison with a regular drive, has these advantages:

  • Fast IO operations
  • Fast search operations
  • Less number of junks
  • Reduced fragmentations
  • No noise or heat

But, of course, it has disadvantages:

  • Losing memory on reboot
  • High price
  • Size limit

When Is Sacrificing RAM Memory Reasonable?

  • To decrease the time of your builds/compilers.
  • To speed up your database.
  • Cache, cache, cache.
  • To accelerate heavy applications like CAD, development IDEs, or even games.

Windows RAM Drive Applications

  • ImDisk Virtual Disk Driver
  • SoftPerfect RAM Disk
  • Dataram RAMDisk

Linux RAM Drive

To allocate RAM in Linux, you need to take two steps:

Create a folder:

 mkdir /mnt/myramfolder

Mount RAM:

mount -t [TYPE] -o size=[SIZE] [FSTYPE] [MOUNTPOINT]


Now, let's take a look at an example.

Using RAM Memory to Speed Up Build in Java Maven-Based Projects

Allocating 2GB disk using ImDisk application and mount it to G disk:

Image title

Fetching a random Java project from GitHub (Guava): https://github.com/google/guava.

Building that project using the Maven command:

mvn clean install -DskipTests -Dmaven.javadoc.skip=true

Checking the results with a hard drive very performant SSD: Samsung EVO 960 (2GB/3GB read/write speed).

Image title

Building the Project Using a RAM Disk

Put an .m2 Maven repository and Guava project in a RAM drive. Maven requires you to change the .m2 location in settings file to <localRepository>G:/.m2</localRepository>.

Image title

Check the Build Time in RAM

Image title

Results: the RAM disk saved 37% of the build time.

That's pretty good, considering that we are comparing a very performant SSD with regular RAM. Results should be better for non-SSD hard drives. If we go deeper, then the next step is to put the whole Linux machine in RAM.

How to Save Your RAM Disk Before Reboot

In Windows, ImDisk provides a storing feature from the box.

In Linux, you need to write a small script with recursive saving files, like so:

cp -avr /mnt/myramfolder /tmp/myrambackup
Build (game engine)

Published at DZone with permission of Dmitry Egorov. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Introduction to Tactical DDD With Java: Steps to Build Semantic Code
  • How to Build and Optimize AI Models for Real-World Applications
  • Part I: The Build You Can’t See Is the One That Will Kill You: Software Supply Chains, SBOMs, and the Long Reckoning After SolarWinds
  • Java Developers: Build Something Awesome with Copilot CLI and Win Big Prizes!

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook