Re: excessive swap-in time



On Mar 18, 6:40 am, phil-news-nos...@xxxxxxxx wrote:

| 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.

Absolutely, but swap is orders of magnitude cheaper than RAM. For
almost any given cost level, you can do better with some of that money
going to swap. Trying to do it all with RAM is just inefficient.

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.

You will still do more disk I/O than you need to because some pages
will stuck in memory when it's more efficient for them not to be. So
even given that, you will lose efficiency because the disk cache will
be smaller.

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.

Except that other pages do take up I/O bandwidth because memory is
wasted holding pages that were modified long ago and won't be read for
ages -- memory that could hold pages that were discarded.

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.

Exactly.

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.

Crazy, since the cost of adding RAM is so much higher than the cost of
adding swap.

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.

Huh? Your logic doesn't make sense. Evicting long-ago used dirty pages
is much better than evicting recently-used clean pages.

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.

That you can add more RAM when you need it is no reason to make less
than ideal use of the RAM you have.

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.

That's ass backwards. That's like saying you should decide how many
lifejackets to put on a boat based on the number of passengers less
the maximum number of casualties you can accept. Lifejackets are
cheap.

DS
.



Relevant Pages

  • Re: OT (slightly) swap limits
    ... influence your decision on how much swap was enough. ... processes due to lack of memory. ... I've run machines with 1Gig or more RAM with NO SWAP. ... Linux possible when before on Unix it wasn't? ...
    (Debian-User)
  • 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: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >> memory and hence causes the kernel to 'thrash' thus slowing down the ... 4GB physical RAM + 4GB swap area) the application will think that it can ... You've said in another message that your app is ...
    (comp.os.linux.setup)
  • Re: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >> memory and hence causes the kernel to 'thrash' thus slowing down the ... 4GB physical RAM + 4GB swap area) the application will think that it can ... You've said in another message that your app is ...
    (comp.os.linux.misc)
  • Re: fedora-list Digest, Vol 10, Issue 167
    ... Well, I have two 433 MHz Celerons and 288 MB RAM, and no performance ... > The memory usage is always around 400MB. ... I'd like to introduce you to the vmstat command. ... > I know that SWAP should be double the Physical RAM but I don't have ...
    (Fedora)