Speeding up exit(2)?

Dan Nelson dnelson at allantgroup.com
Sun Mar 15 08:48:53 PDT 2009


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 at allantgroup.com


More information about the freebsd-questions mailing list