Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jul 2007 00:14:11 -0700
From:      Alfred Perlstein <alfred@freebsd.org>
To:        Jeff Roberson <jroberson@chesapeake.net>
Cc:        arch@freebsd.org
Subject:   Re: Fine grain select locking.
Message-ID:  <20070703071411.GK45894@elvis.mu.org>
In-Reply-To: <20070702230728.E552@10.0.0.1>
References:  <20070702230728.E552@10.0.0.1>

next in thread | previous in thread | raw e-mail | index | archive | help
* Jeff Roberson <jroberson@chesapeake.net> [070702 23:21] wrote:
> I have a diff which makes the following improvements to select:
> 
> 1) Per-thread wait channel rather than global select wait channel.
> 2) Per-thread select lock.
> 3) Rescan after sleep scans only descriptors which have come active.
> 4) No exposed select internals.
> 5) selwakeuppri() works again.
> 6) No thread_lock()ing in select, no TDF_SELECT required.
> 7) No more collisions.
> 
> This is based on an approach from Alfred with some locking and rescan 
> improvements by me.  It only required changing select users in cases where 
> they assumed only one thread could select at a time.
> 
> The unfortunate cost of this patch is that a descriptor per select fd must 
> be allocated to track individual threads.  This is what allows us to know 
> which descriptor has fired an event and allows us to use per-thread 
> locking etc.
> 
> The one thing I haven't fixed is netsmb and netncp which both have some 
> wonky select implementation that could be replaced with kern_select(). 
> That could be done seperately from this patch but is required for this to 
> go in.
> 
> http://people.freebsd.org/~jeff/select.diff
> 
> Comments and suggestions welcome.

Sounds cool.  I really wish that the rescan wouldn't be needed.  I
think in practice select or poll returning more than 1-4 descriptors
ready doesn't happen so it's not that big of a deal, but still. :)

Also, have you thought of a cache per-thread for the selfd?

There's actually two places for this cache -it's hard to see if you're
already doing this but- one is a cache for the bits copied in for
select/poll, the other is a cache for the selfds, so that a process
selecting on the same fds does not need to allocate/free N "selfd"s
per iteration of select.

Also, while doing this work, I found that using slightly more
descriptive names for the components helps to keep things more
readable.  Instead of "selfd" 


-- 
- Alfred Perlstein



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