4 ms·
Since I do use journalled filesystems for my real data, your comment implies I should create yet another partition for /tmp using a filesystem that optimises pe
by rogerbinns 10y ago
Since I do use journalled filesystems for my real data, your comment implies I should create yet another partition for /tmp using a filesystem that optimises performance over durability/integrity, eg without journalling.
I consider files in /tmp to be temporary, and do not expect them to survive a reboot. (Actually I prefer they don't - less administration and housekeeping.) They also have random lifetimes ranging from fractions of a second to several days. And random sizes from zero length to gigabytes (eg making an ISO image).
With tmpfs RAM is used which provides the best performance since the filesystem is trivial. Memory pressure will cause swap to be used as needed. Files not accessed will end up in the swap and taking no RAM.
By far the fastest I/O is the I/O you don't have to perform.
- lmm 10y ago> Since I do use journalled filesystems for my real data, your comment implies I should create yet another partition for /tmp using a filesystem that optimises performance over durability/integrity, eg without journalling. If you're using a swap partition just for the sake of /tmp then it's the same difference, no?
- rogerbinns 10y ago> If you're using a swap partition just for the sake of /tmp then it's the same difference, no? No. The big difference is that regular filesystems try to do I/O to their backing device - heck that is their point, and what they do the vast majority of the time. tmpfs does not do any I/O. However I/O will happen when there is memory pressure by the swapper, but that is going to be rarer. ie with tmpfs, swap is a spillover mechanism. With a regular filesystem, the underlying device is the primary mechanism. Swap can also be used for actual swap on the occasions it is helpful.
- lmm 10y ago> No. The big difference is that regular filesystems try to do I/O to their backing device - heck that is their point, and what they do the vast majority of the time. tmpfs does not do any I/O. However I/O will happen when there is memory pressure by the swapper, but that is going to be rarer. Yes and no - aren't they just two ways of looking at the same decision? Regular filesystems will buffer, and when the system is low on memory it will flush buffers, using similar criteria to deciding whether to swap. > Swap can also be used for actual swap on the occasions it is helpful. Swap enables actual swap, sure. My experience is that it usually hurts more than it helps though.
- rogerbinns 10y ago> ... Regular filesystems will buffer, and when the system is low on memory it will flush buffers ... That is the bit you are missing. Unwritten filesystem data is regularly flushed. The flush interval is often around 5 seconds. Lookup "pdflush" to get the gist, although things have changed since then. Same with laptop mode. Quite simply if a file is created and lives for at least N seconds then there will be disk activity irrespective of memory pressure. N is 5, perhaps up to 30 seconds in normal use. Even if the file contents aren't fully flushed, metadata is.