From: djz@cbnews.cb.att.com (danny.zerkel)
Subject: Re: SWAP size for 20MB IIci?
Organization: AT&T
Distribution: usa
Date: Mon, 11 Jan 1993 20:55:15 GMT

In article <1993Jan9.225116.18441@noao.edu> tody@noao.edu writes:
>In article <1368@jagubox.gsfc.nasa.gov>, jim@jagubox.gsfc.nasa.gov (Jim Jagielski) writes:
>> I ramble:
>> 
>> >tody@noao.edu (Doug Tody) writes:
>> 
>> >>This is what I thought too, but swap appears to work differently under A/UX
>> >>than most UNIX systems.  On most UNIX systems I have seen swap space is
>> >>allocated when virtual memory is allocated to a process; every time you run
>> >>a process or do a malloc in the process you see the available swap space
>> >>decrease.  On A/UX however, if you can believe swap -l, NO swap space is
>> >>used until the total virtual memory usage exceeds the physical memory
>> >>available.  Hence if you have vast amounts of physical memory, little or no
>> >>swap is used.
>> 
>> >One must recall that A/UX (as well as other "newer" :) Unices) perform both
>> >swapping and paging... 

Well... not really...

>
>Well, of course.  I was referring mainly to differences in how these systems
>handle paging of virtual memory.  UNIX systems use the swap area for paging
>as well as swap; for a virtual memory system swapping and paging are closely
>related.  Most UNIX systems preallocate space in the swap area for paging
>when memory is *allocated* by a process - whether or not the process has any
>writable pages paged out.  On a busy system this guarantees that the space
>will be there when if and when it is needed.  A/UX is unusual in that it
>appears to wait until physical memory is exhausted, i.e., until it actually
>has to page something out, before allocating space in the swap area.  On
>most UNIX systems, as someone said earlier, one typically allocates
>something like 2 times the physical memory for swap, e.g., 40-80 Mb or even
>more on some systems.  A/UX appears to be able to make do with much less
>swap space and swap usage tends to decrease as the physical memory increases.

A/UX 3.0 is based (like it's predicessors) on AT&T SVR2.  The paging system
in SVR2 and SVR3 is seriously flawed.  Unlike the BSD based virtual memory
system, SVR2&3 consider swap space to be an extension of memory space.  So
in theory, your "virtual" memory space is RAM + swap space.  Unfortunately,
in order for the kernel to allocate more memory for a process, that memory
must be "free" all at once in the RAM area.  To keep enough memory free,
the "vhand" process scans memory looking for old pages to throw out when a
low memory condition occurs.  How much memory to keep free and how often to
look are what you tune in vhand.  However, since vhand is "just-another-
process", other processes go into memory starvation before vhand can clean
up enough space.  When SVR2&3 run out of memory in swap they start limping.
I have seen systems take 20 minutes or more to shutdown when they are out
of memory.  And there is nothing you can do about it.  Fortunately, SVR4
did not keep this system.  They use a BSD-like virtual memory scheme, where
your experience with 2 * mem == swap is true, since BSD virtual memory is
the size of swap space; and RAM is just a mapping of that space.

---------------------------------------------------------------------------
Danny J. Zerkel, AT&T Bell Labs, Columbus, OH
"Proprietary information contained in this line only!" -- Use your secret
 decoder ring to find it!
Newsgroups: comp.unix.aux