Child pages
  • Ramdisk Java

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

Putting a JVM in a read only ramdisk file system improve the overall performance of Java on Ubuntu Linux.

It doesn't replace a SSD but rooming 200M of RAM to get some substantial performance is always welcome.

However there are some limitations with this technic:

  • tmpfs is swappable. Under heavy loaded machine our ramdisk could be transferred in a mechanical hard drive.
  • SquashFS is building a highly compressed file, reducing the IO and the size of the ramdisk. Not sure if an unsquashed JVM image would outperform a squashed image.

SquashFS

In order to put a JVM in a RAM disk we are going to use the tool SquashFS.

...

Code Block
languagebash
themeEmacs
sudo mkdir /media/ramdisk-java-8-oracle

Edit your /etc/fstab and define your mount point as a tmpfs file system and run your squashed JVM against this mount point by adding the following declarations:

Code Block
languagetext
# changedefine a thetmps defaultmount sizepoint for theJava ramdisk
tmpfs /media/ramdisk-java-8-oracle tmpfs defaults,size=170M,mode=1777 0 0
# run a squashed JVM against our tmps mount point
/usr/lib/jvm/ramdisk/java-1.8.0.91-oracle.sqsh /media/ramdisk-java-8-oracle squashfs ro,defaults,loop 0 0

If you reboot at this point you will have a ramdisk defined at /media/ramdisk-java-8-oracle filled with your squashed JVM:

Installation

At this point you need to reboot to initialize the ramdisk with your Squashed JVM. Now you to proceed a standard Java installation.

Check your Java environment

Define a jinfo file

Prepare a bunch of shell scripts to install and uninstall your new JVM.

in the /usr/lib/jvm directory we define the default-java to point to a local symlink who will point to our ramdisk:

...