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

Re: /tmp as tmpfs and consequence for imaging software

On 12/11/11 23:25, Josselin Mouette wrote:
> Le samedi 12 novembre 2011 à 23:12 +0100, Samuel Thibault a écrit : 
>> Adam Borowski, le Sat 12 Nov 2011 23:08:08 +0100, a écrit :
>>> You need to increase the swap size by the amount you'd use for /tmp.
>> Well, the idea of such case is precisely to *not* use swap, but real
>> disks. Such software already know how to manage its memory and
>> disk-backed memory (thusly stored in /tmp)
> Practically speaking, the only significant difference is that files are
> not forced to disk as early. Otherwise, if you have a large enough swap,
> pages of a file on a tmpfs that are not used enough will be swapped. And
> pages of a file on a regular filesystem that are used enough will be
> kept in the buffer cache.
There are another differences:

When the system is swapping heavily, if you are not using a preempt
kernel the hole system will become so unresponsive while the swapping
process is taking place that even your mouse pointer will stop moving.
And Debian kernel is no preempt.

So, if having /tmp with tmpfs will make your system to swap more often
(huge files on /tmp) then any performance gain by tmpfs will be buried
by this swapping hell.

Also, if you are near to run out of virtual memory (RAM+SWAP) for
whatever reason: few ram, many apps open... an application can trigger
the OOMKiller by simply writing data into /tmp if you are using tmpfs.

> OTOH, for a wide range of applications that do a lot of small writes,
> using tmpfs is a huge gain.

Linux already has a disk cache buffer that works very nice for this case
of doing lot of small read/writes into a file. Also, when its time to
flush the data to disk, or read data no previously cached, the kernel IO
scheduler will take care of optimizing it in order to reduce the disk
spinning and improve the performance.

So... while is true that tmpfs is faster than using the disk for /tmp,
it isn't such big deal.

And IMHO I don't think that this performance gain outweighs so clearly
the problems exposed that justify making tmpfs on /tmp the default on

Attachment: signature.asc
Description: OpenPGP digital signature

Reply to: