[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Moving /tmp to tmpfs makes it useless



Le vendredi 25 mai 2012 à 02:22 +0300, Serge a écrit : 
> I've read across different debates about whether using tmpfs is good or bad
> but I could not find the most important reason, so here it is...
> 
> Reason
> ======
> What's a temporary file? Really, why would applications temporarily store
> its data in a file? They do that to *free some memory*. Placing those files
> back to memory renders the whole process of writing the file useless.
> If the files are small and can stay in memory why would application save it
> to file?

This is complete bullshit. If you know nothing about how virtual memory
works, please refrain from making a fool of yourself.

Files which are written on a regular filesystem stay on memory. This is
called the buffer cache. Whenever they are not used and/or the system
needs to reclaim memory, they are trashed.
Files which are written on a tmpfs stay on memory. Whenever they are not
used and/or the system needs to reclaim memory, they are swapped.

See? No difference.

Oh stop, there is a difference: in a tmpfs the system doesn’t need to
commit the data on disk, and therefore can write it to disk whenever it
likes, especially when the disk is not too used. There is no need to
keep a journal nor to access the disk several times to update metadata.
Only unused data is written to disk. Which means a *huge* performance
improvement. Do the measurements yourself, it works with basically
anything that makes heavy use of /tmp.

And if you find /tmp too small, it’s really simple: increase your swap
size. That’s all.

-- 
 .''`.      Josselin Mouette
: :' :
`. `'
  `-


Reply to: