Original from Rich Wonneberger to Denis Tonn on 04-27-1998
Original Subject: Beginlibpath?
---------------------------------------
> A word about swapping: It is not the SIZE of a swapper that matters,
> it is the swapping ACITIVITY.
RW> I agree with the amount of activity, but wouldnt a large
RW> swap file be from a lot of activity to get stuff into it??
Not really. Writing a lot of data to a file does not take that long
(in human terms), and it really depends on how long it took to get
such a large file. An easy example is a program with a "memory leak";
a program that allocates some memory for a task, but does not free it.
The next task allocates a new block and so forth. Over a period of
time it may have allocated 100MB of memory, which could all be in the
swapper. But since it never references this memory (it should have
freed it but didn't, so it just sits there) there is no constant
"swapping activity" associated with it. It got paged out once, and has
never come back into RAM, and won't. When the program ends, there will
be a significant amount of reorganization of the swapper as the system
shrinks it back again...
"Normal" program operation could have the same kind of effects
depending on how the program was written, IE: large amount of data in
memory, waiting to be referenced by the user (who only wants to look
at one of those 10,000 phonebook entries at a time).
Sure, there must have been *some* activity to get the page into the
swapper in the first place, but if there are no references to load it
back into RAM after this, it is no longer an "active" page. If all
pages that are in the swapper are not being referenced (at all) then
there is zero "swapper activity", no matter what the size. This is a
very dynamic and fluid set of operations. You have to look at the
situation over a period of time (you choose the time frame!) and
measure the actions. In actual working set measurements I have seen
systems with 100MB swapper and zero swapping activity. On the other
hand I have seen systems with 20MB swapper and lots of activity.
Again, it is the ACTIVITY that counts in performance tuning, not the
swapper SIZE.
Let me try another example:
I have a BBS that runs unattended (for months at a time). It has a
lot of automated maintenance routines in addition to handling mail and
callers. "Normal" operation has zero swapper activity, but when it
receives a new mail packet, a set of code and data that has been
"swapped" becomes referenced and is loaded into RAM. To make room for
this, other pages have to be swapped out. This causes a "spurt" of
swapper activity, but after this the mail run continues to completion
without any further swapper activity (although there is lots of disk
acivity, none of it is swapping activity). When I run a routine to
sort and list all the files on my BBS, the same kind of swapper spurt
happens (possibly pushing out the dormant code/data "left over" from a
mail run). When my backup routine kicks in, the same "spurt" again.
Again, for message base pruning and packing. Again for my offline QWK
message packing, upload, and response processing (I don't need to call
my BBS to pickup and reply to mail). Etc, etc..
All of the above operations run at full speed once started. There is
no swapping activity during the operations themselves. They would not
run any faster if I had more RAM. There *is* a second or 3 of swapper
activity as the new routine becomes active. I would have to have a LOT
of ram (I would guess 512MB) to eliminate most of this swapping, and
"save" about 5-10 seconds every hour. My swapper generally runs
around 24MB on 16MB ram.
Performance tuning is finding the "right balance" between app speed,
user interactions, and system resources for a particular set of
operations. It is not about "eliminating all swapper actions". If this
is what you desire, try modifying config.sys to MEMMAN=NOSWAP. This
will eliminate all possible swapping (you won't be using the system
effectively - and you will need lots more RAM).
I just redid a little test on this 64MB laptop. About 1/2 hour ago
(when I first read this message), I ran a little program that
allocated 100MB of ram (causing swapper growth). Before I started
the program, I had a 4MB swapper (initial size) with 0 pages in use.
LOTS of swapper activity while the program was running. When the
program ended, it freed all the memory it was using. Now my swapper is
30MB in size and 25MB "in use", but I have 42MB of "free" ram. A
working set analysis says I need 16MB to run the things I currently
have running. I have ZERO swapper activity for what I am running now
(granted, it is less than normal) even though my swapper is 30MB in
"size". It will stay here (eventually the shrink process may get it
down to 25MB) until I shut down some processes (and free "memory") or
run something that uses up more than my 46MB of available "free" ram.
There was lots of activity when I heavily overcommited the system
(and the swapper grew to quite a size!), but there is ZERO activity at
the moment even with a 25MB "in use" swapper.
If I run the program and "pause" it (or have it sleep) the swapper
would STILL be a massive size and there would *STILL* be zero swapper
activity as soon as the "paused" program's data was all swapped out..
I have tested this in the past (run 2 copies, pause the first one, let
the second one force the "dormant" pages of the first one out before
it ends, run my "normal" stuff until it all gets swapped back in).
RW> If a system was booted from floppy & a large swap file deleted, would it
be
RW> re-created as a small file?? (azzuming just bringing up
RW> OS/2 with say 32 meg ram & nothing running)
The swapper is recreated each time the system is rebooted. It will
start off at (and never shrink below) the size you specified on the
SWAPPATH= line in config.sys. Initially all the pages in the swapper
are "free" or "empty slots" available for use.
It does not "reuse" the pages in the swapper (although the swap file
MAY be physically in the same place on the drive, it is "recreated"
there each boot up).
RW> When I shut down, is it the ram portion of this that gets
RW> saved, and why would you want to save it?? Why not start
RW> next time clean..
Shutdown does 2 major things, neither of them have anything to do
with memory management or the swapper (directly). It advises all the
running programs that the system is shutting down and gives them a
chance to close any open data files and generally clean things up, and
it flushes the disk cache(s) to the disk. If a program has a bunch of
data in "memory" (some of which might be currently swapped), it may
write all this data to it's files before allowing the system to
shutdown.. The system will have to swap this data in from the swapper
before the program can write it out to it's data files.
Denis
All opinions are my very own, IBM has no claim upon them
.
.
.
--- Maximus/2 3.01
---------------
* Origin: T-Board - (604) 277-4574 (1:153/908)
|