Re: When does swap decreases

2005-06-21 Thread Bill Moran
Francisco Reyes [EMAIL PROTECTED] wrote:

 On Mon, 20 Jun 2005, Dan Nelson wrote:
  When the system is low on memory, it will force the least used
  blocks of memory to swap.  It will not free the swap space until
  the process owning them exits
 
 Have not found any program to see what programs are using the swap, but as 
 I think about it, the current method is not very smart. I guess any 
 other method is difficult to implement.
 
 How wonder how the current method affects performance.
 Basically if there is a surge of memory usage and processes start that use 
 the swap and these processes are long lived.. I wonder if performance 
 will be affected.

The answer that was given to you on the usage of swap is greatly simplified.
As a result, it's natural that you would ask these kinds of questions.

In reality, FreeBSD's use of swap is _highly_ optimized.  Even if you don't
fully understand what it's doing ;)

If you're interested in the nitty-gritty details, I suggest you purchase
(or borrow) a copy of _The_Design_and_Implementation_of_FreeBSD_ and read
the detailed descriptions of how the pager and swapper work.  The complexity
of those two systems, and the reasoning behind how they're designed is more
than can easily be answered on an email list.

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Dan Nelson
In the last episode (Jun 20), Francisco Reyes said:
 My swap used to be 30MB+
 I increased from 256MB to 384MB.
 For several days swap usage was zero. Then I saw it increase to a few 
 hundred Kbs.. and now it's up to 10MB.
 
 I am wondering if it's because swap is not going down or there is now that 
 many more programs running (which I doubt).
 
 Before the memory upgrade the swap was very steady at 30MB so after a
 128MB memory increase I am a little surprised my swap seems to be
 staying around 10MB

When the system is low on memory, it will force the least used blocks
of memory to swap.  It will not free the swap space until the process
owning them exits (even if it pages that memory back into RAM), so at
some point the system paged out 30MB of memory, some processes exited
and freed up 20MB, and you probably have some long-lived processes that
account for that remaining 10MB.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Francisco Reyes

On Mon, 20 Jun 2005, Dan Nelson wrote:


When the system is low on memory, it will force the least used blocks
of memory to swap.  It will not free the swap space until the process
owning them exits (even if it pages that memory back into RAM), so at
some point the system paged out 30MB of memory, some processes exited
and freed up 20MB, and you probably have some long-lived processes that
account for that remaining 10MB.


Makes sense.
Any way to find out which process is using the swap?
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Dan Nelson
In the last episode (Jun 20), Francisco Reyes said:
 On Mon, 20 Jun 2005, Dan Nelson wrote:
  When the system is low on memory, it will force the least used
  blocks of memory to swap.  It will not free the swap space until
  the process owning them exits (even if it pages that memory back
  into RAM), so at some point the system paged out 30MB of memory,
  some processes exited and freed up 20MB, and you probably have some
  long-lived processes that account for that remaining 10MB.
 
 Makes sense.
 Any way to find out which process is using the swap?

None that I know of.  Another one of those Junior Kernel Hacker
proejcts :)

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread K. Greenwood


--- Dan Nelson [EMAIL PROTECTED] wrote:
 In the last episode (Jun 20), Francisco Reyes said:
  On Mon, 20 Jun 2005, Dan Nelson wrote:

snipped swap space not decreasing, and revelation
that a process may still exist

  Makes sense.
  Any way to find out which process is using the
 swap?
 
 None that I know of.  Another one of those Junior
 Kernel Hacker
 proejcts :)

snipped

Perhaps /sysutils/lsof?  Desc. as follows.

+++
Lsof (LiSt Open Files) lists information about files
that are open by the running processes.  An open file
may be a regular file, a directory, a block special
file, a character special file, an executing text
reference, a library, a stream or a network file
(Internet socket, NFS file or Unix domain socket).

See also fstat(1) in the base system.

WWW: http://people.freebsd.org/~abe/
+++

I have only recently installed it, not a clue as to
how to use it, however.

BTW, if Mr. Nelson is considered Junior Kernel
Hacker, I qualify as Senior Keyboard Drooler.

AKA, take my advice with a grain of salt.



__ 
Discover Yahoo! 
Find restaurants, movies, travel and more fun for the weekend. Check it out! 
http://discover.yahoo.com/weekend.html 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Francisco Reyes

On Mon, 20 Jun 2005, K. Greenwood wrote:


Perhaps /sysutils/lsof?  Desc. as follows.



Checked both lsof and fstat. Neither lists programs that are using the 
swap.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Francisco Reyes

On Mon, 20 Jun 2005, Dan Nelson wrote:

