Swap size for a machine with 2GB of memory
The Red Hat installation manual claims that the size of the swap partition should be twice the size of physical memory, but no more than 128MB.
The screaming hotrod machine Gary Sandine and I built around the Tyan S2464 has 2GB of physical memory. Should I believe the above formula? If not, is there a more correct one for calculating needed swap on machines with very large memory?
(No further hangs, BTW.)
Signature · 6 lines
<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>
.. a government and its agents are under no general duty to
provide public services, such as police protection, to any
particular individual citizen...
-- Warren v. District of Columbia, 444 A.2d 1 (D.C. App.181)Quoted 9 lines · Eric S. Raymond
The Red Hat installation manual claims that the size of the swap partition should be twice the size of physical memory, but no more than 128MB.
The screaming hotrod machine Gary Sandine and I built around the Tyan S2464 has 2GB of physical memory. Should I believe the above formula? If not, is there a more correct one for calculating needed swap on machines with very large memory?
(No further hangs, BTW.)
I'm not an authority on swap under Linux, but I can tell you about my personal experiences, and I hope it helps you.
In reality, machines with as little as 192 MB of RAM don't necessarily need swap space. Of course, it depends on what you're doing with it. A machine like that would be used solely as a high-powered office machine or a low-grade workstation.
At the other extreme, I've heard of machines that are running heavy scientific applications. They have 4 GB of RAM and run with 10+ GB of swap.
A machine with 2 GB of RAM can easily live with no swap, unless you want to run web, proxy, or database servers in very large configurations, or if you compile software several times the size of XFree86 with any regularity. By "very large configurations" I mean something you would have to deliberately set, probably requiring a change to defined constants in the software.
Signature · 1 line
Ignacio Vazquez-Abrams <[email protected]>
Quoted 2 lines
The screaming hotrod machine Gary Sandine and I built around the Tyan S2464 has 2GB of physical memory. Should I believe the above formula? If not,
The formula is sort of true for 2.4 due to VM issues, its no longer true for 2.4-ac because Rik fixed the weakness in question, and it wont matter if you are not running >2Gb of toys anyway
Good that its no longer hung again - this is with noapic now ?
Quoted 8 lines · Ignacio Vazquez-Abrams
At the other extreme, I've heard of machines that are running heavy scientific applications. They have 4 GB of RAM and run with 10+ GB of swap.
A machine with 2 GB of RAM can easily live with no swap, unless you want to run web, proxy, or database servers in very large configurations, or if you compile software several times the size of XFree86 with any regularity. By "very large configurations" I mean something you would have to deliberately set, probably requiring a change to defined constants in the software.
One word here: tmpfs.
I use several amounts of RAM as tmpfs. And with that you can certainly reach the point of swapping sth. out.
But my machine has only 1GB of RAM and I set up only 2GB of swap.
I compile and test many things there directly from the CVS, run things like the fcgp to produce nearly a GB of PostScript files and many more fun things.
So if you plan to use tmpfs, better have enough swap available. Files in tmpfs can also not be removed by the OOM killer. So you should define your tmpfs limits properly.
Regards
Ingo Oeser
Signature · 2 lines
Isn't vi that text editor with two modes... one that beeps and one that corrupts your file? --- Dan Jacobson in comp.os.linux.advocacy
Quoted 2 lines · Eric S. Raymond
The Red Hat installation manual claims that the size of the swap partition should be twice the size of physical memory, but no more than 128MB.
----------------------------------------------------------------^^^^^ For the benefit of anyone finding this in the kernel archives and any future Linux technical historians, this 128MB swap partition limit was fixed by a patch submitted by Stephen C. Tweedie on 9 Jul 1998, and which appeared in 2.1.109 on 20 Jul 1998.
Steven
Alan Cox <[email protected]>:
Quoted 1 line
Good that its no longer hung again - this is with noapic now ?
APIC is on.
Signature · 4 lines
<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>
When only cops have guns, it's called a "police state".
-- Claire Wolfe, "101 Things To Do Until The Revolution" Quoted 2 lines · Eric S. Raymond
The Red Hat installation manual claims that the size of the swap partition should be twice the size of physical memory, but no more than 128MB.
???
with old 2.0 kernels there was a limit to swap partition of 128MB each one, and then you could use a lot of them if you have need of a lot of swap.
Quoted 5 lines
The screaming hotrod machine Gary Sandine and I built around the Tyan S2464 has 2GB of physical memory. Should I believe the above formula? If not, is there a more correct one for calculating needed swap on machines with very large memory?
Depends of what is your need. in general kernel 2.4 needs of more swap space in front of 2.2. To explain why whould be long,
it's due to VM change and a different page aging. You can check in a kml archive to find an explanetion in a better english than mine.
with early 2.4 kernel Linus suggested to have a swap area double in front of the physical ram. That was expecially true for pc having big amount of ram that are going to have long uptimes.
On my ultrasparc linux with 4 GByte of RAM running 2.4.X kernels, I needed to add a 8 GB disk just for
swap (16 partitions of 512 MB each one).
But that is because i needed all that swap for what my users where running on this server at the times. (now this sun 3500 has been sended to other use, SOB!)
On the other side, if you are going to run some applications that do not require a lot
of memory, it could happen that you will never touch the swap for more that some Mbyte.
In generel it is a good thing to have an amount of swap bigger than your physical ram, but not too mutch.
if you need a swap 4 times bigger than your physical ram that means you should buy more ram.
bests
Luigi
Quoted 10 lines
(No further hangs, BTW.)
--<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>.. a government and its agents are under no general duty to provide public services, such as police protection, to any particular individual citizen...
-- Warren v. District of Columbia, 444 A.2d 1 (D.C. App.181)-
On Sunday 19 August 2001 01:29 pm, Luigi Genoni wrote:
[snipped]
Quoted 3 lines
On my ultrasparc linux with 4 GByte of RAM running 2.4.X kernels, I needed to add a 8 GB disk just for
swap (16 partitions of 512 MB each one).
--------^^
Just curious, in linux-2.4.9/include/linux/swap.h line 11, we have:
#define MAX_SWAPFILES 8
Did you change this to 16, or does this not matter anymore? This value is the same in 2.4.8-ac7.
Steven
Yes, i changed this value.
But i also changed a lot of other #define with bigger values, because of the eavy use of all HW resources my users were needing. (maximum number of processes and so on...)
It has been funny.
First i installed via NFS the slackware-current for sparc (now obsoleted, and developed at sourceforge as splackware),
then i upgraded the kernel, then i installed a new disk
to make the swap and so on...
The latest kernel i used before the 3500 was sended to other uses was 2.4.7.
The worser kernel on that server was 2.4.5, absolutelly it had the worst VM i ever saw on ultrasparc.
Luigi
Quoted 15 lines · Steven Cole
On Sunday 19 August 2001 01:29 pm, Luigi Genoni wrote:
[snipped]Quoted 3 lines
On my ultrasparc linux with 4 GByte of RAM running 2.4.X kernels, I needed to add a 8 GB disk just for
swap (16 partitions of 512 MB each one).--------^^
Just curious, inlinux-2.4.9/include/linux/swap.hline 11, we have:#define
MAX_SWAPFILES8Did you change this to 16, or does this not matter anymore? This value is the same in 2.4.8-ac7.
Steven
Quoted 3 lines
The Red Hat installation manual claims that the size of the swap partition should be twice the size of physical memory, but no more than 128MB.
This manual is outdated.
1. You hahe 2GB limit for a single swap file/partition now. And you can use many of them.
2. it sjould be <= 2* RAM, i.e. 0 <= SWAP <= 2*RAM. More is inefficient.
3. except kernels 2.4.x, where x <= 7-ac8, where you should have SWAP=0 or SWAP > RAM. 2.4.7-ac9 & 2.4.8 have already this problem fixed.
Quoted 4 lines
The screaming hotrod machine Gary Sandine and I built around the Tyan S2464 has 2GB of physical memory. Should I believe the above formula? If not, is there a more correct one for calculating needed swap on machines with very large memory?
Correct and universal formula for swap size is as always:
SWAP = MAX_RAM_you_ever_need - physical_RAM_you_have
However in 2.4 more eficient (and in 2.40-7 obligatory) is:
SWAP = MAX_RAM_you_ever_need > physical_RAM_you_have
? MAX_RAM_you_ever_need
;)
Andrzej
Quoted 7 lines · Eric S. Raymond
The Red Hat installation manual claims that the size of the swap partition should be twice the size of physical memory, but no more than 128MB.
The screaming hotrod machine Gary Sandine and I built around the Tyan S2464 has 2GB of physical memory. Should I believe the above formula? If not, is there a more correct one for calculating needed swap on machines with very large memory?
There is no magic formula for calculating the amount of swap space needed. It really needs to be sized to the expected load on your box plus some. If you seriously expect to be using swap, have swapsize > memsize and figure the amount of virtual memory you have is swapsize.
With respect to swap partitions the current limit is about 64Gig. You can actually make a larger swap partition but the kernel on x86 only uses 24 offset bits into that partition. The 128MB partition existed but was removed long ago.
Eric
I was just experimenting on my personal Linux computer this weekend, which has 512MB of RAM and 700MB of swap. I also have an unpatched 2.4.8 kernel installed.
I wrote a program that allocated 700MB of RAM and touched every page, then read it back in. When finished, there remained 250+ meg of swap in use, but no corresponding free space in RAM, compared to before running my test program. The expected behavior of the 2.4 kernels seemed to be followed, where many programs retained space in both RAM and swap.
However, since my normal behavior is for swap to not be used, I will wait a little bit for some of the VM updates to be tested.
I don't have 2X RAM because when I installed my system, I only had 256MB of RAM.
Quoted 9 lines · Kevin Krieser
I was just experimenting on my personal Linux computer this weekend, which has 512MB of RAM and 700MB of swap. I also have an unpatched 2.4.8 kernel installed.
I wrote a program that allocated 700MB of RAM and touched every page, then read it back in. When finished, there remained 250+ meg of swap in use, but no corresponding free space in RAM, compared to before running my test program. The expected behavior of the 2.4 kernels seemed to be followed, where many programs retained space in both RAM and swap.
This was even the behavior in 2.0, and 2.2. 2.4 can simply be more aggressive about it. What this sounds like is that, your program pushed 250MB of other programs into swap. The programs were the reread into memory when it was done, and their location in swap was remembered so that if they were ever pushed into swap again they could just be dropped from memory, and not need to be written out.
As long as you don't have problems where you can't run your program multiple times in a row, 2.4 sounds like is is behaving correctly and sanely.
Quoted 2 lines
However, since my normal behavior is for swap to not be used, I will wait a little bit for some of the VM updates to be tested.
Are you saying something is wrong?
Quoted 2 lines
I don't have 2X RAM because when I installed my system, I only had 256MB of RAM.
This is not a requirement but is a requirement to have swap > mem if you are swapping heavily and want good performance.
Eric
I was just experimenting. 512MB is more than sufficient for my needs, I just couldn't bypass the $130 (at the time) for the memory which took me to 512MB.
I've seen some later updates to the VM, but at the moment, the 2.4.8 kernel is working well for me. Better than the 2.4.6 kernel.
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Eric W. Biederman
Sent: Monday, August 20, 2001 12:43 PM
To: Kevin Krieser
Cc: Linux Kernel List
Subject: Re: Swap size for a machine with 2GB of memory
As long as you don't have problems where you can't run your program multiple times in a row, 2.4 sounds like is is behaving correctly and sanely.
Quoted 1 line
However, since my normal behavior is for swap to not be used, I will wait
a
Quoted 1 line
little bit for some of the VM updates to be tested.
Are you saying something is wrong?
Quoted 1 line
I don't have 2X RAM because when I installed my system, I only had 256MB
of
Quoted 1 line
RAM.
This is not a requirement but is a requirement to have swap > mem if you are swapping heavily and want good performance.
Eric
Eric W. Biederman <[email protected]>:
Quoted 9 lines
There is no magic formula for calculating the amount of swap space needed. It really needs to be sized to the expected load on your box plus some. If you seriously expect to be using swap, have swapsize > memsize and figure the amount of virtual memory you have is swapsize.
With respect to swap partitions the current limit is about 64Gig. You can actually make a larger swap partition but the kernel on x86 only uses 24 offset bits into that partition. The 128MB partition existed but was removed long ago.
That's helpful, thanks.
Signature · 3 lines
<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a> Never trust a man who praises compassion while pointing a gun at you.