You are not logged in.

#1 2005-07-25 13:35:44

CrayMk7
Member
From: Norway
Registered: 2004-03-29
Posts: 51

Swap size limitations / default rules

I've been playing with software raid to speed up my hd performance.
I currently have 4 x 160 gig hd's (2 x sata & 2 x pata).
I got my 4'th hd today, so I did a clean install (got too much spare time) and for some reason decided to set my swap to 1gig on each drive witch should be 4gig total (just to be sure).

However, after getting my system up and running, checking with gnome-system-monitor & top, I see only 2gig of swap space is in use.
I did a quick search here on the forum & google, and it seems that by default swap is 2 x ram, I got 1gig ram so it add's up.

I checked :

[root@Cray loke]# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid5] [multipath] [raid6] [raid10]
md1 : active raid0 sdb2[0] sda2[1] hdb2[2] hda2[3]
      3919360 blocks 64k chunks

md2 : active raid0 sdb3[0] sda3[1] hdb3[2] hda3[3]
      15229184 blocks 64k chunks

md3 : active raid0 sdb4[0] sda4[1] hdb4[2] hda4[3]
      605577792 blocks 64k chunks

md0 : active raid1 sdb1[0] sda1[1] hdb1[2] hda1[3]
      96256 blocks [4/4] [UUUU]

unused devices: <none>

And did a speed test comparing /dev/md/1 (swap)  & /dev/md2 (/)

[root@Cray loke]# hdparm -t /dev/md/1
/dev/md/1:
Timing buffered disk reads:  366 MB in  3.01 seconds = 121.61 MB/sec

[root@Cray loke]# hdparm -t /dev/md/2
/dev/md/2:
Timing buffered disk reads:  348 MB in  3.02 seconds = 115.40 MB/sec

Looking at the speed, the swap file is using 4 drives but only 2gig of the 4 available, I doubt I ever going to  use all the swap space, but since its already there and I'm not gonna add more hd's anytime soon, why not have it all available smile.

So my question is, where do I alter / force the swap size to go byond 2gig or 2 x ram?
Thanks.

Offline

#2 2005-07-25 14:22:52

kth5
Member
Registered: 2004-04-29
Posts: 657
Website

Re: Swap size limitations / default rules

i think that in this case the oh so great 32bit addressspace limitation comes into effect. lol
after this the total can only be 4gig of memory which is presented by swap and physical memory together. so if you have 2gigs physical memory in your machine that's it. no way to have another 4gig swap. anyway, as you only have one it might be the md setup or swapfs limit after all, then i have no idea. tongue
you may want to look into highmem support etc. in the kernel, but i actually doubt that it'll help much.


I recognize that while theory and practice are, in theory, the same, they are, in practice, different. -Mark Mitchell

Offline

#3 2005-07-25 14:37:19

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: Swap size limitations / default rules

I see only 2gig of swap space is in use.

Can you clarify what you mean by "in use"? Do you mean you're only seeing 2GB total, or that your seeing 4GB but never more than 2GB gets used (as in "top" showing total 4GB, used 2GB, free 2GB)? If the latter, what on earth are you running that uses 1GB Ram plus 2GB swap?

Offline

#4 2005-07-25 14:37:57

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Swap size limitations / default rules

Wouldn't 4GB of swap for 1GB of ram be overkill by about four times? Are you doing some kind of extremely high performance graphics editing or running a high-profile server here?

You'd want to increase your RAM in that case, I think. I have 1GB of RAM and 1GB of swap, and its very rare that anything is swapped out anyway.

Dusty

Offline

#5 2005-07-26 00:12:39

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Swap size limitations / default rules

Most people dont even need swap anyway unless they have low ram or are doing graphic work, large compiles or anything that is likely to use lots of memory.

only time my swap gets worked on is when i do really intensive things in inkscape like tracing bitmaps, 512mb ram.

iphitus

Offline

#6 2005-07-26 08:53:00