When the system is low on memory, it will force the least used
blocks of memory to swap.  It will not free the swap space until
the process owning them exits


Have not found any program to see what programs are using the swap, but as 
I think about it, the current method is not very smart. I guess any 
other method is difficult to implement.


How wonder how the current method affects performance.
Basically if there is a surge of memory usage and processes start that use 
the swap and these processes are long lived.. I wonder if performance 
will be affected.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Dan Nelson
In the last episode (Jun 20), Francisco Reyes said:
 On Mon, 20 Jun 2005, Dan Nelson wrote:
  When the system is low on memory, it will force the least used
  blocks of memory to swap.  It will not free the swap space until
  the process owning them exits
 
 Have not found any program to see what programs are using the swap,
 but as I think about it, the current method is not very smart. I
 guess any other method is difficult to implement.
 
 How wonder how the current method affects performance. Basically if
 there is a surge of memory usage and processes start that use the
 swap and these processes are long lived.. I wonder if performance
 will be affected.

There may even be a performance gain, since if the system comes under
memory pressure again, some of the in-memory pages of those long-lived
processes previously copied to swap may still be clean, and the system
won't even have to page them out; it can simply free the RAM.  I can't
think of any way for there to be a performance hit, unless you actually
run out of swap.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Francisco Reyes

On Mon, 20 Jun 2005, Dan Nelson wrote:


In the last episode (Jun 20), Francisco Reyes said:

How wonder how the current method affects performance. Basically if
there is a surge of memory usage and processes start that use the
swap and these processes are long lived.. I wonder if performance
will be affected.


There may even be a performance gain, since if the system comes under
memory pressure again, some of the in-memory pages of those long-lived
processes previously copied to swap may still be clean, and the system
won't even have to page them out; it can simply free the RAM.  I can't
think of any way for there to be a performance hit, unless you actually
run out of swap.



I must really be missing something here..
My case. 384MB of RAM
For several days swap was 0.
That to me means that everything was fitting nicely into memory.

At one point in the last few days I must have opened too many 
windows/apps.. and the OS actually had to use swap.


Once I closed programs (xpecially X, Opera, and other GUI apps) I expected 
the swap would go back to 0.


Swap remained at 10MB.. Whatever processes are using the swap aren't they 
accessing the HD?


Can there be swap usage, yet the OS doing all the work on memory?
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: When does swap decreases

2005-06-20 Thread Dan Nelson
In the last episode (Jun 20), Francisco Reyes said:
 On Mon, 20 Jun 2005, Dan Nelson wrote:
 In the last episode (Jun 20), Francisco Reyes said:
 How wonder how the current method affects performance. Basically if
 there is a surge of memory usage and processes start that use the
 swap and these processes are long lived.. I wonder if performance
 will be affected.
 
 There may even be a performance gain, since if the system comes
 under memory pressure again, some of the in-memory pages of those
 long-lived processes previously copied to swap may still be clean,
 and the system won't even have to page them out; it can simply free
 the RAM.  I can't think of any way for there to be a performance
 hit, unless you actually run out of swap.
 
 I must really be missing something here.. My case. 384MB of RAM For
 several days swap was 0. That to me means that everything was fitting
 nicely into memory.
 
 At one point in the last few days I must have opened too many
 windows/apps.. and the OS actually had to use swap.
 
 Once I closed programs (xpecially X, Opera, and other GUI apps) I
 expected the swap would go back to 0.

Have you disabled all of your console login screens?  Each one has a
getty process that'll never get swapped back in if you always use X. 
Same thing for sshd, sendmail, /bin/sh wrapper scripts around programs,
and probably a dozen other processes that get rarely used on an X
desktop machine.  You've got more than enough idle pages to account for
10MB of used swap.
 
 Swap remained at 10MB.. Whatever processes are using the swap aren't
 they accessing the HD?

If you mean aren't they accessing swap?, the answer is only the
first time they need to retrieve the pages.  To the virtual memory
system, swap is no different from the disk blocks used to store the
contents of /bin/ls.  The first time you use them, they get paged into
RAM.  The next time, they're already in RAM.  If the system is low on
RAM, it first discards clean pages that it can re-fetch from disk
(/bin/ls code for example, or process memory that was swapped out at
some point but is still clean).  The remainder is either dirty disk
cache pages (which it can simply sync to disk), or private process
memory (which gets written to new swap blocks).

 Can there be swap usage, yet the OS doing all the work on memory?

Certainly.  It's easy to verify this by tunning top and watching the
Swap line.  If you don't see any In/Out data, you're not swapping. 
You can also run vmstat -s | grep swap at intervals and verify that
the counters aren't increasing.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]