Re: Swap space

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

 



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.
> 
Comparing the read rates in that links list for flash drives to the
output of hdparm for hard disks make it clear that disks are faster:
[root@localhost ~]# hdparm -Tt /dev/sda3

/dev/sda3:
 Timing cached reads:   1630 MB in  2.00 seconds = 815.32 MB/sec
 Timing buffered disk reads:   94 MB in  3.01 seconds =  31.20 MB/sec

> 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.)
> 
> James.
> 
> ¹ Other sizes may be used on other OSes, or in Linux on
> non-x86-compatible processors.
> 
> -- 
> E-mail:     james@ | And the cuckoo isn’t cooing,
> aprilcottage.co.uk | But he’s cucking and he’s ooing,
>                    | And a Pooh is simply pooh-ing
>                    | Like a bird.                          -- ‘Noise’, by Pooh
> 
--
=======================================================================
Congratulations! You are the one-millionth user to log into our system.
If there's anything special we can do for you, anything at all, don't
hesitate to ask!
=======================================================================
Aaron Konstam telephone: (210) 656-0355 e-mail: akonstam@xxxxxxxxxxxxx

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux