> > > This stuff came up while Justin and Aaron were performance testing
> > > mod_mbox -- right now you can double the requests per second simply
> > > by recompiling with --disable-threads.
> 
> Wow, which MPM are you using? That is actually quite a suprise to me as Apache 2.0 
>performance is
> close to that of Apache 1.3 (on AIX at least) which does not use pool  locking or 
>buffer locking for
> file i/o.

We are currently using prefork because pthread is completely useless at
this point.  Hopefully, the signals stuff gets fixed soon...  Actually, 
on FreeBSD, threaded MPMs are disabled, but no one tells APR, so it 
defines APR_HAS_THREADS - we need to fix that.  I may submit a patch for
that - just add --disable-threads to APRs configure for these platforms?

The traditional static pages bypass most of the locks because they only
deal with ap_send_fd (apr_bucket_file.c).  They also aren't stressing
the locking.  Lots of apr_pallocs in the SDBM code (and to some extent
in mod_mbox).  Each request needs to load the SDBM file into memory.
Somehow there is an exclusive cross-process lock going on somewhere 
(upon further review, we don't think it is fcntl - but it still might 
be...).  The net result is that only one process is running at a time.

There seems to be a lot of lock contention going on within SDBM - we
ONLY want read access.  As Roy has pointed out, there should be very 
little locking going on in the mainline read code ANYWHERE within Apache
(and hence within APR).  This is why each request gets its own 
thread/process/whatever-the-MPM-decides.  Requests shouldn't spawn
threads themselves.  r->pool is allocated on a per-request-basis.  
Therefore, it is pointless to lock that.  By its very nature, we
know that we are exclusive.

I was actually shocked, but mod_mbox's performance *doubles* when we
disable APR threading.  We were able to duplicate this on FreeBSD
and Linux (haven't seen what the performance on Solaris is yet).  
mod_mbox doesn't give a hoot for threads anywhere.  Actually IIRC, 
SDBM doesn't either explicitly - but the pools, IO, and locks do.  

I'm not exactly sure where to start with removing the locks.  I guess
we could just remove ALL of the locking calls in read and pools (unless
global pools) and see if we can get threaded APR to be closer to
non-threaded APR.  Roy might have some ideas...  -- justin

Reply via email to