[ale] On swap space (was Re: who is eating my drive)

Pat Regan thehead at patshead.com
Tue May 31 21:15:53 EDT 2011


On Tue, 31 May 2011 18:09:40 -0400
The Don Lachlan <ale-at-ale.org at unpopularminds.org> wrote:

> That's seems pretty non-deliberate, moreso "oh crap, how can I fix
> this?"

Just because you don't like the idea of the extended partition being
anywhere besides the end of the drive doesn't make it incorrect or
difficult to deal with.  It used to happen quite often.  :)

> >> Regular paging between physical RAM and swap space can be expensive
> >> to a system's performance; I would say that we shouldn't be paging
> >> in/out often, if at all, but paging out is A Good Thing<tm>.
> > If a system is accessing swap often enough that the speed of the
> > swap space makes a significant difference then it is most likely
> > time for a memory upgrade.  That's all I'm trying to point out :)
> 
> And you're wrong. Let's break this into two problems: 1) system
> paging to swap space and 2) performance of swap space.

We'll see if I'm wrong :)

> In the first, disk is between 3 and 4 orders of magnitude cheaper
> than RAM. Paging out a GB of data is extremely cost effective. A
> system does not need to page to swap but if you aren't, you've likely
> put too much (costly) RAM into a system that only needed (cheap) disk.

A gigabyte of RAM is extremely inexpensive.  Relying on swap space
rarely makes much sense anymore.

If any of my machines were regularly a gig or more into swap I would be
looking for the problem.  

I'm very curious as to what workload a server has where it is OK to dip
so deeply into swap under normal conditions.

> Regarding the second, the system cost of paging out data (which is
> good) is pretty minimal and I'm happy to make it a little more
> minimal by putting swap at the front of the disk. It may not gain you
> much but it costs you nothing. Not Much > Nothing.

The speed and access time of RAM is measured in gigabytes per second
and nanoseconds, disks in megabytes per second and milliseconds.

Earlier you argued that if I'm not swapping I wasted money on RAM.
Someone else might argue that if you have the time to swap that you
probably wasted money on CPU :)

> A system which is paging in/out heavily has problems larger than its 
> swap; however, that doesn't mean we ignore the swap. Who listens to
> the doctor that says, "Sorry, no cold medicine for you, just stop
> spending time around sick people." :)

If a system is paging heavily you probably wouldn't even be able to
measure the difference between swap at the front or back of the
platter.  Disk is just so much slower than RAM that it just doesn't
help enough to matter.

> >> I would also counter that I have never, EVER, seen anyone
> >> deliberately use the start of a disk for faster access unless they
> >> were using it for swap. If you want to put your most I/O intensive
> >> partition at the front of the disk, that absolutely makes sense -
> >> and as soon as I find someone who does that, I'll toggle my bit to
> >> 1. :)
> >
> > There's a good chance you've inadvertently done exactly this on your
> 
> Inadvertent != deliberate. You keep using that word. I do not think
> it means what you think it means.

Just because most people do it inadvertently doesn't mean that I
haven't done it on purpose.  I won't bother doing it again :)

> > own systems.  Anyone creating smallish root/var partitions near the
> > front of the drive are speeding up access to some of the most
> > important files on the system.  :)
> 
> On occasions when I've discussed partitioning schema, persons 
> recommended the small root/var/usr partitions for many reasons but
> never to increase disk access speed.

Does the lack of recommendations make the assertion any less true? :)

> Drives list seek times because they matter; seek times are an average 
> and clusters closest to the center are faster, clusters farther from
> the center are slower. Swap is something where your read/write speed
> can matter significantly but not so much you would expend money on
> RAID. Use the knowledge in front of you!

I think you're making a big assumption about the read/write speed at
the beginning of the drive.  It is only measurably faster for large
sequential reads and writes.  Paging usually involves random reads and
writes.

I did some experimenting with this stuff about 10 years ago.  The
theory was that if you kept all your data in a smaller section of the
drive, say the first 10-20%, you could reduce your average seek times
and you could take advantage of the faster sequential read/write
speeds.

IIRC, I set up an install using the first 6 gig of a 40 gig drive.  I
monkeyed around, ran some bonnie benchmarks, and other stuff.  Then I
moved the whole dd-ed the whole thing to the last 6 gig of the drive.

I remember the large sequential read/write numbers being a bit better,
but not by much.  Everything else was a wash.  It was no better than
just using the whole drive...  :(

Pat


More information about the Ale mailing list