Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 94966 invoked from network); 5 Jan 2006 00:42:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Jan 2006 00:42:49 -0000 Received: (qmail 15539 invoked by uid 500); 5 Jan 2006 00:42:47 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 15512 invoked by uid 500); 5 Jan 2006 00:42:47 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 15501 invoked by uid 99); 5 Jan 2006 00:42:47 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jan 2006 16:42:47 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=NO_REAL_NAME,SPF_HELO_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [193.201.201.170] (HELO lobstertechnology.com) (193.201.201.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jan 2006 16:42:46 -0800 Received: from localhost (localhost [127.0.0.1]) by lobstertechnology.com (Postfix) with ESMTP id F3F4FC832D for ; Thu, 5 Jan 2006 00:42:35 +0000 (GMT) Received: from bb-87-82-30-152.ukonline.co.uk (bb-87-82-30-152.ukonline.co.uk [87.82.30.152]) by lobstertechnology.com (Horde MIME library) with HTTP; Thu, 5 Jan 2006 00:42:35 +0000 Message-ID: <20060105004235.k866zoe3z2g444og@lobstertechnology.com> Date: Thu, 5 Jan 2006 00:42:35 +0000 From: gerry@everythingsucks.co.uk To: dev@apr.apache.org Subject: Re: UPDATE: [Patch] poll/unix/poll.c:apr_pollset_poll() optimisation References: <20060101150105.g571mpamfjeskcww@lobstertechnology.com> <200601011618.30009.nick@webthing.com> <20060102204354.d3922p1jtfwo0ck8@lobstertechnology.com> <20060105002903.wwuzqe7409wggow8@lobstertechnology.com> <7edfeeef0601041636n695c227dsf6f4b76870e76932@mail.gmail.com> In-Reply-To: <7edfeeef0601041636n695c227dsf6f4b76870e76932@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.0.4) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Quoting Garrett Rooney : > Um, I don't think that's going to work, rv is the number of > descriptors that hit, there's nothing that says that if N hit it'll be > the first N... That would be true were I comparing I As for the other version of this patch, I'm kind of curious if it's an > actual improvement. Sure, you can bail early, but at the cost of > intruducing an extra if into each of the iterations before you bail. > Is that actually better in the average case? Yeah I kinda thought the same thing, was bugging me which is why I revisited it. G > On 1/4/06, gerry@everythingsucks.co.uk wrote: >> Greetings, >> >> There's a sneakier (and pretty obvious, once you look at it) way of >> improving this loop which I prefer to my original mail by replacing the >> for-loop condition. >> >> Should be safe: I like poll()... he has an honest face... I don't think >> he will lie to us about the number of signalled descriptors. >> >> >> --- poll.c 2006/01/02 18:30:27 1.1 >> +++ poll.c 2006/01/05 00:11:36 >> @@ -254,13 +254,13 @@ >> return apr_get_netos_error(); >> } >> if (rv == 0) { >> return APR_TIMEUP; >> } >> j = 0; >> - for (i = 0; i < pollset->nelts; i++) { >> + for (i = 0; j < rv; i++) { >> if (pollset->pollset[i].revents != 0) { >> pollset->result_set[j] = pollset->query_set[i]; >> pollset->result_set[j].rtnevents = >> get_revent(pollset->pollset[i].revents); >> j++; >> } >> > > Um, I don't think that's going to work, rv is the number of > descriptors that hit, there's nothing that says that if N hit it'll be > the first N... > > As for the other version of this patch, I'm kind of curious if it's an > actual improvement. Sure, you can bail early, but at the cost of > intruducing an extra if into each of the iterations before you bail. > Is that actually better in the average case? > > -garrett >