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

Re: Swap space



On Sun, 2009-02-22 at 00:21 +0000, James Wilkinson wrote:
> Patrick O'Callaghan wrote:
> > Has anyone actually compared the speed of pendrives versus hard disks
> > when used for swap?
> 
> Aaron Konstam wrote:
> > They have to be much slower …
> 
> I don’t think they have to be – I suspect they might be faster than hard
> disks.
> 
> What I’ve read is that the sort of flash you tend to get in these drives
> can be very slow for writes, slow to read back data in sequentially, but
> they can be a lot faster than hard drives to actually start accessing
> the data, because there’s no physical movement required to start reading
> from the disk. A quick google resulted in
> http://www.tomshardware.com/reviews/security-flash-storage,1804-6.html ,
> with a couple of drives with access times a tenth of what you’d expect
> from a good hard drive, but slower sequential transfer speeds.
> 
> That leaves two questions – does the flash in question have low access
> times, or did the manufacturer come up with slow flash because no-one
> cared? And what sort of access patterns do you get for reading from
> swap?
> 
> A virtual memory system works in pages, normally of 4K¹. If you’re just
> going to read in one 4K page, then the access time is going to be much
> larger than the transfer time, even for flash: in other words, the flash
> will have got the data into RAM before the hard drive is likely to be
> anywhere near the data. So for a hard disk to be faster than
> low-access-time flash for swap, then you’re going to have to have a
> situation where the kernel wrote out around a megabyte of data to swap,
> and then read it back in continuously.
> 
> I doubt that Linux (or many other operating systems) does that. It will
> normally choose pages to swap from multiple different processes, and in
> any case, adjacent pages in swap would be unlikely to be needed back in
> RAM at the same time.
> 
> Note that the speed of writing pages to swap is not that important until
> it takes a large proportion of the flash’s time (it’s asynchronous:
> nothing’s waiting on it), or unless you suddenly have a lot of need for
> memory (which is rare: the kernel does try to keep some free memory
> about, and will only actually allocate memory when a process actually
> starts using it).
> 
> As I and others have said, just because it’s fast doesn’t mean it’s a
> good idea, and you might get through flash drives fairly quickly if you
> actually use your swap for much. (If you just have swap for emergencies,
> it might see less use than your home directory.)

You're forgetting that USB transfers consume a fair amount of cpu time,
unlike a SATA disk which is DMA. That's why I asked if anyone had
actually done a comparison. With so many complex interactions between
paging policy, system load, disk configurations, wide variations in
flash memory speeds etc., theory is a poor substitute for actual
measurement.

poc


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