Linux: Creating a ramdisk with tmpfs and ramfs

From Define Wiki
Revision as of 10:11, 2 October 2014 by David (talk | contribs) (Created page with "So tmpfs vs ramfs, in short tmpfs is newer and behaves like a filesystem and can be created on the fly (it will also swap under high usage), ramfs wont swap but you may hang y...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

So tmpfs vs ramfs, in short tmpfs is newer and behaves like a filesystem and can be created on the fly (it will also swap under high usage), ramfs wont swap but you may hang your machine if you exhaust ram. Lots more details online: http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/

Setting up tmpfs

Easier than i expected!

 mkdir -p /ramdisk
 mount -t tmpfs -o size=8192m tmpfs /ramdisk

Setting up ramfs

Damn this is easy

mkdir /ramdisk
mount -r ramfs -o size=8192m ramfs /ramdisk

Performance tmpfs

  • On a haswell DDR4-2133Mhz with 8GB ramdisk tmpfs
  • Bandwidth with dd
[david@haswell5 dp]$ dd if=/dev/zero of=./file.dd bs=4M count=1024
1024+0 records in
1024+0 records out
4294967296 bytes (4.3 GB) copied, 2.00559 s, 2.1 GB/s
  • IOPS / BW with FIO
[david@haswell5 dp]$ cat iops.fio 
[random]
rw=randread
size=500m
directory=/ramdisk/dp/
iodepth=32
blocksize=4k
numjobs=16
nrfiles=1
group_reporting
ioengine=sync
loops=1
[david@haswell5 dp]$ fio ./iops.fio 
random: (g=0): rw=randread, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=32
...
random: (g=0): rw=randread, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=32
fio-2.0.13
Starting 16 processes
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
random: Laying out IO file(s) (1 file(s) / 500MB)
Jobs: 16 (f=16)
random: (groupid=0, jobs=16): err= 0: pid=9616: Thu Oct  2 11:11:20 2014
  read : io=7940.3MB, bw=4550.3MB/s, iops=1164.9K, runt=  1745msec
    clat (usec): min=0 , max=1463 , avg= 2.06, stdev= 2.17
     lat (usec): min=0 , max=1463 , avg= 2.09, stdev= 2.17
    clat percentiles (usec):
     |  1.00th=[    0],  5.00th=[    1], 10.00th=[    1], 20.00th=[    1],
     | 30.00th=[    1], 40.00th=[    1], 50.00th=[    1], 60.00th=[    1],
     | 70.00th=[    2], 80.00th=[    3], 90.00th=[    5], 95.00th=[    6],
     | 99.00th=[    9], 99.50th=[   10], 99.90th=[   13], 99.95th=[   15],
     | 99.99th=[   21]
    bw (KB/s)  : min=    3, max=    3, per=0.00%, avg= 3.00, stdev= 0.00
    lat (usec) : 2=63.58%, 4=16.42%, 10=19.43%, 20=0.56%, 50=0.01%
    lat (usec) : 100=0.01%, 250=0.01%
    lat (msec) : 2=0.01%
  cpu          : usr=3.68%, sys=95.18%, ctx=2966, majf=0, minf=398
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued    : total=r=2032697/w=0/d=0, short=r=0/w=0/d=0

Run status group 0 (all jobs):
   READ: io=7940.3MB, aggrb=4550.3MB/s, minb=4550.3MB/s, maxb=4550.3MB/s, mint=1745msec, maxt=1745msec

Nippy, 4GB+ bandwidth over 1m IOPS