2001-11-22 01:54:31

by Justin Piszcz

[permalink] [raw]
Subject: Swap vs No Swap.

I do not understand something.

How can having swap speed ANYTHING up?

RAM = 1000MB/s.
DISK = 10MB/s

Ram is generally 1000x faster than a hard disk.

No swap = fastest possible solution.


2001-11-22 02:22:48

by Joel Jaeggli

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Wed, 21 Nov 2001, war wrote:

> No swap = fastest possible solution.

assuming you can safely run without swap yes...

In many cases paging out processes you're not using can free up memoery
for useful things like caching disk writes...

for a significant number of people running without swap isn't an option.

if you have fine grained control over how much of your memory is used by
your apps then running without swap can be a resonable option...

6:19pm up 3 days, 5:15, 3 users, load average: 0.44, 0.58, 0.61
53 processes: 51 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 7.5% user, 17.6% system, 0.0% nice, 74.7% idle
Mem: 770844K av, 767476K used, 3368K free, 824K shrd, 80280K buff
Swap: 0K av, 0K used, 0K free 134424K cached

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
1076 squid 16 0 499M 499M 2108 R 23.0 66.3 2546m squid


> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

--
--------------------------------------------------------------------------
Joel Jaeggli [email protected]
Academic User Services [email protected]
PGP Key Fingerprint: 1DE9 8FCA 51FB 4195 B42A 9C32 A30D 121E
--------------------------------------------------------------------------
It is clear that the arm of criticism cannot replace the criticism of
arms. Karl Marx -- Introduction to the critique of Hegel's Philosophy of
the right, 1843.


2001-11-22 02:32:38

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Yes, I have.

I have 1024MB of ram.

When running every X application I have as user + root + etc, I still only use
600MB out of the 1024MB of ram.



2001-11-22 02:59:20

by Mark Hahn

[permalink] [raw]
Subject: Re: Swap vs No Swap.

> How can having swap speed ANYTHING up?

simple: under memory load, it's more efficient to scavenge
idle pages so they can be used for some "hotter" purpose.
there usually are *some* pages in any process which are
only used at startup, or very rarely used. if there's no
memory pressure, sure, leave them there. if there is some
other use for the memory, even caching files, then it's more
efficient to swap those pages (assuming they're dirty).

swap is a sound way of making more efficient use of limited ram.

> RAM = 1000MB/s.
> DISK = 10MB/s

well, modern disks are 40 MB/s, and a typical non-rambus PC
has only around 600 MB/s dram bandwidth, depending on how you
measure it, etc.

> Ram is generally 1000x faster than a hard disk.

no, more like 20x; it can be up to around 80x (1.6 GB/s pc800
and a fairly pathetic 20 MB/s disk). the *latency* ratio can
be much higher (10 ms vs 200 ns).

> No swap = fastest possible solution.

false in general. the only case where this is true is where
you either have just the right amount of ram (unlikely, unless
you can tune your apps rather carefully), or you have too much (your case).

2001-11-22 04:09:48

by listmail

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Its not so much that Swap speeds anything up, its that it allows the
machine process things more efficently because it can do more at once.


On Wed, 21 Nov 2001, war wrote:

> I do not understand something.
>
> How can having swap speed ANYTHING up?
>
> RAM = 1000MB/s.
> DISK = 10MB/s
>
> Ram is generally 1000x faster than a hard disk.
>
> No swap = fastest possible solution.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2001-11-22 05:25:12

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Followup to: <[email protected]>
By author: war <[email protected]>
In newsgroup: linux.dev.kernel
>
> I do not understand something.
>
> How can having swap speed ANYTHING up?
>

By allowing RAM to be better utilized.

-hpa
--
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <[email protected]>

2001-11-22 05:33:03

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Swap vs No Swap.

war wrote:

> Yeah, but when the disk starts swapping the system slows down to a halt.
>


No, when the disk starts *THRASHING* the system slows down to a halt.
If you are thrashing with swap you would be thrashing much worse without
swap.

-hpa


2001-11-22 05:31:42

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Yeah, but when the disk starts swapping the system slows down to a halt.


"H. Peter Anvin" wrote:

> Followup to: <[email protected]>
> By author: war <[email protected]>
> In newsgroup: linux.dev.kernel
> >
> > I do not understand something.
> >
> > How can having swap speed ANYTHING up?
> >
>
> By allowing RAM to be better utilized.
>
> -hpa
> --
> <[email protected]> at work, <[email protected]> in private!
> "Unix gives you enough rope to shoot yourself in the foot."
> http://www.zytor.com/~hpa/puzzle.txt <[email protected]>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2001-11-22 08:51:14

by Rik van Riel

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Wed, 21 Nov 2001, war wrote:

> I do not understand something.
> How can having swap speed ANYTHING up?
>
> RAM = 1000MB/s.
> DISK = 10MB/s
>
> Ram is generally 1000x faster than a hard disk.

This also means that the the caching of files from your
filesystem (say, /usr/bin/netscape or /lib/libc.so) is
1000x faster than reading them from disk.

> No swap = fastest possible solution.

Not true if having no swap means you do not have enough
memory to cache /lib/libc.so ;)

