apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Stoddard <b...@wstoddard.com>
Subject Re: pollset initialization within apr_file_open()?
Date Mon, 04 Jul 2005 18:01:05 GMT
Joe Orton wrote:
> On Sun, Jul 03, 2005 at 04:27:05PM -0700, Brian Pane wrote:
> 
>>I just did some performance profiling of httpd-2.1 for the first time  
>>in a long while.
>>
>>One of the odd things I noticed is that apr_file_open() appears to  
>>spend half its time
>>in a call to apr_pollset_create().
>>
>>The pollset creation can be expensive, especially on platforms where 
>>it's implemented using /dev/poll or kqueue.  And as far as I can tell. 
>>the pollset is only used in the special case of 
>>apr_wait_for_io_or_timeout() where the caller wants to wait on a file.
> 
> 
> Note that this problem only affects the very small number of platforms 
> without a (working) poll() implementation.
> 
> 
>>I'm inclined to think that the pollset within an apr_file_t should be 
>>created only if needed--e.g., with lazy initialization triggered via 
>>an apr_file_get_pollset() function.  Such a function wouldn't be 
>>thread-safe without some extra synchronization, of course, but that's 
>>true of many of the apr_file_* and apr_pollset_* operations already.
> 
> 
> apr_wait_for_io_or_timeout could not be used from multiple threads for 
> one file object already since the pollset use is not safe for such use 
> either, so just creating the pollset there would probably work.
> 
> The other alternative is just to implement the function using select(), 
> but that then trades off against the FD_SETSIZE limitation.
> 
> Possibly "use select if fd < FD_SETSIZE or fallback on creating a 
> pollset" would be the most efficient for the normal case.
> 
> joe

It's been quite a while since I profiled httpd but I distinctly recall that select on AIX,
specifically the 
memset to clear out the FD_SET, chewed up CPU. FD_SETSIZE on AIX 5.2 is 64K.

Bill


Mime
View raw message