From owner-freebsd-hackers Sat Jul 3 21:21:48 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134]) by hub.freebsd.org (Postfix) with ESMTP id 1D68114C96 for ; Sat, 3 Jul 1999 21:21:32 -0700 (PDT) (envelope-from grog@freebie.lemis.com) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by allegro.lemis.com (8.9.1/8.9.0) with ESMTP id NAA19327; Sun, 4 Jul 1999 13:51:30 +0930 (CST) Received: (from grog@localhost) by freebie.lemis.com (8.9.3/8.9.0) id NAA10276; Sun, 4 Jul 1999 13:51:28 +0930 (CST) Date: Sun, 4 Jul 1999 13:51:28 +0930 From: Greg Lehey To: Jonathan Lemon Cc: Peter Wemm , "Brian F. Feldman" , wayne@crb-web.com, hackers@FreeBSD.ORG Subject: Re: poll() vs select() Message-ID: <19990704135128.U709@freebie.lemis.com> References: <19990704040435.35CD464@overcee.netplex.com.au> <19990703231029.08379@right.PCS> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: <19990703231029.08379@right.PCS>; from Jonathan Lemon on Sat, Jul 03, 1999 at 11:10:29PM -0500 WWW-Home-Page: http://www.lemis.com/~grog X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Saturday, 3 July 1999 at 23:10:29 -0500, Jonathan Lemon wrote: > On Jul 07, 1999 at 12:04:35PM +0800, Peter Wemm wrote: >> "Brian F. Feldman" wrote: >>> On Fri, 2 Jul 1999, Jonathan Lemon wrote: >>> >>>> In article > 0000@crb.crb-web.com> you write: >>>>> now supports the select() and poll() system calls. My question is really >> one >>>>> of usage. Why would one us poll() over select()? Is select eventually go >> ing >>>>> to go away for some reason? >>>> >>>> select() as a user-level call will never go away; there is a large base >>>> of code that uses it. >>>> >>>> poll() is faster (it doesn't have to do bit twiddling), and it's interface >>>> is cleaner (it can report invalid fd's, something select() can't do). As >>>> its functionality is a superset of select()'s, it is used as the internal >>>> implementation for select(). >>> >>> Actually, select() doesn't require horrendous amounts of copyin()s, which >>> poll() does. So have you benchmarked the two? I'd expect select to be faster. >> >> Actually.. select() has three copyins and three copyouts per call. poll() >> has one copyin and one copyout per call. >> >> Now what I particular like is the event queue system that David Filo put >> together for Yahoo. In a nutshell you create a queue (a fd), and then >> register the descriptors you want to monitor with the queue. You then run >> an accept()-like loop where the accept returns the fd number that has met >> the conditions you asked for. For example, if you wanted to know if fd >> number 4251 becomes readable, then the accept would return 4251. This has >> potential to work across multiple processes sharing a queue so that events >> could get round robined or whatever. The other good part is that it >> maintains the state and lists persistantly and doesn't have to keep copying >> it to/from the kernel. It handles 50,000 to 100,000 connections without >> too much trouble. You can still use this with select as the queue fd >> becomes readable when there is an event waiting for your process. This sounds rather like what Tandem did in its TOS^H^H^HGuardian^H^H^H^H^H^H^H^HNonStop Kernel operating system. At the user level, you had the choice of calling awaitio (-1), which would return the next completion on any fd, or awaitio (4251), which would return information on that specific fd. And of course you have the choice of blocking or not if the conditions aren't met. Of course, the performance implications of waiting on a specific fd are another issue. >> Is there interest in doing something like this in general? > > YES! As a matter of fact, I've done something similar to this already, > but instead of a queue, it's a variant of poll which passes in and out > "change lists"; a list of fd's which have had status changes since the > last call. I've been trying to bring it up for discussion on the -arch > list, but it's been dead. (I think it was just fixed recently). Did you see the presentation "A scalable and explicit event delivery mechanism for UNIX" at USENIX? It sounded quite interesting. Page 253 of the proceedings. Greg -- See complete headers for address, home page and phone numbers finger grog@lemis.com for PGP public key To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message