Temporary files: RAM or disk?
Posted Jun 7, 2012 2:28 UTC (Thu) by giraffedata
In reply to: Temporary files: RAM or disk?
Parent article: Temporary files: RAM or disk?
there aren't inodes and directories to pull the head around.
It's not that simple. Tmpfs is not "plain data" filesystem, you can
create directories there, so it has to store all the metadata as well.
It also has inodes internally.
I was talking about disk structures. Inodes and directory information don't go into the swap space, so they don't pull the head around.
(But there's an argument in favor of regular filesystem /tmp: if you have lots of infrequently accessed small files, tmpfs will waste memory).
Second, writes stream out sequentially on disk, eliminating more
This could be true if swap was empty. Same when you write to the empty
filesystem. But what if it was not empty? You get the same swap
fragmentation and seeking as you would get in any regular filesystem.
It's the temporary nature of the data being swapped (and the strategies the
kernel implements based on that expectation) that makes the data you want at any particular time less scattered in swap space than in a typical filesystem that has to keep copious eternally growing files forever. I don't know exactly what policies the swapper follows (though I have a pretty good idea), but if it were no better at storing anonymous process data than ext3 is at storing file data, we would really have to wonder at the competence of the people who designed it. And my claim is that since it's so good with process anonymous data, it should also be good with temporary files, since they're used almost the same way.
in order to read a page from swap you must first write another page there.
Actually, the system does the same thing for anonymous pages as it does for
file cache pages: it tries to clean the pages before they're needed so that
when a process needs to steal a page frame it usually doesn't have to wait for a page write. Also like file cache, when the system swaps a page in, it tends to leave the copy on disk too, so if it doesn't get dirty again, you can steal its page frame without having to do a page out.
to post comments)