Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Mar 2009 10:48:49 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        cpghost <cpghost@cordula.ws>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Speeding up exit(2)?
Message-ID:  <20090315154849.GE24875@dan.emsphone.com>
In-Reply-To: <20090315091301.GB1051@phenom.cordula.ws>
References:  <20090315091301.GB1051@phenom.cordula.ws>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090315154849.GE24875>