[comp.sys.next] How do I shrink the swapfile

schock@cpsc.ucalgary.ca (Craig Schock) (03/01/90)

	Last week, our swapfile decided to grow to 41 megs (from 21 megs).
The reason it did this hasn't yet been determined, but this occurrance 
made me come up with some way of shrinking the file.  I rebooted the 
system (single user) and I killed off some of the unnecessary processes.
I then executed:

	mkfile 20M /private/vm/swapfile

and this seemed to do the trick.  

	What I want to know is ... Is there an EASIER way to bring
the swapfile back down to size?  Since we are on a 330 Meg HD with only 
58 Megs free a jump in the size of the swapfile from 21 megs to 41 megs
can cause some problems.  Most VM systems I've worked with don't have a
"growing" swapfile so this little incident came as a little of a shock.
 
Thanks in advance

========================================================================
Craig Schock                               schock@cpsc.UCalgary.CA
University of Calgary  (More reliable ->)  schock@flip.cpsc.UCalgary.CA
========================================================================

eps@toaster.SFSU.EDU (Eric P. Scott) (03/01/90)

I don't have an answer for you, but I did get to see what happens
when you run out of disk space.  This was on a machine that only
had a single 660MB drive at the time.  The swap file grew to 71
megabytes.  It was really weird doing a df and seeing the
filesystem 105% full.  Needless to say, the machine was pretty
much unusable.  There were a whole bunch of

	mach: IO error on pageout: error = 28.
	mach: vnode_pageout: failed!

messages.  (I love it: hey! we're out of disk space!  what should
we do?  let's note it in a log file!)

The swapfile did shrink a little when the cause went away, but
not by a useful amount.  Rebooting left about 35 MB free
according to df.


The culprit: one user, telnetting in, running one program:
Mathematica.  There aren't many things with such an insatiable
appetite for virtual memory--this guy wanted 51 megabytes.  I
wish I had, say, 48MB RAM in 4MB SIMMs for the memory pigs.
(This really makes me wonder about the wisdom of putting only 40MB
for swap+/tmp in each of the formerly diskless workstations...
Doesn't seem like enough for people who want to do real work.)

Interestingly enough, in its present configuration, the machine
rarely seems to get "slow" even with its mere 68030--it runs out
of process slots before horsepower.  Not that I wouldn't mind
seeing a faster processor (especially when printing).  Still,
nothing helps like having enough RAM.  You can tell when the
machine is paging because the performance loss is so noticeable.

					-=EPS=-

wilson@mit-amt.MEDIA.MIT.EDU (Wilson Chan) (03/01/90)

In article <2558@cs-spool.calgary.UUCP> schock@cpsc.ucalgary.ca (Craig Schock) writes:

[stuff deleted]

>	What I want to know is ... Is there an EASIER way to bring
>the swapfile back down to size?  Since we are on a 330 Meg HD with only 
>58 Megs free a jump in the size of the swapfile from 21 megs to 41 megs
>can cause some problems.  Most VM systems I've worked with don't have a
>"growing" swapfile so this little incident came as a little of a shock.
> 
>Thanks in advance
>
>========================================================================
>Craig Schock                               schock@cpsc.UCalgary.CA
>University of Calgary  (More reliable ->)  schock@flip.cpsc.UCalgary.CA
>========================================================================

The file, /etc/swaptab, controls the swapfile size.  Here's the original file:

/private/vm/swapfile	lowat=20971520	#  20 Meg low water mark

The OS will "attempt" to shrink the swapfile down to lowat.  Similarly, you
can add a hiwat entry which tells the OS not to grow infinitely big.  I think 
the keyword here is "attempt".  My swapfile stays at 20Meg even when I set the
lowat to 16Meg and only a Terminal is running.  

--wilson

mic@ut-emx.UUCP (Mic Kaczmarczik) (03/02/90)

In article <2558@cs-spool.calgary.UUCP> schock@cpsc.ucalgary.ca (Craig Schock) writes:
>
>	Last week, our swapfile decided to grow to 41 megs (from 21 megs).
>The reason it did this hasn't yet been determined, but this occurrance 
>made me come up with some way of shrinking the file.  I rebooted the 
>system (single user) and I killed off some of the unnecessary processes.
>I then executed:
>
>	mkfile 20M /private/vm/swapfile
>
>and this seemed to do the trick.  

	I think this is done automatically on bootup, but I haven't
	checked lately...

>	What I want to know is ... Is there an EASIER way to bring
>the swapfile back down to size?  Since we are on a 330 Meg HD with only 
>58 Megs free a jump in the size of the swapfile from 21 megs to 41 megs
>can cause some problems.  Most VM systems I've worked with don't have a
>"growing" swapfile so this little incident came as a little of a shock.

	I don't think there is an easy way to reduce the swapfile size. In my
	experience, once the swapfile has filled up the disk, about the only
	thing to do is reboot the system. 

	However, I have been able to *limit* the growth of the swapfile by
	setting the hiwat parameter in /etc/swaptab; the one we're using on
	our consulting cube is:

#
#       /etc/swaptab
#
/private/vm/swapfile    lowat=20971520,hiwat=62914560 # 20 Meg low water mark

	This limits the size of the swapfile to around 60 meg, which will
	hopefully be enough for this particular cube (its swapfile seems to
	grow to about 37M after a day or so of operation, so there's plenty of
	room left). The swaptab man page has more details on the other
	settings that are available. 

--mic--

-- 
Mic Kaczmarczik                                   mic@emx.utexas.edu (Internet)
Unix/VMS/Cyber Services                                     mic@utaivc (BITNET)
UT Austin Computation Center                ...!cs.utexas.edu!ut-emx!mic (UUCP)
COM 1/UT Austin/Austin TX 78712              ``Good tea.  Nice house.'' -- Worf

Please direct consulting questions to gripe@{emx,ix2,ccwf,iv1} as appropriate.

smithw@physc1.byu.edu (03/02/90)

eps@sutro.SFSU.EDU (Eric P. Scott) writes:
>The swapfile grew to 71 megabytes
  I frequently run Mathematica stuff that takes upward of 100MB of
swap and the system is virtually dead until I can reboot. ('course I
only have an OD only system with the fancy files stripped off).
  Somebody (Avie?) from NeXT explained why the swapfile grows like this
(never shrinks until reboot) last fall. It's probably on the
archives somewhere.
  I have 16 meg ram and things still crawl when I open a big
Mathematica file. "Serious" Mathematica stuff is just plain slow
on the NeXT.  I'm still hoping for Maple with a good NeXT front
end.