[net.unix-wizards] SysIII swapping strangeness

jk@plx.UUCP (John Kullmann) (08/09/85)

The stock swap algorithm will swap out a process which
has been in memory for 2 seconds (regardless of whether it
got *any* cpu time or not since it was swapped in) and swap 
in a selected swapped out process that has been out for 
at least 2 seconds.

Consider a heavily memory (over)loaded system, sometimes
swapping continuously for 5-20 minutes at a time. Is it
possible that processes are being swapped in and back out 
many many times before they actually run? (some of these
processes are > 500Kb).

A few questions:
1) Is this 2 second business left over from the pdp11
	where the address spaces were smaller?  Should
	I/do people change this?
2) Shouldn't the swapper be changed to at least let the
	poor sucker get a few ticks before letting him
	go back out?
3) Do all un*x systems (before demand paging came around)
	slow way,way,way down when anything but trivial
	swapping is occurring?
4) Has anyone else researched this? If so, please save me
	some time and respond...

John Kullmann
...decvax!sun!plx!jk

henry@utzoo.UUCP (Henry Spencer) (08/14/85)

> Consider a heavily memory (over)loaded system, sometimes
> swapping continuously for 5-20 minutes at a time. Is it
> possible that processes are being swapped in and back out 
> many many times before they actually run? (some of these
> processes are > 500Kb).

Not inconceivable.  At the very least, they're not getting *much* run
time per swap.  This is not a trivial problem -- compute just how long
it takes even (say) an Eagle to swap a 500KB process!

> 1) Is this 2 second business left over from the pdp11
> 	where the address spaces were smaller?  Should
> 	I/do people change this?

No, it seems to be left over from systems that were not badly memory-short,
or at least didn't combine memory shortage with big long-running processes.
Even on the 11 this represented very bad behavior if you *did* have big
long-running processes.	 (I speak from experience.)

> 2) Shouldn't the swapper be changed to at least let the
> 	poor sucker get a few ticks before letting him
> 	go back out?

Yup.  In fact, it should be changed to let him have a fair bit of cpu time,
since even with very fast disks it takes the better part of a second to
swap half a megabyte in and out.  This WILL do bad things to the response
time of interactive programs that are competing with the big boy for memory.
This problem is fundamental and unsolvable:  if you cannot get both the
big boy and the interactive programs in memory at once, you have to choose
one or the other.  Trying to do both only results in thrashing.

> 3) Do all un*x systems (before demand paging came around)
> 	slow way,way,way down when anything but trivial
> 	swapping is occurring?

*All* Unix systems -- demand paging or not -- slow way,way,way down if
their physical memory is overcommitted.  "Real memory for real performance."
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

jmc@inset.UUCP (John Collins) (08/23/85)

In article <167@plx.UUCP> jk@plx.UUCP (John Kullmann) writes:
>1) Is this 2 second business left over from the pdp11
>	where the address spaces were smaller?  Should
>	I/do people change this?

Yes it is a leftover from pdp11 days.
I have played around with a program called "tune" which adjusts both
these 2 constants and can make response time *VASTLY* better (although
it depends what you are doing).

>2) Shouldn't the swapper be changed to at least let the
>	poor sucker get a few ticks before letting him
>	go back out?

Yes

-- 
John M Collins		....mcvax!ist!inset!jmc
Phone:	+44 727 57267
Snail Mail: 47 Cedarwood Drive, St Albans, Herts, AL4 0DN, England.