From: Howard Chu Date: Wed, 28 Nov 2001 20:48:06 +0000 (+0000) Subject: Renamed BDB_ID2ENTRY_PAGESIZE to just BDB_PAGESIZE; set it on each database X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~814 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=295e14bd54c47e5c8d583b03be7ec8e08b6e7389;p=openldap Renamed BDB_ID2ENTRY_PAGESIZE to just BDB_PAGESIZE; set it on each database instead of just the id2entry db. It helps. I also found that tweaking the environment (set_lg_bsize 2MB; set_cachesize 2MB) helps but those can be taken care of in a DB_CONFIG file. Tweaked the bdb_bt_compare function; it really only needs to be set on little-endian machines. (On big-endian machines a lexical sort gives the same result as an integer sort.) Moved the final checkpoint back to the dbenv_close, I think this leaves a cleaner log file. --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 26eb103c5c..e8f3a6ae83 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -47,10 +47,11 @@ LDAP_BEGIN_DECL /* The bdb on-disk entry format is pretty space-inefficient. Average * sized user entries are 3-4K each. You need at least two entries to * fit into a single database page, more is better. 64K is BDB's - * upper bound. + * upper bound. The same issues arise with IDLs in the index databases, + * but it's nearly impossible to avoid overflows there. */ -#ifndef BDB_ID2ENTRY_PAGESIZE -#define BDB_ID2ENTRY_PAGESIZE 16384 +#ifndef BDB_PAGESIZE +#define BDB_PAGESIZE 16384 #endif #define BDB_INDICES 128 diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index a959c23505..580506e807 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -68,6 +68,8 @@ bdb_db_cache( return rc; } + rc = db->bdi_db->set_pagesize( db->bdi_db, BDB_PAGESIZE ); + file = ch_malloc( strlen( name ) + sizeof(BDB_SUFFIX) ); sprintf( file, "%s" BDB_SUFFIX, name ); diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index b7775be791..6672c3029b 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -102,14 +102,26 @@ static void *lock_detect_task( void *arg ) int bdb_bt_compare( DB *db, - DBT *usrkey, - DBT *curkey + const DBT *usrkey, + const DBT *curkey ) { - ID usr, cur; - memcpy(&usr, usrkey->data, sizeof(ID)); - memcpy(&cur, curkey->data, sizeof(ID)); - return usr - cur; + unsigned char *u, *c; + int i; + + u = usrkey->data; + c = curkey->data; + +#ifdef WORDS_BIGENDIAN + for( i = 0; i < sizeof(ID); i++) +#else + for( i = sizeof(ID)-1; i >= 0; i--) +#endif + { + if( u[i] - c[i] ) + return u[i] - c[i]; + } + return 0; } static int @@ -232,9 +244,9 @@ bdb_db_open( BackendDB *be ) if( i == BDB_ID2ENTRY ) { rc = db->bdi_db->set_bt_compare( db->bdi_db, bdb_bt_compare ); - rc = db->bdi_db->set_pagesize( db->bdi_db, - BDB_ID2ENTRY_PAGESIZE ); } + rc = db->bdi_db->set_pagesize( db->bdi_db, BDB_PAGESIZE ); + rc = db->bdi_db->open( db->bdi_db, bdbi_databases[i].file, /* bdbi_databases[i].name, */ NULL, @@ -283,17 +295,6 @@ bdb_db_close( BackendDB *be ) int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; - /* force a checkpoint */ - if( bdb->bi_txn ) { - rc = txn_checkpoint( bdb->bi_dbenv, 0, 0, DB_FORCE ); - if( rc != 0 ) { - Debug( LDAP_DEBUG_ANY, - "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); - return rc; - } - } - while( bdb->bi_ndatabases-- ) { rc = bdb->bi_databases[bdb->bi_ndatabases]->bdi_db->close( bdb->bi_databases[bdb->bi_ndatabases]->bdi_db, 0 ); @@ -308,6 +309,16 @@ bdb_db_destroy( BackendDB *be ) int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; + /* force a checkpoint */ + if( bdb->bi_txn ) { + rc = txn_checkpoint( bdb->bi_dbenv, 0, 0, DB_FORCE ); + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); + } + } + /* close db environment */ if( bdb->bi_dbenv ) { rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );