Skip to contentSkip to conversation

Swap

DISCUSSION war 10 participants 20 messages Nov 18, 2001 – Nov 20, 2001

lore
Share & tools
lore

war

author
#0 lore raw

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

#1 lore raw
Quoted 4 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

James.

author
#2 lore raw
In reply to war

Well, without the swap, everything seems to be about 100% more responsive when I execute any task.
I see how it works now.

Quoted 19 lines · James A Sutherland
Quoted 4 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

James.

#3 lore raw
In reply to war

I don't understand why it should be better with swap then... I mean, my comp seems to run so much faster (it doesn't take time to switch from one app to another, i mean) *without* swap.
And I see no benefits to having an active swap, other than making my hard drive work harder.

comp is PIII933/512MB on ATA100
kernel is 2.4.14 with XFS patch.

François

Quoted 36 lines · war

Well, without the swap, everything seems to be about 100% more responsive when I execute any task.
I see how it works now.

Quoted 15 lines · James A Sutherland
Quoted 5 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

Quoted 6 lines

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

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/

#4 lore raw

I agree... After a while it always seems that 80% or more of my RAM is
used for cache and buffers while my open, but not currently used apps get pushed onto disk. Then when I decide to switch to that mozilla window of emacs session I have to wait for it to be loaded from disk again. Also considering the kind of disk activity this box has, the data in the cache is mostly the last few hour's MP3's, in other words utterly useless as that data will not be used again. I'd rather my apps stayed in RAM...

Is there a way to limit the size of the cache?

/cyr

Quoted 61 lines

I don't understand why it should be better with swap then... I mean, my comp seems to run so much faster (it doesn't take time to switch from one app to another, i mean) *without* swap.
And I see no benefits to having an active swap, other than making my hard drive work harder.

comp is PIII933/512MB on ATA100
kernel is 2.4.14 with XFS patch.

François

Quoted 26 lines · war

Well, without the swap, everything seems to be about 100% more responsive when I execute any task.
I see how it works now.

Quoted 19 lines · James A Sutherland
Quoted 5 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

Quoted 10 lines
Quoted 2 lines

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/

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

Signature · 5 lines
-----------------------------------------------------------------------
Holly: Purple alert! Purple alert!
Lister: What's a purple alert?
Holly: Well, it's like not as bad as a red a alert, but a bit worse
than a blue alert -- sort of a mauve alert.
author
#5 lore raw
In reply to war

I completely agree with you.
p3/866/1024MB here.
Everything seems much faster; and I can run 512 processes of varying memory "weights" without a hitch.

Quoted 49 lines · François Cami

I don't understand why it should be better with swap then... I mean, my comp seems to run so much faster (it doesn't take time to switch from one app to another, i mean) *without* swap.
And I see no benefits to having an active swap, other than making my hard drive work harder.

comp is PIII933/512MB on ATA100
kernel is 2.4.14 with XFS patch.

François

Quoted 36 lines · war

Well, without the swap, everything seems to be about 100% more responsive when I execute any task.
I see how it works now.

Quoted 15 lines · James A Sutherland
Quoted 5 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

Quoted 6 lines

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

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/

#6 lore raw
In reply to war
Quoted 10 lines · On 20011118 James A Sutherland wrote:
Quoted 4 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

Sure ??? Where ?? What disk space uses it to swap pages to ?

Quoted 4 lines

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

You get thrashing because you don have anything cached. So you can get a point (fill all your space with apps and data) where each file read is _REALLY_ a disk read, not just a transfer from cache (that is what usually happens).

Quoted 5 lines

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

You swap out pages, not data or code. Kernel does not care if the page contains code or data. Try (on a swap enabled box) this: open mozilla or staroffice (a big gui app), let it open and don't use it, fill your ram with other apps and try to pull down a menu from mozilla. It has an unusual delay, the time to get mozilla CODE pages back from swap. That is why a system with no swap is more responsive.

