Wednesday, May 19, 2010

Compiling Berkeley DB on GNU/Linux

When compiling Berkeley DB on GNU/Linux (in particular if it's being compiled to be used with OpenLDAP), make sure you compile it with the following flags:

--enable-posixmutexes --with-mutex=POSIX/pthreads

I happened to run across that buried in the openldap-software mailing list archives. Here are some more details:
"On x86 though, they have a hybrid mutex mechanism which is enabled by default. It uses both assembly language spinlocks and pthread mutexes, first spinning in the assembly language lock some number of times before falling back onto the mutex. They claimed that this improved performance in their tests, because pthread mutexes can be very expensive on some platforms. In my tests on x86_64 Linux however, it just forced CPU usage to 100% (200% actually, dualcore) and slowed down overall throughput.

You can give an explicit "--with-mutex=POSIX/pthread" argument when configuring BerkeleyDB to avoid the hybrid mutex scheme"
http://www.openldap.org/lists/openldap-software/200708/msg00344.html

"BerkeleyDB will use excessive CPU on Linux unless you configure --with-mutex=POSIX/pthreads. By default it uses "hybrid" mutexes, which use an assembly language spinlock loop before falling back to pthread mutex. The spinlock will chew up all of your CPU on multiprocessor machines..."
http://www.openldap.org/lists/openldap-devel/200809/msg00085.html

More:
http://www.openldap.org/lists/openldap-devel/200902/msg00064.html
http://www.openldap.org/lists/openldap-technical/200906/msg00015.html

0 comments:

Post a Comment