LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SWAP (https://www.linuxquestions.org/questions/linux-newbie-8/swap-689269/)

sunil_sutar 12-09-2008 04:23 AM

SWAP
 
Dear all,

I have linux installed with 2.5GB and SWAP with 5GB

my question is : if all processes consume my physical memory can i divert process request to my SWAP, so that my system performance will boost up


Thanks in Advance

tommcd 12-09-2008 05:02 AM

Quote:

Originally Posted by sunil_sutar (Post 3368902)
I have linux installed with 2.5GB and SWAP with 5GB

my question is : if all processes consume my physical memory can i divert process request to my SWAP, so that my system performance will boost up

Does this mean that your root partition is 2.5GB and swap is 5GB?
What distro are you using? and how did you end up with a 5GB swap? How much RAM do you have?

You should not need 5GB of swap. But, to answer your question, all linux distros I have tried will automatically use all your physical RAM before turning to swap. Then after all your RAM is used up linux will start to use your swap.

To check how much RAM and swap you are using, open up a terminal and run:
Code:

free -m
(This displays your memory usage in megabytes).
You will get something like this:
Code:

bash-3.1$ free -m
            total      used      free    shared    buffers    cached
Mem:          2026        812      1213          0        125        354
-/+ buffers/cache:        332      1693
Swap:          996          0        996

This means I have 2GB (2026) RAM, and I am using 812mb with 1213 free. But note the -/+buffers/cache line. This shows that 332mb are being used by programs, with 1693 free. The buffers + cached columns on the right show how much of that 812mb that is being used is cached in memory. So 332 + 125 + 354 = (approx) 812. And I am not using any swap.

sica07 12-09-2008 05:09 AM

That is SWAP it's all about (well, almost). BUT: because runing on a hard-disk, SWAP memory is very slow and, the more swapping that occurs, the slower your system will be.
Anyway, why are you having a 5GB SWAP partition?! It's huge!!! In "old times" when RAM memory was a problem, there was the recommendation that you should make a partition that would be (in size) not more than double of you RAM memory. That would be more than sufficient. I'm a newbie so, for more accurate information, googlize. Read this: http://www.linux.com/feature/121916

ErV 12-09-2008 06:01 AM

Quote:

Originally Posted by sunil_sutar (Post 3368902)
my question is : if all processes consume my physical memory can i divert process request to my SWAP, so that my system performance will boost up

Performance won't boost when system is using swap. It will drop instead (well, unless your swap on solid state drive) - because accessing harddrive is much slower than accessing memory.

onebuck 12-09-2008 07:22 AM

Hi,

WOW!

Give us your system specifications? 5GB swap is a big swap. How much memory? What distribution? What are you using the system for?

baig 12-09-2008 08:16 AM

Usually it is advised to make a swap partition twice the size of your ram.. My RAM is 1GB and am having 2GB swap..

Who advised you to end up with a 5GB swap?

Access to RAM is much more times faster than to Swap.. The more process in your swap the slower you system and the more you have physical memory the faster would be you computer.. I think you should consider a new RAM rather finding a process switch temporary fix...

Cheers!!

sundialsvcs 12-09-2008 08:54 AM

I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.

The original complaint is "system performance needs to be boosted up." This alone does not necessarily have anything at all to do with the amount of swap-space that you have.

The ordinary purpose of swap-space, today, is "a place to set things down." Most computers these days have more-than-adequate supplies of RAM, as your machine certainly does. But the operating system may nevertheless find that it wants to use some portion of RAM for other purposes, but there's this chunk of written-to storage that's "in the way." Where do you put it? You swap it out.

One of the things that the operating system loves to do is to fill-up RAM with file buffers. These are chunks of data that someone has read, and that someone might need to read again. (This is often the case.) Chunks of written-to storage that have become "long in the tooth" get moved out of the way sometimes to make room just for that.

If "performance is sluggish," the first thing to check is your disk I/O: that DMA is being used, and all of the hardware features of your controller are being exploited. On my desktop systems, I don't use the motherboard's disk-controller; I have an expansion-card. A very high performance controller costs about $40 and "it do make a difference."

TB0ne 12-09-2008 09:11 AM

Quote:

Originally Posted by sundialsvcs (Post 3369153)
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.

I agree, but use caution. I tried to do a RHEL5 install not too long ago, and tried to do this (set the swap to be 8 GB...long story, has to do with an Oracle DBA and her whining about how it 'had to be' that way), on a system with 4GB of RAM. Swap set above 8 GB caused the install to take a LONG time (like 6+ hours), before it died. Reduced swap to 4GB, and install was less than an hour.....

amani 12-09-2008 09:23 AM

Quote:

Originally Posted by TB0ne (Post 3369173)
I agree, but use caution. I tried to do a RHEL5 install not too long ago, and tried to do this (set the swap to be 8 GB...long story, has to do with an Oracle DBA and her whining about how it 'had to be' that way), on a system with 4GB of RAM. Swap set above 8 GB caused the install to take a LONG time (like 6+ hours), before it died. Reduced swap to 4GB, and install was less than an hour.....

For 4GB RAM, swap should be ~3GB... for most situations. Anyway, how do you explain the 'LONG time'?

i92guboj 12-09-2008 09:48 AM

Quote:

Originally Posted by tommcd (Post 3368932)
Does this mean that your root partition is 2.5GB and swap is 5GB?
What distro are you using? and how did you end up with a 5GB swap? How much RAM do you have?

I think he meant 2.5 GB RAM and 5GB SWAP. I presume he's applying the infamous 2x rule.

Quote:

You should not need 5GB of swap. But, to answer your question, all linux distros I have tried will automatically use all your physical RAM before turning to swap. Then after all your RAM is used up linux will start to use your swap.
It's long since the last time I looked into it, and the kernel has changed greatly in the latest months, so I am not sure how it handles it right now. But if the thing hasn't changed so drastically, this is controlled by a thing called swapiness.

Also, the kernel uses swap for several things. You might find a few kilobytes or megabytes of swap filled at any random moment, even if your ram is empty.

Quote:

Originally Posted by ErV (Post 3368979)
Performance won't boost when system is using swap. It will drop instead (well, unless your swap on solid state drive) - because accessing harddrive is much slower than accessing memory.

Exactly. Swap is not and was never a performance booster. It's just a fallback that will prevent your kernel from randomly closing programs once your ram is full. Lately it's also used by some hibernation methods to store the contents of your ram for later restoration when you want to go back on from hibernation.

Nothing in a tipical pc is faster than ram, nothing except for the l1 and l2 caches, that live inside your cpu. Regular swap on hard drive is in the range of tens of millions slower than these of the ram (tens of miliseconds seeks time vs. a few nanoseconds for ram).

Quote:

Originally Posted by sundialsvcs (Post 3369153)
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.

Except that by the time you are using 1GB (let alone 5) your system will be unusable. Then you will wish you had a smaller swap space so the program that's leaking ram is forced to be closed and you can continue working after a reasonable amount of time.

If the swap space is too big and something start leaking swap you can wait sitting for a couple of days :p

Quote:

The original complaint is "system performance needs to be boosted up." This alone does not necessarily have anything at all to do with the amount of swap-space that you have.
It's the other way around. If you really need 5 GBs of swap, then simply your machine can't do the job you need it to do, and a hardware upgrade is mandatory.

Having some swap space never hurts. Having so much can be a problem, unless you can guarantee that nothing will ever lack memory in your system. However on modern desktops that's no longer possible, overall if you want to use the latest and greatest.

TB0ne 12-09-2008 09:56 AM

Quote:

Originally Posted by amani (Post 3369189)
For 4GB RAM, swap should be ~3GB... for most situations. Anyway, how do you explain the 'LONG time'?

I don't...I just know what it did. Never pursued it more, since I got the build done, and things working. And I agree with you, but set the swap to 4GB to shut the aforementioned DBA up. :)

This is the same DBA who says:

"QuickIO or ASM is totally unnecessary, for any database less than a terabyte"
"You need to try to keep a database on one disk, so access is quicker.."
"Anything less than 12GB of RAM won't even let Oracle start the listener...".

yeah....right....

ErV 12-09-2008 10:09 AM

Quote:

Originally Posted by sundialsvcs (Post 3369153)
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.

It depends on what you use your machine for. I have 2 gigabytes of RAM and 1 gigabyte swapspace. Normal swap usage is zero, or less than megabyte. Sometimes system use few dozen megabytes, but not more. I don't remember situations when swap file usage was at least 300megabytes. So if you have decent amount of RAM, large swapspace will be a waste of resources(unless you are really doing something heavy that can't live without a lot of swap space). I remember that somewhere I saw recommendation that "swapspace should be twice the amount of RAM, but not more than 512 megabytes". I don't remember where I saw it, but slackware 11 was happily working with 512mB of swap and 512mB of RAM.


All times are GMT -5. The time now is 02:37 AM.