From owner-freebsd-questions@FreeBSD.ORG Tue Jun 21 03:49:58 2005 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BA5E16A41C for ; Tue, 21 Jun 2005 03:49:58 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id EB4B143D55 for ; Tue, 21 Jun 2005 03:49:57 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id j5L3nuLv057699; Mon, 20 Jun 2005 22:49:56 -0500 (CDT) (envelope-from dan) Date: Mon, 20 Jun 2005 22:49:56 -0500 From: Dan Nelson To: Francisco Reyes Message-ID: <20050621034956.GI8497@dan.emsphone.com> References: <20050620141439.S36309@zoraida.natserv.net> <20050620182430.GE8497@dan.emsphone.com> <20050620144631.F37558@zoraida.natserv.net> <20050620185545.GF8497@dan.emsphone.com> <20050620225204.F41158@zoraida.natserv.net> <20050621030141.GH8497@dan.emsphone.com> <20050620230435.H41158@zoraida.natserv.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050620230435.H41158@zoraida.natserv.net> X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.9i Cc: FreeBSD Questions List Subject: Re: When does swap decreases X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2005 03:49:58 -0000 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 dnelson@allantgroup.com