Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14
I think that only applies for low-mem systems, like 32 MB and lower. I have 512 MB RAM and 128 MB swap. I would also like to know why every ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    I think that only applies for low-mem systems, like 32 MB and lower. I have 512 MB RAM and 128 MB swap. I would also like to know why every document states that.

  2. #12
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Yes,

    Back when I first installed Redhat, I always wondered why you needed to double the ram for the swap partition. I remember reading something about how it MUST be double the size or else applications can run slow and etc. However, I read that about three years ago and I doubt I can remember which document stated that. I'll post the URL if I can find it. In the meantime, it's always nice that YOU answer all of my questions in the forum. =)
    The best things in life are free.

  3. #13
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    want to know why it is 2:1? I wrote a comment about this earlier on here, it seems to be a common question. Here is how I understand it.

    swap is the place where you put stuff when RAM fills up. They want it to be in a particular place that way it is "relatively quickly" accessible. The reason it is 2:1 is due to the algorithm they use for swapping. When a page in RAM isn't used any more it is put into the swap. To put this in there they use a hash. When two pages map to the same address they use a stepping hash algorithm (is that what they are called??). It is where you add consecutive odd numbers to the hash value and see if those areas are full. It works better with an example. Say a page is getting killed from RAM, and put into swap. We hash the RAM page address and get the swap address it will map to. Say that value is "1". But 1 is taken, so we add consecutive odd numbers till we get one that isn't taken. Next we try 2, then 5, then 10, etc. Since all RAM have unique page numbers they don't map to the same place all that often (relatively), and they figured out that double the ram will leave enough space to hash every page of RAM within like three "steps" from the original hash value. The leads to quicker access times (hash value computation + 3 (I don't know the exact number) additional lookups) instead of using a different method of looking up swap pages. This is why they say that, no other reason. Having 20 megs of RAM and 3 gigs of swap will do almost nothing to your overall speed as opposed to 20 megs RAM/40 megs swap.

    Oh, also, not everyone uses swap, sometimes they feel their ram is large enough to handle the programs they have open, and don't even worry about pages falling from RAM. Once they fall from RAM, then are needed again, they are retrieved from the filesystem (not swap) which is like 10 times slower than swap space.
    I respectfully decline the invitation to join your delusion.

  4. #14
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Thank you very much for clearing that up, wassy. I have long wanted to know the reason. Do you have some details though? If I'm interpreting what you're saying correctly, access time remains pretty much same if you have more than double your RAM in swap? I recently transferred some services from one server to another, and since that machine only has 32 MB RAM, I put in a spare 2GB HD I had lying around and used it entirely for swap. I guess that's not going to hurt performance, right?

    Also, just for curiosity; would you happen to know how the kernel prioritizes pages when it needs to swap? Does it prefer anonymous mappings over mapped files?

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •