From owner-freebsd-questions@FreeBSD.ORG Sun Mar 15 15:48:53 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27CE91065672 for ; Sun, 15 Mar 2009 15:48:53 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id D37D28FC1C for ; Sun, 15 Mar 2009 15:48:52 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id n2FFmpl8011364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 15 Mar 2009 10:48:51 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id n2FFmodB023665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 15 Mar 2009 10:48:51 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id n2FFmnVc023640; Sun, 15 Mar 2009 10:48:49 -0500 (CDT) (envelope-from dan) Date: Sun, 15 Mar 2009 10:48:49 -0500 From: Dan Nelson To: cpghost Message-ID: <20090315154849.GE24875@dan.emsphone.com> References: <20090315091301.GB1051@phenom.cordula.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090315091301.GB1051@phenom.cordula.ws> X-OS: FreeBSD 7.1-STABLE User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: ClamAV version 0.94.1, clamav-milter version 0.94.1 on email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Sun, 15 Mar 2009 10:48:51 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: freebsd-questions@freebsd.org Subject: Re: Speeding up exit(2)? 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: Sun, 15 Mar 2009 15:48:53 -0000 In the last episode (Mar 15), cpghost said: > I've noticed that when a huge, partially or totally swapped out process > exits, there is a lot of disk activity going on, before the process truly > dies. This is not necessarily due to sync(2), because it also happens > with CPU bound processes that write very little output. > > Not sure what's really going on there, but apparently, the process reads > in pages from swap that have been paged out previously (according to > top(1)). Are you sure this is actually in _exit, and not in a cleanup function executed by the application as it exits? If there is a large linked list, for example, and the author has decided to actually free the list before exiting instead of just letting it disappear when the process exits, each swapped-out page will have to be brought back in as the list is traversed. C++ programs may have destructors doing this behind the scenes. Best way to figure out what's going on is to attach to the program with gdb while it's swapping, and print a stack trace. Also, since you mentioned a "totally swapped out" process exiting, are you terminating it externally with kill -9? It may be writing a core dump, which will force the kernel to pull back swapped-out pages to write them to the core file. > Couldn't this be avoided and the paged out pages simply discarded > without reading them back in? Or do those pages contain necessary > data at this point (page directories etc.)? -- Dan Nelson dnelson@allantgroup.com