flying_icarus
Member
Registered: 2005-07-18
Posts: 10

Re: Swap size limitations / default rules

kth5 wrote:

i think that in this case the oh so great 32bit addressspace limitation comes into effect. lol
after this the total can only be 4gig of memory which is presented by swap and physical memory together. so if you have 2gigs physical memory in your machine that's it. no way to have another 4gig swap. anyway, as you only have one it might be the md setup or swapfs limit after all, then i have no idea. tongue
you may want to look into highmem support etc. in the kernel, but i actually doubt that it'll help much.

I too would say that this could be the result of a 32bit cpu and addressing range. I have done some research on a similar subject, how to get 4GB of physical RAM working under various windows OS-s, and found out that most motherboards don't even have the address space for reaching those 4 GB. In other words, you may have 4x1GB sticks in your mobo and it can even "officialy" support 4GB ram, but you would get 3,3 or 3,5  if you're lucky, because the rest of the address space is used for addressing various I/O devices, like usb, firewire, ata/sata, pci bus, and so on. Things get more complicated from there on, since  better motherboards can have the last GB moved up into "5th" GB address space so you don't "loose" it. smile

And the reason for me writing this is to also suggest enabling highmem support in the kernel. wink

Offline

#7 2005-07-26 09:24:54

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Swap size limitations / default rules

But dont forget, swap isnt mobo level, it's kernel level so it wouldnt be affected by limitations of the motherboard.

It's just like another drive, which it is, another partition, which the kernel overflows data into when required.

iphitus

Offline

#8 2005-07-26 10:02:20

CrayMk7
Member
From: Norway
Registered: 2004-03-29
Posts: 51

Re: Swap size limitations / default rules

Thank you all for replying.

kth5 : I didn't realize that the 32bit address space limitation counts both ram and swap, I always thought it  only affected physical memory.

vacant : I see only 2gig of swap space is in use was a bad way of saying it, I only see 2gig of swap available is more correct and at the moment none in use. I can't ever imagine I'm going to need all that swap.

Dusty : Yeah 4gig of swap is overkill for me, it's only a home computer running NVN as the most intensive app, I don't even remember why I choose that amount, I guess it looked pretty when setting up the hard discs, I have never seen the swap space go beyond 2-300kb.

It's no problem at all for me, the speed of the swap is correct and the size is more than enough, but when I saw only half of what I set up was avalible to the system, it makes me wonder what was going on.

Offline

#9 2005-07-26 10:38:44

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: Swap size limitations / default rules

CrayMk7 wrote:

vacant : I see only 2gig of swap space is in use was a bad way of saying it, I only see 2gig of swap available is more correct and at the moment none in use. I can't ever imagine I'm going to need all that swap.

OK, I guess you can see what most people are saying ... you're unlikely to need swap.

That "swap = 2 x ram" guideline always makes me laugh:

1) I have 2x256MB RAM and 1GB swap I have a faulty stick of RAM so I take it out ... and should I halve my swap file? I don't think so. If anything I should increase it my 256 if it was ever getting fully used.

or

2) I have 256MB RAM and notice sometimes my 512MB swap gets used. I chuck in an extra 512MB RAM to solve that.

If you are really low on RAM and can't afford more then it may be necessary to use swap on a regular basis.

Goof luck.

Offline

#10 2005-07-26 16:43:12

rhfrommn
Member
From: Minnesota
Registered: 2005-01-13
Posts: 99

Re: Swap size limitations / default rules

Swap = 2x Ram is an old rule of thumb for servers.  For a home desktop I agree it is inappropriate.  And even for servers now it is probably too much swap.  But I have an old Unix book from the mid 90's that talks about how even though RAM is so expensive you should make your database servers be at least 32MB of ram, and 128MB if you can afford it.  So back in those days you can see how a database could easily need more than your physical ram and having lots of swap would help.

Offline

Board footer

Powered by FluxBB