LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 10-07-2016, 05:11 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Ram disk


Is there an speed improvement in using a ram disk ?

http://askubuntu.com/questions/15286...ake-a-ram-disk
 
Old 10-07-2016, 06:01 PM   #2
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Created my ram disk and pointed my browser cache to it.
Quote:
sudo mkdir -p /media/ramdisk
sudo mount -t tmpfs -o size=2048M tmpfs /media/ramdisk
free -m shows this. Where is the ram disk ?

Quote:
total used free shared buff/cache available
Mem: 6.8G 679M 4.8G 35M 1.3G 5.7G
Swap: 0B 0B 0B
 
Old 10-07-2016, 06:03 PM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
obviously a ram disk is going to be faster than a mechanical drive, but whatever you use in the ram dksk is not available to programs so may cause more use of swap, also if you need to save the data after power down you will need to write it out to a 'real' disk all of which takes time, it's swi ngs and roundabouts really
 
Old 10-07-2016, 06:05 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
p.s. I beleive the ram disk will frow as needed so a fresh ramdisk will not use much memory untill u start writing to it
 
Old 10-07-2016, 06:55 PM   #5
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by Keith Hedger View Post
obviously a ram disk is going to be faster than a mechanical drive, but whatever you use in the ram dksk is not available to programs so may cause more use of swap, also if you need to save the data after power down you will need to write it out to a 'real' disk all of which takes time, it's swi ngs and roundabouts really
I am aware of that.

A browser cache never needs to be saved.

I have 8 Gb of ram, of which only 2 Gb is ever used.

A ram disk is even faster than a SSD drive.

When burning CD/DVDs I notice that CPU usage is very high, but I think the burner program uses RAM for it's cache.
 
Old 10-07-2016, 07:15 PM   #6
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
tmpfs is incredibly fast. I even blogged a how-to on customizing boot scripts to load the entire OS into a tmpfs ramdisk. It's faster than any SSD. And it honestly does NOT slow down a system if you have swap. tmpfs can be offloaded into swap space, which reduces the performance of any files offloaded down to the level of normal files on a normal partition...but this is not really worse than the performance had those files been on a normal partition in the first place.

The differences in performance are more subtle. Basically, a normal file on a normal partition will receive writes at some point when the drive is free to accept the updates. In all cases, writes first go to the RAM cached file. If it's backed by a normal partition, then this update will be written to disk eagerly...as early as convenient. After being written to disk, the cached portion is marked as clean (so it can be flushed from RAM at any instant to make way for something else needing RAM).

tmpfs is basically just a RAM cache with no disk file system backing it. As such, there's nothing to write updates to. Its files can never be marked clean. But they can be offloaded into swap...not eagerly, though. It'll only get offloaded at the last second, when the RAM is needed. This may cause a noticeable speed bump as whatever needs the RAM waits for it. So maybe you'll notice some slower performance. Maybe. But once it is offloaded into swap, that RAM is now available. As long as the offloaded files aren't accessed again, it just sits on swap not impairing performance at all. Just like any normal file just sitting on disk.

Now, there's the question - "Where is it?" when you look at the output of "free". Unfortunately, the data returned by "free" does not account for tmpfs in a neat way. The problem is that tmpfs is implemented as a file cache that just happens to not have a normal file system backing it. As such, it's included in with "cache". But everything else in "cache" is not really used up in a way that makes the RAM unavailable. Normally, "cache" is nothing but blocks that are either clean or will be clean soon enough. Any clean blocks can be dumped from RAM in a flash.

But tmpfs breaks that assumption. Any tmpfs cache will NEVER be clean. They will ALWAYS be dirty, because there just isn't any backing file system.
 
Old 10-07-2016, 08:13 PM   #7
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Interesting.

Thanks for the explanation.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone know of something like a disk-backed RAM disk? dchicks Linux - Kernel 2 11-04-2009 04:21 PM
RAM disk? Help Patou001 Linux - General 4 01-18-2007 07:16 AM
copy RAM to disk imsandy_007 Programming 6 11-18-2006 09:20 AM
ram disk quiron Linux From Scratch 3 07-20-2005 02:43 AM
Ram disk consty Red Hat 1 05-11-2005 07:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 09:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration