On Apr 18, 2006, at 10:32 am, Andrew Piskorski wrote:
On Tue, Apr 18, 2006 at 08:46:39AM +0100, John Buckman wrote:
Is it possible to build AOLServer in a single-threaded, lock-free
manner?

My guess is the only remotely plausible way, short of redesigning and
reimplementing everything from scratch, would be to convert AOLserver
from multi-threaded to multi-process with System V shared memory, and
perhaps write an emulation layer for the POSIX Threads APIs on top of
that.

That really wasn't my question, it really was "if AOLServer is running in single threaded mode, does it not need locking, if if not, is it possible to disable the locking". However, you answered that question later on:
When you start up AOLserver, it is ALWAYS using multiple threads, two
or three or so at the very minimum.  I would be quite surprised if it
continued to run reliably after you removed every single mutex lock...

so that's fine.

Because BerkeleyDB's tcl interface isn't thread safe, I'm running
aolserver in single-thread mode, with

In what way is it not thread safe?  Depending on just what the problem
is, you may able to make it thread safe (at least for your use cases)
with only a modest amount of work.  (Or if you're unlucky, it could be
a LOT of work, it all depends.)

Internally, they're using a global structure to convert Tcl db handles into a C struct, and those aren't thread safe and get corrupted. When Aolserver runs in 1 thread-max-mode, I don't have a problem. What's frustrating is that I'm wrapping a mutex around my berkeleydb operations, and that doesn't seem to be enough to prevent corruption in all cases (but it helps a lot)

Incidentally, I know next nothing about BerkelyDB, but why are you
using it in the first place?  Are you forced to because some 3rd party
library you need to use uses it?  Or are you free to use something
else instead which is already thread-safe, like SQLite?

BerkeleyDB is (one of) the underlying databases to MySQL, and is psychotically fast, much faster than SQL is, and the web site I'm writing (a book sharing site) needs high scalability. I also run www.magnatune.com, which uses MySQL, and run against scalability problems all the time.

ns_param maxthreads 1

ApacheBench shows me getting 440 page requests per second, on an ADP
page that does a database find and read operation, which is really
fast still, even when I set concurrency at 10 with ApacheBench.

440 hits/s to this one single ADP page isn't fast enough for you?
Just what is this page doing, such that you need it to go faster?

440 hits/s second is plenty fast, amazing even (fyi, compared to about 12 hits/s I get if I code the same page in MySQL), I was just wondering if I could remove locks to speed things up a bit more, just for giggles.

"ns_param maxthreads" sets the maximum number of connection threads,
not the number of ALL threads of any type in the AOLserver process.

Very helpful to know, thanks.

-john


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to