Re: Fine grain select locking.



Here is an update that avoids the malloc per fd when there are no collisions. This unfortunately adds 64bytes to every socket in the system. This is less than 10% of the size of the socket. Vnodes only allocate their selinfo structures on demand so this does not cause a per-file overhead. This was suggested by Peter. This patch also uses a vm zone for the selfd structures. I can shrink them slightly by using a SLIST in one case vs TAILQ as well.

http://people.freebsd.org/~jeff/select2.diff

Thanks,
Jeff

On Mon, 2 Jul 2007, Jeff Roberson 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.

Thanks,
Jeff
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"

_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: non blocking sockets
    ... >> determined that the socket was ready. ... > Upon successful completion, the pselector selectfunction shall ... > arguments to indicate which file descriptors are ready for reading, ... > descriptor shall be considered ready for reading.) ...
    (comp.unix.programmer)
  • RE: UDP recvmsg blocks after select(), 2.6 bug?
    ... > - select returns success with descriptor ready for reading ... against having a socket operation block is found in non-blocking sockets. ... then checks the UDP checksum. ...
    (Linux-Kernel)
  • Re: Linux Threading
    ... > That would imply that the socket were already shared via the ... > its descriptor and then thread to get a second thread to use ... you could get by with no additional signalling. ... they were definitely not thread safe. ...
    (comp.os.linux.development.system)
  • Re: epoll and timeouts
    ... I'd recommend just using the descriptor. ... descriptors to internal socket structures is probably best. ... I don't think I understand why the map is better. ... hasn't exactly been known to keep the most thought-out interfaces. ...
    (comp.unix.programmer)
  • Re: Finding an available port for a socket connection?
    ... have a conflict in that range. ... It is acutally fairly likely there will be collisions if there are ... several instances of my code running on the same machine under the same ... Socket socket = new Socket(AddressFamily.InterNetwork, ...
    (microsoft.public.dotnet.framework)