I am wondering how much swap space I need in modern Linux such as FC6.
I'm planning to set up a system Pentium Dual Core with 8G RAM, and I don't expect I need much more than that for my apps.
Would I need a swap anyway. There is some old rule of thumb to have twice as much virtual memory as you have physical RAM, but that sounds a bit ridiculous as it would take a lot of time to swap in/out this much memory from disk.
In some other Unixes the swap space was needed to preserve dump information in case of a panic, are there any such considerations in Linux?
Regards Uno Engborg
Uno Engborg wrote:
I am wondering how much swap space I need in modern Linux such as FC6.
I'm planning to set up a system Pentium Dual Core with 8G RAM, and I don't expect I need much more than that for my apps.
Would I need a swap anyway. There is some old rule of thumb to have twice as much virtual memory as you have physical RAM, but that sounds a bit ridiculous as it would take a lot of time to swap in/out this much memory from disk.
In some other Unixes the swap space was needed to preserve dump information in case of a panic, are there any such considerations in Linux?
Regards Uno Engborg
The 2X physical memory rule has not applied for a long time. With that much memory, how much swap you need depends on if you are going to use suspend to disk or not, and just what you are going to run. If you are not going to use suspend to disk, then you may want to set up a 500m swap partition, and monitor its use. If you end up needing more, then create a swap file.
Mikkel
On Sun, Feb 25, 2007 at 18:18:14 +0100, Uno Engborg uno@webworks.se wrote:
I am wondering how much swap space I need in modern Linux such as FC6.
I'm planning to set up a system Pentium Dual Core with 8G RAM, and I don't expect I need much more than that for my apps.
Would I need a swap anyway. There is some old rule of thumb to have twice as much virtual memory as you have physical RAM, but that sounds a bit ridiculous as it would take a lot of time to swap in/out this much memory from disk.
In some other Unixes the swap space was needed to preserve dump information in case of a panic, are there any such considerations in Linux?
How much swap you need is going to be tied to your memory allocation setting. If you are willing to let the oom killer run loose, you may not need any. If you can't let it kill processes and you have processes that preallocate a lot of memory (fortran programs with large static arrays are the classic example), you may need a lot of swap space (even though it never gets used).
Uno Engborg wrote:
I'm planning to set up a system Pentium Dual Core with 8G RAM, and I don't expect I need much more than that for my apps.
Erm -- what's the rationale for having that much memory? If it's just that you want as much as you can have, then I shouldn't think you need swap. If you have an application (or several applications) that need memory, you'd have to consider what those applications will need.
In some other Unixes the swap space was needed to preserve dump information in case of a panic, are there any such considerations in Linux?
I understand that you need a proper swap partition if you want to suspend the system to disk. Otherwise, you might just as well see how you get on without swap, and add swap files (which are normal files in a Linux filesystem) later if you need them.
Hope this helps,
James.
On Sun, 25 Feb 2007, James Wilkinson wrote:
I understand that you need a proper swap partition if you want to suspend the system to disk. Otherwise, you might just as well see how you get on without swap, and add swap files (which are normal files in a Linux filesystem) later if you need them.
Is there any performace issues related to using swap files instead of a swap partition?
-- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 --------------------------------------------------------- Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática | '@' || 'unl.edu.ar'; Universidad Nacional | DBA, Programador, del Litoral | Administrador ---------------------------------------------------------
Martin Marques wrote:
Is there any performace issues related to using swap files instead of a swap partition?
I understand that these days, there isn't. In any case, when you're swapping to disk, what really kills performance is the relative eternity it takes for data to reach disk or be read from disk. For paging, what will usually take the most time is moving the drive head to reach the right track, and then for the disk to spin so the right bit of data is underneath the head.
Depending on how you lay things out, a swap file that's physically close on disk to the rest of the files you're accessing may well be faster than a swap partition at one end of the disk because the drive head can get to the right track faster.
Hope this helps,
James.
On Mon, 26 Feb 2007, James Wilkinson wrote:
Martin Marques wrote:
Is there any performace issues related to using swap files instead of a swap partition?
Depending on how you lay things out, a swap file that's physically close on disk to the rest of the files you're accessing may well be faster than a swap partition at one end of the disk because the drive head can get to the right track faster.
So it really depends on *where* the swap file or swap partition is on the disk (I tend to put heavy duty patitions first), rather then if it's a file or a partition.
-- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 --------------------------------------------------------- Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática | '@' || 'unl.edu.ar'; Universidad Nacional | DBA, Programador, del Litoral | Administrador ---------------------------------------------------------
2007/2/25, Uno Engborg uno@webworks.se:
I am wondering how much swap space I need in modern Linux such as FC6.
I have been thinking about that myself lately. I came up with the following reasoning: you need as much swap as necessary to fill the gap between your physical ram and the amount of memory needed for your most memory intensive task. So let's say you need 10GB of ram to crunch huge datasets. Since you have 8GB of physical RAM, you'd need a minimum of 2GB of swap. Swap is very slow. It obviously should not be considered as 'cheap ram'.
Uno Engborg wrote:
Would I need a swap anyway. There is some old rule of thumb to have twice as much virtual memory as you have physical RAM, but that sounds a bit ridiculous as it would take a lot of time to swap in/out this much memory from disk.
I used to think it was kind of ridiculous, myself, until I discovered a quirk of Posix's behavior. If I get any of these details wrong, I invite corrections:
When a process called fork() on an old unix system, the OS required an amount of free memory equal to the size of the process, plus the size of a process table entry. If this memory wasn't free, fork() would fail. After fork(), the OS would copy the full set of memory from the parent process to the new process. Since fork() is so often followed by exec(), which throws away all of that memory, modern unix systems don't copy the whole set of memory when a process forks. However, they still require that there is enough memory to do so (at least normally; Linux has an "overcommit" feature that you can enable).
With 8GB of RAM, that may not affect you directly, but it may, too. Lets say that you have no swap, and you were using a 3d modeler, or high-end graphics package. If that application was using 5GB of your 8, and needed to launch a helper application, like an out-of-process perl or python script, it wouldn't be able to do so. Even though that script only needs a few MB of the GB you have free, the parent is too big to fork(), so it can't spawn new processes.
So, when you decide whether or not to follow the traditional advice offered about the amount of swap to allocate, you should first understand how the Linux VM works: http://www.redhat.com/magazine/001nov04/features/vm/
...if you don't want to spend the time learning the details, I'd just stick with the advice offered.