regards,

Rik
--
Shortwave goes a long way: irc.starchat.net #swl

http://www.surriel.com/ http://distro.conectiva.com/

2001-11-22 09:51:56

by Christian Borntraeger

[permalink] [raw]
Subject: Re: Swap vs No Swap.

> > Yeah, but when the disk starts swapping the system slows down to a halt.
> No, when the disk starts *THRASHING* the system slows down to a halt.
> If you are thrashing with swap you would be thrashing much worse without
> swap.

Not neccessarily.
Your swap early swap often paradigma works fine...as long as the swap
partition resides on an standalone harddisk without a data partition.

But imagine the situation that you have a higher band width streaming
application - e.g. viewing a video file. On the same hard disc there is a
swap partition. Cache is getting bigger and bigger until kernel starts to
swap.
Now the swapping algorithm writes on the harddisc. That troubles the hard
disc elevation mechanism, so that higher bandwidth readings starve, due to
head movements away from the data partitions towards the swap partition.

greetings

Christian Borntr?ger

2001-11-22 11:01:21

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 1:53 am, war wrote:
> I do not understand something.
>
> How can having swap speed ANYTHING up?

By providing ADDITIONAL storage. Yes, it's slower than RAM - but it's faster
than not having the storage at all.

> RAM = 1000MB/s.
> DISK = 10MB/s
>
> Ram is generally 1000x faster than a hard disk.
>
> No swap = fastest possible solution.

BS. You don't use swap INSTEAD of RAM, but AS WELL AS. Moving less frequently
used data to swap allows you to put more frequently used data in RAM, which
DOES speed things up. (At least, it does if the VM system works properly :P)

By your logic, we should switch off the system RAM, too: after all, L2 cache
is much faster again, so using RAM can only slow things down?


James.

2001-11-22 16:02:29

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Once again, I have enough ram where I am not going to run out for the things I
do.
I never need swap.

When the system swaps, it slows down the system responsiveness big time.


Oliver Neukum wrote:

> Am Donnerstag 22 November 2001 02:53 schrieb war:
> > I do not understand something.
> >
> > How can having swap speed ANYTHING up?
> >
> > RAM = 1000MB/s.
> > DISK = 10MB/s
> >
> > Ram is generally 1000x faster than a hard disk.
> >
> > No swap = fastest possible solution.
>
> At some point you will run out of ram. Then you have to start paging. The
> only question there is whether you page only mmaped files including program
> code or whether you also write out program data.
>
> HTH
> Oliver

2001-11-22 16:01:39

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Incorrect, my point is I have enough ram where I am not going to run out for the
things I do.

Using swap simply slows the system down!


James A Sutherland wrote:

> On Thursday 22 November 2001 1:53 am, war wrote:
> > I do not understand something.
> >
> > How can having swap speed ANYTHING up?
>
> By providing ADDITIONAL storage. Yes, it's slower than RAM - but it's faster
> than not having the storage at all.
>
> > RAM = 1000MB/s.
> > DISK = 10MB/s
> >
> > Ram is generally 1000x faster than a hard disk.
> >
> > No swap = fastest possible solution.
>
> BS. You don't use swap INSTEAD of RAM, but AS WELL AS. Moving less frequently
> used data to swap allows you to put more frequently used data in RAM, which
> DOES speed things up. (At least, it does if the VM system works properly :P)
>
> By your logic, we should switch off the system RAM, too: after all, L2 cache
> is much faster again, so using RAM can only slow things down?
>
> James.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2001-11-22 16:09:29

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 4:00 pm, war wrote:
> Incorrect, my point is I have enough ram where I am not going to run out
> for the things I do.

There's more to it than "not run out". You have some fixed amount of RAM; if
the VM is working properly, adding swap will IMPROVE performance, because
that fixed amount of RAM is used more efficiently.

Obviously, there are cases where removing swap breaks the system entirely,
but even in other cases, adding swap should *never* degrade performance. (In
theory, anyway; in practice, it still needs tuning...)

> Using swap simply slows the system down!

In which case, the VM isn't working properly; it SHOULD page out infrequently
used data to make more room for caching frequently used files.


James.

2001-11-22 16:12:52

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 4:01 pm, war wrote:
> Once again, I have enough ram where I am not going to run out for the
> things I do.
> I never need swap.
>
> When the system swaps, it slows down the system responsiveness big time.

"when it swaps" is meaningless: Linux ALWAYS swaps when there is swapspace.
Do you mean when it *thrashes*? Or does your system have problems during I/O
such as not using DMA for disk access?


