[EXIM] CDB support for exim 1.890

Top Page
Delete this message
Reply to this message
Author: Nigel Metheringham
Date:  
To: Philip Hazel
CC: exim-users
Subject: [EXIM] CDB support for exim 1.890
[copied to the list in case anyone else has interest in this - especially
if other people would be willing to test it...]

Philip,

Here is a working tested (honest) cut of my cdb support for exim. It has
been fairly thoroughly tested on Linux, and lightly on SunOS. There
should not be any real system dependencies (other than 2 I mention later
in detail).

CDB stands for "Constant DataBase" and is a concept/package produced by 
Dan Bernstein.  The specification and sample code can be found at
    http://www.pobox.com/~djb/cdb.html


CDB is designed to be a low overhead lightweight means of referencing data
tables that are effectively constant (ie you create the database once and
read data from it many times). There are no update functions, but
creating of a cdb is very fast - at least 20 times quicker than the best
Berkeley db implementation I found.

The code within exim takes a few supporting functions from Dan's code, but
is in general a reimplementation of Dan's specification. It is
self-contained - you do not need the reference implementation's libraries
(although you will need some way of creating databases since this
implementation is read-only).

There are 2 implementation varients within my code:-
  1. A basic implementation which is always compiled in as a fallback.
  2. An implementation using mmap() for greater flexibility and speed
     and also the advantage that cdb files can be shared between
     multiple processes (using mmap read-only/shared semantics).


The mmap implementation is selected depending on whether the HAVE_MMAP
define is defined - this has been added into a number of the os.h files
for various operating systems, although I will have missed some....
If the mmap() call fails the implementation falls back to the standard
version.

With the mmap version of the cdb code, lookups are slightly quicker (user,
sys and clock time, with significantly fewer page faults) than a Berkeley
DB 1.85 implementation (this will depend somewhat on your config).
Without mmap the performance is less consistant (it is more affected by
current disk i/o etc), but it is comparable to Berkeley DB.

The other OS dependancy is that at present the code assumes that an
"unsigned int" is 32 bits wide - which holds on all current systems that I
have seen. Any good suggestions for a portable way of getting a 32 bit
unsigned quantity would be gratefully received.

To use, patch your 1.890 sources, add "LOOKUP_CDB=yes" to the
Local/Makefile and rebuild. Wherever you currently can use dbm/lsearch
etc lookup you can now additionally use a cdb lookup.

You will need Dan Bernstein's package to create cdb files - I will look at
updating exim_dbmbuild at a later date.

Please let me know of any problems in use.

    Nigel.


[ Nigel.Metheringham@??? - Systems Software Engineer ]
[ Tel : +44 113 251 6012                   Fax : +44 113 234 6065 ]
[      Real life is but a pale imitation of a Dilbert strip       ]