Re: Swap space

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

 



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.)

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

-- 
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