James.

2001-11-22 16:11:59

by Elgar, Jeremy

[permalink] [raw]
Subject: RE: Swap vs No Swap.

Hum think I'm going to test this idea out tonight, quick question without
swap at what point would the kernel stop giving memory up for cache
purposes. For example I noticed on Tuesday whist doing a back up of a file
system (in-line tar cd untar) I was left with ~4 Mb left having nearly the
rest of my 2Gb Ram used for cache.

Would this ram be given back to the free pool much more readily?


> -----Original Message-----
> From: war [mailto:[email protected]]
> Sent: 22 November 2001 16:01
> To: Oliver Neukum; [email protected]
> Subject: Re: Swap vs No Swap.
>
>
> Once again, I have enough ram where I am not going to run out
> for the things I
> do.
> I never need swap.
>
> When the system swaps, it slows down the system
> responsiveness big time.
>
>
> Oliver Neukum wrote:
>
> > Am Donnerstag 22 November 2001 02:53 schrieb war:
> > > I do not understand something.
> > >
> > > How can having swap speed ANYTHING up?
> > >
> > > RAM = 1000MB/s.
> > > DISK = 10MB/s
> > >
> > > Ram is generally 1000x faster than a hard disk.
> > >
> > > No swap = fastest possible solution.
> >
> > At some point you will run out of ram. Then you have to
> start paging. The
> > only question there is whether you page only mmaped files
> including program
> > code or whether you also write out program data.
> >
> > HTH
> > Oliver
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2001-11-22 16:23:11

by Stephan von Krawczynski

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, 22 Nov 2001 16:11:29 -0000
"Elgar, Jeremy" <[email protected]> wrote:

> Hum think I'm going to test this idea out tonight, quick question without
> swap at what point would the kernel stop giving memory up for cache
> purposes. For example I noticed on Tuesday whist doing a back up of a file
> system (in-line tar cd untar) I was left with ~4 Mb left having nearly the
> rest of my 2Gb Ram used for cache.
>
> Would this ram be given back to the free pool much more readily?

Not to my knowledge. Since I was pretty much bitten by swap in former days I
plugged in more RAM and stopped swap completely. I must admit that it didn't
get any faster, but trashing is gone (obviously). But this is only because of
my own dumbness placing swap on the same drive as root-fs. I guess it would be
a good idea to use the former small hds (1-2 GB) for swap completely, so any
bad interaction with normal fs is omitted.
BTW maybe you should try the latest preX versions, they tend to have more
_free_ mem available and perform pretty ok on my system.

Regards,
Stephan

2001-11-22 16:22:59

by Ryan Cumming

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On November 22, 2001 08:11, Elgar, Jeremy wrote:
> Hum think I'm going to test this idea out tonight, quick question without
> swap at what point would the kernel stop giving memory up for cache
> purposes. For example I noticed on Tuesday whist doing a back up of a file
> system (in-line tar cd untar) I was left with ~4 Mb left having nearly the
> rest of my 2Gb Ram used for cache.

The general idea behind VM is pretty simple: keep the most frequently used
pages in the fastest storage possible. The tar backup pushed a lot of pages
that looked more frequently used in to RAM, and swapped out programs that
weren't being used at all in favour of this cache. Now that the backup is
completed, and only a small portion of the cache you used for backup is being
used, these unused cache pages can very easily be 'given up' to be used as
free memory again. A VM that -doesn't care- if it's dealing with program
pages, buffer pages, shared memory, or cache pages when making swapping
decisions is much more robust than a VM that tries to 'outsmart' itself.

-Ryan

2001-11-22 16:27:11

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Why have SWAP if you don't need it - answer that.?

James A Sutherland wrote:

> On Thursday 22 November 2001 1:53 am, war wrote:
> > I do not understand something.
> >
> > How can having swap speed ANYTHING up?
>
> By providing ADDITIONAL storage. Yes, it's slower than RAM - but it's faster
> than not having the storage at all.
>
> > RAM = 1000MB/s.
> > DISK = 10MB/s
> >
> > Ram is generally 1000x faster than a hard disk.
> >
> > No swap = fastest possible solution.
>
> BS. You don't use swap INSTEAD of RAM, but AS WELL AS. Moving less frequently
> used data to swap allows you to put more frequently used data in RAM, which
> DOES speed things up. (At least, it does if the VM system works properly :P)
>
> By your logic, we should switch off the system RAM, too: after all, L2 cache
> is much faster again, so using RAM can only slow things down?
>
> James.

2001-11-22 16:30:10

by Elgar, Jeremy

[permalink] [raw]
Subject: RE: Swap vs No Swap.

Okay I agree with that it was just quite interesting to see the mem usage.
I also agree with what people have said (VM should not have a noticeable
effect on the performance of the system) but would like to check the
original posters point (that disabling swap does increases performance.)

