Re: excessive swap-in time



On Mon, 17 Mar 2008 22:52:30 -0700 (PDT) David Schwartz <davids@xxxxxxxxxxxxx> wrote:
| On Mar 17, 12:44 pm, phil-news-nos...@xxxxxxxx wrote:
|
|> Actually, my target is to have enough RAM to do without any swap space at all.
|> I've heard arguments why I should not do this, but so far I have not heard any
|> that make sense. As soon I can solve the video issues on the new machine that
|> has no swap space with its 8 GB of RAM, I will see how well it performs with
|> the biggest of obese beasts: firefox after it has loaded 100 websites
|
| If you have no swap space, the system cannot swap out pages that
| haven't been touched for a very, very long time. This means that not
| only must the working set fit in memory, but all modified pages that
| are not part of the working set must fit as well. Thus the system may
| page badly even if the working set is less than the total size of
| physical memory.

But it would be no worse with an 8GB RAM / 0GB SWAP system as compared to
a 4GB RAM / 4GB SWAP system, or a 2GB RAM / 6GB SWAP. The way I am doing
this is to decide what my RAM needs are, what my swap needs are, and make
the RAM really be the sum of that. Thus those pages that haven't been
touched for a very, very long time and are stuck in RAM because of no swap
are not occupying the portion of RAM that was originally considered to be
the need.

What if I reserve 4GB of that 8GB of RAM to be a ramdisk and use it for
swapping? What I would be doing is taking those long untouched pages and
moving them from one place in RAM to another place in RAM. Well ... what
I would be doing by leaving all 8GB as available RAM is avoiding any page
movement at all. So those long untouched pages just sit where they are
and don't take up I/O bandwidth.

I can see the two counter arguments here:

1. Add some swap to the 8GB and you can make even better use of the 8GB
by having more of the 8GB available by getting those long untouched
pages out of the way.

2. (mine) Add more RAM instead of adding more swap, and to the extent
there are not too many of those long untouched pages, you have more
RAM to use.

One problem I have seen, and described elsewhere, is I/O cache/buffer space
tends to get in the way too easily in Linux's VM design. Eliminating swap
space can reduce that effect. Dirty pages have nowhere to go and so they
will not contribute to the I/O load caused by swapping (which in turn slows
the real I/O which can cause a backup of I/O buffers in heavy write cases).
Undirty text pages would still be stealable. If stolen, they have to be
read back in from their file mapping when needed again. But at least this
is less I/O load. The idea of preloading /{,usr/}{lib,{,s}bin} into ramdisk
with even more RAM in the machine would get this I/O load way down.

The arguments come down to "make better use of the RAM you have" vs. "add
more RAM when you need it". They tend to be orthogonal arguments. One can
go back and forth between them.

I have used the following criteria in the past to decide how much swap space
to use in a system: Determine how much time you can tolerate for an idle
program to become fully active again. Make your swap space size be how much
can be read in during that much time. For a system in which I would like to
eliminate such delays, that suggests very little swap. But there is that
issue of text pages that won't play in the swap space to contend with.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2008-03-18-0822@xxxxxxxx |
|------------------------------------/-------------------------------------|
.



Relevant Pages

  • Re: running Linux with no swap space (but lots of RAM)
    ... it actually SLOWS DOWN the intended I/O by ... much additional RAM as I would have in swap space. ... never run out of memory in normal operation. ...
    (comp.os.linux.development.system)
  • Re: running Linux with no swap space (but lots of RAM)
    ... It's a very good reason to not swap to the boot device ... | JdeBP> on that system, but instead to swap to some other device ... | JdeBP> I/O, not that the system is paging to disc. ... Adding RAM in the amount of swap would eliminate a great deal of this. ...
    (comp.os.linux.development.system)
  • Re: Swap partition size (future proofing)
    ... > the HDD or using mkswap to create a swap file in an existing partition. ... > Suggested swap partition sizes from the archives range from the same size as ... > the RAM to twice the size of the RAM. ... you start actually using the swap space. ...
    (Fedora)
  • Re: excessive swap-in time
    ... Trying to do it all with RAM is just inefficient. ... I find that does not work well when the swapping is caused by excessive I/O ... Or you could have 5 TB of swap space. ...
    (comp.os.linux.development.system)
  • Re: excessive swap-in time
    ... | physical memory. ... but swap is orders of magnitude cheaper than RAM. ... You will still do more disk I/O than you need to because some pages ...
    (comp.os.linux.development.system)