Yes, a box without swap runs faster, but if you *don't do anything* with it. The test shown in previous mails had a ton of apps opened *doing nothing*. Try do do a grep several times on the kernel source tree for example in that scenario. Or a kernel build. They will be dog slow (all the tries). Try the same on a box with swap, the second time much things are cached and it flies.

Signature · 4 lines
J.A. Magallon                           #  Let the source be with you...        
mailto:[email protected]
Mandrake Linux release 8.2 (Cooker) for i586
Linux werewolf 2.4.15-pre6-beo #1 SMP Sun Nov 18 10:25:01 CET 2001 i686
#7 lore raw
Quoted 6 lines · In article <[email protected]> you wrote:
Quoted 4 lines

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

Sure ??? Where ?? What disk space uses it to swap pages to ?

It does not swap code pages out. It simply forgets them and reloads ("page them in") them when needed.

Greeetings
Bernd

#8 lore raw
In reply to war
Quoted 5 lines · J.A. Magallon

Yes, a box without swap runs faster, but if you *don't do anything* with it. The test shown in previous mails had a ton of apps opened *doing nothing*. Try do do a grep several times on the kernel source tree for example in that scenario. Or a kernel build. They will be dog slow (all the tries). Try the same on a box with swap, the second time much things are cached and it flies.

I tend to both agree and disagree with you.

fact :
I don't use more than 350MB of my 512MB for apps (and that's a worst case scenario), and I guess than 150MB of RAM is enough for caching, at least in my case.

I agree that a box that uses 99% of its RAM for apps will be dog slow ; but I simply have to disagree with swapping apps I *use* when 66% of my RAM is free.
Have you tried pulling openoffice from swap to RAM ?
If doing a second [and third, and so on] grep on the kernel source tree is dog slow without swap, pulling openoffice from swap is *snail* slow.

François

#9 lore raw
In reply to war
Quoted 4 lines · J.A. Magallon
Quoted 3 lines · On 20011118 James A Sutherland wrote:
Quoted 2 lines · war

It is amazing that I could run all of that stuff, because:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

Sure ??? Where ?? What disk space uses it to swap pages to ?

The code is "swapped" to the original file it was loaded from. You just free up the pages for someone else to use until you get a page fault in that task, then reload it from the original executable. That may have something to do with the fact that he gets better performance without a swap file allocated, since code swaps never write, only read (half as much disk I/O). I could see some workloads that essentially use every bit of data all the time, and swapping code only is an optimization. Nothing I've ever profiled worked that way, though. And I thought even in this case the system would tend to swap code in preference to dirty data (I have to go back and look at the code to say for sure, though).

Quoted 8 lines
Quoted 4 lines

(This is why you can still get "disk thrashing" without any swap - in fact, it's more likely in this case than it is with some swap added - you are just forcing your binaries to take more of the swapping load instead.)

You get thrashing because you don have anything cached. So you can get a point (fill all your space with apps and data) where each file read is _REALLY_ a disk read, not just a transfer from cache (that is what usually happens).

But that would never run faster than enabling the cache (unless the cache code was competitive with Microsoft's).

Quoted 11 lines
Quoted 4 lines

So: with swapspace, the kernel swaps out a few hundred Mb of unused data, to make room for more code. Without it, the kernel is forced to swap out code pages instead. The big news here is...?

You swap out pages, not data or code. Kernel does not care if the page contains code or data. Try (on a swap enabled box) this: open mozilla or staroffice (a big gui app), let it open and don't use it, fill your ram with other apps and try to pull down a menu from mozilla. It has an unusual delay, the time to get mozilla CODE pages back from swap. That is why a system with no swap is more responsive.

Check out the thread entitled "Executing binaries on new filesystem" -- they talk quite a bit about mmap() and how it is used in loading code space. You are right about swapping out pages, not data or code, but the pages are written only if they are dirty. A page that is not dirty does not need to be written to be swapped out, and code pages are almost never dirty (I think). So they can be "swapped" out without any place to write them, unlike data pages that have anything but zeros in them.

Quoted 5 lines

Yes, a box without swap runs faster, but if you *don't do anything* with it. The test shown in previous mails had a ton of apps opened *doing nothing*. Try do do a grep several times on the kernel source tree for example in that scenario. Or a kernel build. They will be dog slow (all the tries). Try the same on a box with swap, the second time much things are cached and it flies.

Ah! This may well be the explanation for the apparent performance boost. Now I'm really interested in digging into the paging algorithms....

Quoted 5 lines

--
J.A. Magallon # Let the source be with you...
mailto:[email protected]
Mandrake Linux release 8.2 (Cooker) for i586
Linux werewolf 2.4.15-pre6-beo #1 SMP Sun Nov 18 10:25:01 CET 2001 i686

--Charles

#10 lore raw
In reply to war
Quoted 12 lines · On 20011118 Charles Marslett wrote:
Quoted 11 lines · J.A. Magallon
Quoted 9 lines · On 20011118 James A Sutherland wrote:
Quoted 4 lines · war

It is amazing that I could run all of that stuff, because:

When I have swap on, and if I run all of those programs, 200-400MB of swap is used.

Yep. There's a reason for that: the kernel is *ALWAYS* able to swap pages out to disk - even without "swap space". Disabling swapspace simply forces the kernel to swap out more code, since it cannot swap out any data.

Quoted 7 lines
Quoted 1 line

Sure ??? Where ?? What disk space uses it to swap pages to ?

The code is "swapped" to the original file it was loaded from. You just free up the pages for someone else to use until you get a page fault in that task, then reload it from the original executable. That may have something to do with the fact that he gets better performance without a swap file allocated, since code swaps never write, only read (half as much disk I/O). I could see

Yup, I missed mmapped pages. You can drop them and reread, yes.

Signature · 4 lines
J.A. Magallon                           #  Let the source be with you...        
mailto:[email protected]
Mandrake Linux release 8.2 (Cooker) for i586
Linux werewolf 2.4.15-pre6-beo #1 SMP Sun Nov 18 10:25:01 CET 2001 i686
#11 lore raw
In reply to war
Quoted 11 lines · Erik Gustavsson

I agree... After a while it always seems that 80% or more of my RAM is
used for cache and buffers while my open, but not currently used apps get pushed onto disk. Then when I decide to switch to that mozilla window of emacs session I have to wait for it to be loaded from disk again. Also considering the kind of disk activity this box has, the data in the cache is mostly the last few hour's MP3's, in other words utterly useless as that data will not be used again. I'd rather my apps stayed in RAM...

Is there a way to limit the size of the cache?

Reasonable. It looks like the use once heuristics are failing for your
mp3 files. Find out why that is happening and they should push the
rest of your system into swap.

Eric

#12 lore raw
Quoted 5 lines · Eric W. Biederman
Quoted 1 line

Is there a way to limit the size of the cache?

Reasonable. It looks like the use once heuristics are failing for your
mp3 files. Find out why that is happening and they should push the
rest of your system into swap.

I bet they're getting mmap()d, like all mp3 programs seem to do ;)

Rik

Signature · 3 lines
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/
#13 lore raw
Quoted 9 lines · Rik van Riel
Quoted 5 lines · Eric W. Biederman
Quoted 1 line

Is there a way to limit the size of the cache?

Reasonable. It looks like the use once heuristics are failing for your
mp3 files. Find out why that is happening and they should push the
rest of your system into swap.

I bet they're getting mmap()d, like all mp3 programs seem to do ;)

That would probably do it. Though it is puzzling why after the file is munmaped it's pages aren't recycled.

Eric

#14 lore raw
Quoted 2 lines · Eric W. Biederman

That would probably do it. Though it is puzzling why after the file is munmaped it's pages aren't recycled.

Not really. Use-once doesn't work for pages which are or have been mmap()d, but later use of the cache will not be able to put pressure on the pages which have been taken out of the use-once loop.

Use-once as we have it now is fundamentally unbalanced, I can't see a way of ever getting that thing to work nicely.

regards,

Rik

Signature · 3 lines
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/
#15 lore raw
In reply to Rik van Riel
Quoted 2 lines · Eric W. Biederman

That would probably do it. Though it is puzzling why after the file is munmaped it's pages aren't recycled.

Because they're part of the page cache now, and won't be recycled until newer pages 'push' them out of memory. I for one would be very annoyed an mmap()'s associated cache was dropped immediately on munmap, there are many instances in which it would be reused immediately after (think running two GTK+ apps in a row, and having to reload libgtk from disk each time).

-Ryan

#16 lore raw
Quoted 6 lines · Ryan Cumming
Quoted 2 lines · Eric W. Biederman

That would probably do it. Though it is puzzling why after the file is munmaped it's pages aren't recycled.

Because they're part of the page cache now, and won't be recycled until newer pages 'push' them out of memory.

Newer pages cannot push them out of memory, due to use-once. That is, unless those newer pages also get mmap()d or if they get accessed really often.

Rik

Signature · 3 lines
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/
#17 lore raw
In reply to war
Quoted 11 lines · Eric W. Biederman
Quoted 10 lines · Erik Gustavsson

I agree... After a while it always seems that 80% or more of my RAM is
used for cache and buffers while my open, but not currently used apps get pushed onto disk. Then when I decide to switch to that mozilla window of emacs session I have to wait for it to be loaded from disk again. Also considering the kind of disk activity this box has, the data in the cache is mostly the last few hour's MP3's, in other words utterly useless as that data will not be used again. I'd rather my apps stayed in RAM...

Quoted 5 lines
Quoted 1 line

Is there a way to limit the size of the cache?

Reasonable. It looks like the use once heuristics are failing for your
mp3 files. Find out why that is happening and they should push the
rest of your system into swap.

Getting clobbered by the mp3 player accessing the ID3 tag? That way, at least part of the file is used twice, so use-ONCE won't matter...

James.

#18 lore raw
In reply to war
Quoted 12 lines · James A Sutherland
Quoted 11 lines · Eric W. Biederman
Quoted 10 lines · Erik Gustavsson

I agree... After a while it always seems that 80% or more of my RAM is
used for cache and buffers while my open, but not currently used apps get pushed onto disk. Then when I decide to switch to that mozilla window of emacs session I have to wait for it to be loaded from disk again. Also considering the kind of disk activity this box has, the data in the cache is mostly the last few hour's MP3's, in other words utterly useless as that data will not be used again. I'd rather my apps stayed in RAM...

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Is there a way to limit the size of the cache?

Reasonable. It looks like the use once heuristics are failing for your
mp3 files. Find out why that is happening and they should push the
rest of your system into swap.

Getting clobbered by the mp3 player accessing the ID3 tag? That way, at least part of the file is used twice, so use-ONCE won't matter...

For that page perhaps. But that is only 4K. That doesn't explain the rest of it. use-once is per page.

Eric

#19 lore raw
In reply to war
Quoted 19 lines · Eric W. Biederman
Quoted 18 lines · James A Sutherland
Quoted 16 lines · Eric W. Biederman
Quoted 11 lines · Erik Gustavsson

I agree... After a while it always seems that 80% or more of my RAM
is used for cache and buffers while my open, but not currently used apps get pushed onto disk. Then when I decide to switch to that mozilla window of emacs session I have to wait for it to be loaded from disk again. Also considering the kind of disk activity this box has, the data in the cache is mostly the last few hour's MP3's, in other words utterly useless as that data will not be used again. I'd rather my apps stayed in RAM...

Is there a way to limit the size of the cache?

Reasonable. It looks like the use once heuristics are failing for your
mp3 files. Find out why that is happening and they should push the
rest of your system into swap.

Quoted 5 lines
Quoted 2 lines

Getting clobbered by the mp3 player accessing the ID3 tag? That way, at least part of the file is used twice, so use-ONCE won't matter...

For that page perhaps. But that is only 4K. That doesn't explain the rest of it. use-once is per page.

True - the ID3 can be in several different places, so that could account for a couple of pages, but mp3 players certainly DON'T read the whole file in before playing...

Does the mp3 player in question try to pre-read the pages using one process/thread, before the actual player thread reaches them? How far apart would two accesses need to be to disable read-once?

James.