Also Id like to say that in general ive not had problems with the VM system
(although rarely go into swap (maybe 300 Mb after doing something
particularly memory hungry)





> -----Original Message-----
> From: Ryan Cumming [mailto:[email protected]]
> Sent: 22 November 2001 16:22
> To: Elgar, Jeremy
> Cc: [email protected]
> Subject: Re: Swap vs No Swap.
>
>
> On November 22, 2001 08:11, Elgar, Jeremy wrote:
> > Hum think I'm going to test this idea out tonight, quick
> question without
> > swap at what point would the kernel stop giving memory up for cache
> > purposes. For example I noticed on Tuesday whist doing a
> back up of a file
> > system (in-line tar cd untar) I was left with ~4 Mb left
> having nearly the
> > rest of my 2Gb Ram used for cache.
>
> The general idea behind VM is pretty simple: keep the most
> frequently used
> pages in the fastest storage possible. The tar backup pushed
> a lot of pages
> that looked more frequently used in to RAM, and swapped out
> programs that
> weren't being used at all in favour of this cache. Now that
> the backup is
> completed, and only a small portion of the cache you used for
> backup is being
> used, these unused cache pages can very easily be 'given up'
> to be used as
> free memory again. A VM that -doesn't care- if it's dealing
> with program
> pages, buffer pages, shared memory, or cache pages when
> making swapping
> decisions is much more robust than a VM that tries to
> 'outsmart' itself.
>
> -Ryan
>

2001-11-22 16:35:50

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Unworkable?
How is it unworkable for my situation?
I have 1GB of memory, even when I launch every application I can, I still have
350MB left over!

Mark Hahn wrote:

> > You can say whatever you want.
>
> gee, thanks.
>
> > When my box starts swapping, the shit hits the fan, slows down dramatically.
>
> then your disks are misconfigured.
>
> > If you have no need for swap, you shouldn't have it, it simply slows the
> > system down big time.
>
> sure, that's obvious. it's also unworkable in general.
>
> >
> >
> > Mark Hahn wrote:
> >
> > > > How can having swap speed ANYTHING up?
> > >
> > > simple: under memory load, it's more efficient to scavenge
> > > idle pages so they can be used for some "hotter" purpose.
> > > there usually are *some* pages in any process which are
> > > only used at startup, or very rarely used. if there's no
> > > memory pressure, sure, leave them there. if there is some
> > > other use for the memory, even caching files, then it's more
> > > efficient to swap those pages (assuming they're dirty).
> > >
> > > swap is a sound way of making more efficient use of limited ram.
> > >
> > > > RAM = 1000MB/s.
> > > > DISK = 10MB/s
> > >
> > > well, modern disks are 40 MB/s, and a typical non-rambus PC
> > > has only around 600 MB/s dram bandwidth, depending on how you
> > > measure it, etc.
> > >
> > > > Ram is generally 1000x faster than a hard disk.
> > >
> > > no, more like 20x; it can be up to around 80x (1.6 GB/s pc800
> > > and a fairly pathetic 20 MB/s disk). the *latency* ratio can
> > > be much higher (10 ms vs 200 ns).
> > >
> > > > No swap = fastest possible solution.
> > >
> > > false in general. the only case where this is true is where
> > > you either have just the right amount of ram (unlikely, unless
> > > you can tune your apps rather carefully), or you have too much (your case).
> > >
> > > -
> > > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > > the body of a message to [email protected]
> > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at http://www.tux.org/lkml/
> >
>
> --
> operator may differ from spokesperson. [email protected]
> http://java.mcmaster.ca/~hahn

2001-11-22 16:38:10

by Ryan Cumming

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On November 22, 2001 08:25, war wrote:
> Why have SWAP if you don't need it - answer that.?

> > BS. You don't use swap INSTEAD of RAM, but AS WELL AS. Moving less
> > frequently used data to swap allows you to put more frequently used data
> > in RAM, which DOES speed things up. (At least, it does if the VM system
> > works properly :P)

Are you even reading what they're saying? Having swap lets you move less
frequently used data to disk in favour of having more frequently used data in
RAM.

Personally, I have more than enough RAM to run a fairly busy KDE2 desktop,
and still have over 128megs in disk cache. And I still run with swap. The VM
seems to find about 40megs of data I'm -simply not using-, and it now has the
freedom to push that to swap so it can cache things that I -do use-. Although
the more RAM you have, the less significant the results are, you'll find that
in normal desktop/workstation/server use, the kernel will -always- find
something to swap out to give itself more cache, and more cache is a very
good thing. It's not fucking rocket science.

-Ryan

2001-11-22 16:38:20

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

The bottom line here is:

There is no need for swap if you have enough ram.
Using swap with more than enough ram does absolutley nothing for the system,
except by degrading the performance of it.


James A Sutherland wrote:

> On Thursday 22 November 2001 4:01 pm, war wrote:
> > Once again, I have enough ram where I am not going to run out for the
> > things I do.
> > I never need swap.
> >
> > When the system swaps, it slows down the system responsiveness big time.
>
> "when it swaps" is meaningless: Linux ALWAYS swaps when there is swapspace.
> Do you mean when it *thrashes*? Or does your system have problems during I/O
> such as not using DMA for disk access?
>
> James.

On Thursday 22 November 2001 4:00 pm, war wrote:
> Incorrect, my point is I have enough ram where I am not going to run out
> for the things I do.

There's more to it than "not run out". You have some fixed amount of RAM; if
the VM is working properly, adding swap will IMPROVE performance, because
that fixed amount of RAM is used more efficiently.

Obviously, there are cases where removing swap breaks the system entirely,
but even in other cases, adding swap should *never* degrade performance. (In
theory, anyway; in practice, it still needs tuning...)

> Using swap simply slows the system down!

In which case, the VM isn't working properly; it SHOULD page out infrequently
used data to make more room for caching frequently used files.


James.

2001-11-22 16:57:53

by Rik van Riel

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, 22 Nov 2001, James A Sutherland wrote:
> On Thursday 22 November 2001 4:00 pm, war wrote:
> > Incorrect, my point is I have enough ram where I am not going to run out
> > for the things I do.

> Obviously, there are cases where removing swap breaks the system
> entirely, but even in other cases, adding swap should *never* degrade
> performance. (In theory, anyway; in practice, it still needs
> tuning...)

Not quite true. The VM cannot look into the future, so if
you have swap it could have just swapped out the application
on the desktop you're about to switch to ;)

If you have more than enough swap, you can be sure that the
program data will stay in ram and at most the executable code
needs to be read in again from disk.

regards,

Rik
--
DMCA, SSSCA, W3C? Who cares? http://thefreeworld.net/

http://www.surriel.com/ http://distro.conectiva.com/

2001-11-22 17:39:37

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 4:25 pm, war wrote:
> Why have SWAP if you don't need it - answer that.?

Having it is supposed to improve performance. If you take two identical
machines, and enable swap on one but not the other, the first machine should
have better performance: it can cache the FS more effectively.

Now, if you have INSANE amounts of RAM (i.e. enough to have everything
running in RAM *AND* every file you access cached) the swap will make no
difference at all. Under any other circumstances, it should make things
better.


James.

2001-11-22 17:38:07

by Thomas S. Iversen

[permalink] [raw]
Subject: Re: Swap vs No Swap.

> There is no need for swap if you have enough ram.

Turn it off. How hard can that be?

Thomas

2001-11-22 17:42:07

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 4:36 pm, war wrote:
> The bottom line here is:
>
> There is no need for swap if you have enough ram.
> Using swap with more than enough ram does absolutley nothing for the
> system, except by degrading the performance of it.

If the system has so much RAM that EVERYTHING fits in RAM - programs, data
and FS cache - then the swap won't be touched anyway, and makes no
difference. This is rather unlikely on a PC; in practice, adding swap should
always improve matters. (Of course, the VM isn't perfect yet...)


James.

2001-11-22 17:42:57

by Bjorn Wesen

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, 22 Nov 2001, war wrote:
> There is no need for swap if you have enough ram.
> Using swap with more than enough ram does absolutley nothing for the system,
> except by degrading the performance of it.

You're too fast with drawing conclusions. You say you have "enough" ram -
tell me, how big is your harddisk ? Is it less than 1 GB ? Do you use more
than 1 GB of data on your harddisk regularly ?

RAM is not just used to keep your programs in, but also to hold a working
copy of your dataset on the hard-disk. If the programs you use
concurrently use 500 MB RAM and never more, and you have 1 GB RAM, you
have 500 MB over for caching your hard disk content. As long as you only
access a footprint of 500 MB on your disk, you're fine.

But as soon as you start accessing more data which in total will add up to
more than that 1 GB RAM, there is the _potential_ for a swap to speed up
access. There's absolutely nothing which say it _has_ to speed it up in a
_particular_ case, but generally it can.

Also remember that a "swap" only swaps dirty pages. Your programs are run
directly from the page-cache and can be flushed from that even if you have
"disabled swap". The only thing that differs by adding swap is another
freedom for the VM system to prioritize memory. Sometimes it does this
badly, and you get upset, and sometimes it does it well.

/Bjorn

2001-11-22 17:58:29

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Thank you for understanding!

James A Sutherland wrote:

> On Thursday 22 November 2001 4:25 pm, war wrote:
> > Why have SWAP if you don't need it - answer that.?
>
> Having it is supposed to improve performance. If you take two identical
> machines, and enable swap on one but not the other, the first machine should
> have better performance: it can cache the FS more effectively.
>
> Now, if you have INSANE amounts of RAM (i.e. enough to have everything
> running in RAM *AND* every file you access cached) the swap will make no
> difference at all. Under any other circumstances, it should make things
> better.
>
> James.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2001-11-22 18:00:59

by Justin Piszcz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

This is incorrect.
SWAP is used on a [1GB ram/2GB swap system].

I talked to Rik about this.
He said generally SWAP is a good thing and increases performance.

However, in my case it does not.

Nov 22 12:18:41 <war> riel: For a single user system.
Nov 22 12:18:43 <ata> war: what are you trying to do ?
Nov 22 12:18:44 <riel> war: it all depends on what you use the computer for
Nov 22 12:18:56 <riel> war: that's a very important thing to specify ;)
Nov 22 12:18:57 <war> General X apps, staroffice/netscape/media
stuff(aviplay)/etc
Nov 22 12:19:06 <war> compiling apps once and awhile
Nov 22 12:19:13 <riel> war: ok, in that case you omost likely don't need swap
Nov 22 12:19:32 <riel> war: but you really _need_ to tell what you are using
the computer for before anybody can give a sensible answer ;)
Nov 22 12:19:43 <war> riel: thats what I thought too, yet people still say I do
even after I told them what I was using it for
Nov 22 12:19:52 <ata> learath: nope 1gb will still win just one app will loose
and die
Nov 22 12:19:54 <war> riel: I sent the list of my ps auxww (512 processes) and
I still had 350MB left over.
Nov 22 12:20:05 <riel> war: yup, I saw that



James A Sutherland wrote:

> On Thursday 22 November 2001 4:36 pm, war wrote:
> > The bottom line here is:
> >
> > There is no need for swap if you have enough ram.
> > Using swap with more than enough ram does absolutley nothing for the
> > system, except by degrading the performance of it.
>
> If the system has so much RAM that EVERYTHING fits in RAM - programs, data
> and FS cache - then the swap won't be touched anyway, and makes no
> difference. This is rather unlikely on a PC; in practice, adding swap should
> always improve matters. (Of course, the VM isn't perfect yet...)
>
> James.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2001-11-22 18:09:09

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 5:56 pm, war wrote:
> This is incorrect.
> SWAP is used on a [1GB ram/2GB swap system].

As it should be. Page out unused data to make room for more cache. This
*should* improve performance overall. (Yes, latency suffers to boost
throughput. A fairly common tradeoff; you'll be glad of it under heavier
load...)

You have "enough" RAM in that the machine doesn't crash under load, but NOT
enough that swap would go unused.

> I talked to Rik about this.
> He said generally SWAP is a good thing and increases performance.
>
> However, in my case it does not.

As I've said, the VM doesn't always make the right choice :)


James.

2001-11-22 18:52:54

by FD Cami

[permalink] [raw]
Subject: Re: Swap vs No Swap.

Rik van Riel wrote:

> On Thu, 22 Nov 2001, James A Sutherland wrote:
>>Obviously, there are cases where removing swap breaks the system
>>entirely, but even in other cases, adding swap should *never* degrade
>>performance. (In theory, anyway; in practice, it still needs
>>tuning...)
>>
>
> Not quite true. The VM cannot look into the future, so if
> you have swap it could have just swapped out the application
> on the desktop you're about to switch to ;)


I tend to agree. Especially since in some cases (i.e. after
a long compilation (read : lots of code)), the VM has the most
excellent idea to swap out all the GUI (X+apps) and everyone
here knows how long it can be to restore the GUI in that case.

Obviously the problem is very much lessened, in my case, when
i put the swap partition on the *other* drive than the root fs.
Both are ATA100 (40GB 60GXPs), and the system is more responsive
with swap on hdc while / in on hda, than both on hda.

Fran?ois

2001-11-22 18:59:14

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 6:56 pm, Fran?ois Cami wrote:
> Rik van Riel wrote:
> > On Thu, 22 Nov 2001, James A Sutherland wrote:
> >>Obviously, there are cases where removing swap breaks the system
> >>entirely, but even in other cases, adding swap should *never* degrade
> >>performance. (In theory, anyway; in practice, it still needs
> >>tuning...)
> >
> > Not quite true. The VM cannot look into the future, so if
> > you have swap it could have just swapped out the application
> > on the desktop you're about to switch to ;)
>
> I tend to agree. Especially since in some cases (i.e. after
> a long compilation (read : lots of code)), the VM has the most
> excellent idea to swap out all the GUI (X+apps) and everyone
> here knows how long it can be to restore the GUI in that case.

Use-once should avoid *most* of that, though not all; all your .c files
should be read in once each by gcc, and never touched again. Of course the
headers need to be cached, and the .o files will be accessed multiple times
too.

> Obviously the problem is very much lessened, in my case, when
> i put the swap partition on the *other* drive than the root fs.
> Both are ATA100 (40GB 60GXPs), and the system is more responsive
> with swap on hdc while / in on hda, than both on hda.

Hmm... if you've experimented with this, how does this setup compare to a
striped RAID of hda+hdc used for root and swap? (i.e. is the speedup down to
splitting accesses between two spindles?)


James.

2001-11-22 19:14:34

by FD Cami

[permalink] [raw]
Subject: Re: Swap vs No Swap.

James A Sutherland wrote:

>>Obviously the problem is very much lessened, in my case, when
>>i put the swap partition on the *other* drive than the root fs.
>>Both are ATA100 (40GB 60GXPs), and the system is more responsive
>>with swap on hdc while / in on hda, than both on hda.
>>
>
> Hmm... if you've experimented with this, how does this setup compare to a
> striped RAID of hda+hdc used for root and swap? (i.e. is the speedup down to
> splitting accesses between two spindles?)


I haven't, but it's a good idea, I may give it a try, but not very soon.

Fran?ois

2001-11-22 19:37:39

by G . Sumner Hayes

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, Nov 22, 2001 at 08:17:43PM +0100, Fran?ois Cami wrote:
> James A Sutherland wrote:
>
> > Hmm... if you've experimented with this, how does this setup compare
> > to a striped RAID of hda+hdc used for root and swap? (i.e. is the
> > speedup down to splitting accesses between two spindles?)
>
> I haven't, but it's a good idea, I may give it a try, but not very soon.

You shouldn't need striping for this--if you have two swap partitions
with equal priority, the kernel will "stripe" them itself.

At least that's my understanding.

Sumner

2001-11-22 20:38:04

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thursday 22 November 2001 7:36 pm, G . Sumner Hayes wrote:
> On Thu, Nov 22, 2001 at 08:17:43PM +0100, Fran?ois Cami wrote:
> > James A Sutherland wrote:
> > > Hmm... if you've experimented with this, how does this setup compare
> > > to a striped RAID of hda+hdc used for root and swap? (i.e. is the
> > > speedup down to splitting accesses between two spindles?)
> >
> > I haven't, but it's a good idea, I may give it a try, but not very soon.
>
> You shouldn't need striping for this--if you have two swap partitions
> with equal priority, the kernel will "stripe" them itself.
>
> At least that's my understanding.

It'll stripe the SWAP area, but not the root FS; what I'm interested in is
how performance is affected by splitting both across two devices, compared to
putting one on each.


James.

2001-11-22 21:19:03

by Mike Galbraith

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, 22 Nov 2001, Thomas S. Iversen wrote:

> > There is no need for swap if you have enough ram.
>
> Turn it off. How hard can that be?

That was my initial reaction too. I don't have near the memory
he does and am very satisfied with VM throughput. I'm seeing
some bad interactivity problems when loading my box while X/KDE
is resident though.. things I don't see in shell land at all.

-Mike

2001-11-23 06:33:06

by Charles Marslett

[permalink] [raw]
Subject: Re: Swap vs No Swap.

James A Sutherland wrote:
>
> On Thursday 22 November 2001 4:00 pm, war wrote:
> > Incorrect, my point is I have enough ram where I am not going to run out
> > for the things I do.
>
> There's more to it than "not run out". You have some fixed amount of RAM; if
> the VM is working properly, adding swap will IMPROVE performance, because
> that fixed amount of RAM is used more efficiently.
>
> Obviously, there are cases where removing swap breaks the system entirely,
> but even in other cases, adding swap should *never* degrade performance. (In
> theory, anyway; in practice, it still needs tuning...)
>
> > Using swap simply slows the system down!
>
> In which case, the VM isn't working properly; it SHOULD page out infrequently
> used data to make more room for caching frequently used files.
>
> James.

I disagree. It is true that a VM could be designed sufficiently complex that
it would properly analyze every possible sequence of execution and have perfect
prescience. It would probably take a few hundred gigabytes of table structure
to do that and that in itself will slow down the VM just scanning those tables,
I dare say.

In short, no VM is going to work perfectly -- it is extrapolating a model of
behavior to a real world sequence of events and as such there will always be
some real world set of programs and events that will make it worse than some
other model of behavior (VM), including the one that never pages at all. We
just want that to happen rarely (whatever that means).

A VM that is working properly is one that satisfies the beholder (sort of like
beauty). And in fact, if you look at the various similar discussions on
Microsoft newsgroups (sorry ;-), you may notice they don't seem to be able
to come up with a mechanism that handles large uniform access working sets
and still works well with "normal" (highly peaked) working sets. So I doubt
it is an easy problem.

--Charles

2001-11-23 09:14:14

by James A Sutherland

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Friday 23 November 2001 6:30 am, Charles Marslett wrote:
> James A Sutherland wrote:
> > On Thursday 22 November 2001 4:00 pm, war wrote:
> > > Incorrect, my point is I have enough ram where I am not going to run
> > > out for the things I do.
> >
> > There's more to it than "not run out". You have some fixed amount of RAM;
> > if the VM is working properly, adding swap will IMPROVE performance,
> > because that fixed amount of RAM is used more efficiently.
> >
> > Obviously, there are cases where removing swap breaks the system
> > entirely, but even in other cases, adding swap should *never* degrade
> > performance. (In theory, anyway; in practice, it still needs tuning...)
> >
> > > Using swap simply slows the system down!
> >
> > In which case, the VM isn't working properly; it SHOULD page out
> > infrequently used data to make more room for caching frequently used
> > files.
> >
> > James.
>
> I disagree. It is true that a VM could be designed sufficiently complex
> that it would properly analyze every possible sequence of execution and
> have perfect prescience. It would probably take a few hundred gigabytes of
> table structure to do that and that in itself will slow down the VM just
> scanning those tables, I dare say.

That wasn't quite what I had in mind :)

> In short, no VM is going to work perfectly -- it is extrapolating a model
> of behavior to a real world sequence of events and as such there will
> always be some real world set of programs and events that will make it
> worse than some other model of behavior (VM), including the one that never
> pages at all. We just want that to happen rarely (whatever that means).

Yes, sometimes you'll get better behaviour in a specific case by "disabling"
swap (i.e. forcing the kernel to page code instead), which in other cases
causes nasty disk thrashing. In this case, though, I think the VM could do a
much better job than it does presently; I've a feeling Rik's would perform
better in this case, for example...

> A VM that is working properly is one that satisfies the beholder (sort of
> like beauty). And in fact, if you look at the various similar discussions
> on Microsoft newsgroups (sorry ;-), you may notice they don't seem to be
> able to come up with a mechanism that handles large uniform access working
> sets and still works well with "normal" (highly peaked) working sets. So I
> doubt it is an easy problem.

Nobody said VM coding was easy - or that Microsoft had got it right :)


James.

2001-11-23 16:48:46

by Charles Marslett

[permalink] [raw]
Subject: Re: Swap vs No Swap.

James A Sutherland wrote:
>
> Nobody said VM coding was easy - or that Microsoft had got it right :)
>
> James.

