Subject: Re: more on exit performance
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-perform
Date: 11/02/2003 11:43:32
On Sun, Nov 02, 2003 at 11:59:10AM +0100, Jaromir Dolecek wrote:
> David Laight wrote:
> > >  (2) for (pid == -1), we can keep the stopped and dead children on
> > >      separate lists, and only look at the list(s) that we care about.
> > 
> > Why not just requeue a stopped child at the top of the sibling list?
> > It will save all the extra pointers (and data structures to get wrong!).
> > I don't know how how many children the benchmark process has, but I
> > suspet it is a lot!  Even then this gains <10%, for a normal process
> > (and system workload) it must be noise.
> 
> It would be very easy to optimize the WAIT_ANY zombie lookup by looking
> at zombproc - that list should be mostly empty and the lookup
> should be faster than loop over children.

Except that most shells look for stopped processes as well.
I also have a long-term plan to kill the 'allproc' and 'zombproc' lists.
(scan pid_table if truly necessary).

> > 	David
> > 
> > Index: kern_exit.c
> > ===================================================================
> > RCS file: /cvsroot/src/sys/kern/kern_exit.c,v
> > retrieving revision 1.124
> > diff -u -p -r1.124 kern_exit.c
> > --- kern_exit.c	2003/09/16 13:46:24	1.124
> > +++ kern_exit.c	2003/11/02 10:39:49
> > @@ -718,10 +727,16 @@ find_stopped_child(struct proc *parent, 
> >  	for (;;) {
> >  		c_found = 0;
> >  		LIST_FOREACH(child, &parent->p_children, p_sibling) {
> > -			if (pid != WAIT_ANY &&
> > -			    child->p_pid != pid &&
> > -			    child->p_pgid != -pid)
> > -				continue;
> > +			if (pid >= 0) {
> > +				if (child->p_pid != pid) {
> > +					child = pfind(pid);
> > +					if (child == NULL
> > +					    || child->p_parent != parent)
> > +						break;
> 
> This should be outside the LIST_FOREACH() loop. Also, this only
> optimizes asleep child lookup, not zombie lookup. Given that
> more frequent operation is wait for deceased child, we should
> optimize that operation too.

The logic of the function needs it to be inside the loop!

Mmm pfind() needs some flags - for locking as well as finding zombies.

	David

-- 
David Laight: david@l8s.co.uk