Agreed, exactly what I meant to say,....

--Charles

2001-11-23 22:08:46

by Daniel Gryniewicz

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, 22 Nov 2001 16:12:32 +0000
James A Sutherland <[email protected]> wrote:

> "when it swaps" is meaningless: Linux ALWAYS swaps when there is swapspace.
> Do you mean when it *thrashes*? Or does your system have problems during I/O

> such as not using DMA for disk access?

[17:03 athena] dang> free
total used free shared buffers cached
Mem: 255304 184416 70888 716 12636 77524
-/+ buffers/cache: 94256 161048
Swap: 128484 0 128484
[17:03 athena] dang> uname -a
Linux athena.fprintf.net 2.4.13-ac7-preempt-sse #1 Mon Nov 5 14:06:53 EST 2001
i686 unknown
[17:04 athena] dang>

Linux does not always swap.

Daniel

---
Recursion n.:
See Recursion.
-- Random Shack Data Processing Dictionary

2001-11-26 20:19:21

by Kent Borg

[permalink] [raw]
Subject: Re: Swap vs No Swap.

On Thu, Nov 22, 2001 at 11:34:29AM -0500, war wrote:
> Unworkable?
> How is it unworkable for my situation?
> I have 1GB of memory, even when I launch every application I can, I still have
> 350MB left over!

Yes, even X can't easily use up 1 GB by just launching a bunch of
applications.

Times have changed. It used to be that RAM was very dear and even
slow and small disks of olden days were worth using to extend the RAM
via a virtual memory scheme. In many cases today it is quite workable
to throw more RAM at a computer than one can easily use without
"cheating" (say, letting Netscape leak for a few weeks). But not all
cases. Some problems are bigger than yours (big databases love RAM,
some video post production loves RAM), and some machines are smaller
than yours (in physical size, power usage, cost).

If you use your computer in such a way that you keep hundreds of
megabytes of RAM free and having swap slows you down, that is a bug
about which people on this list will want hear details.

If you start to use your computer more heavily so that you start to
use swap, and swap slows you down, then there will be interest in how
are doing that. It might be a bug, it might be an unfortunate
accident of not being able to have one VM for all occasions.

If you start to heavily use swap and it slows you down (when compared
to having no swap), that is also a bug. Tell the world the details.


-kb, the Kent whose basement server runs with only 64 MB RAM, and yet
though it is always using some swap, the swap usage always seems to be
a smaller number than the amount of RAM used for cache.