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.
This commit is contained in:
Howard Chu 2001-11-28 20:48:06 +00:00
parent bfe4dc289a
commit 295e14bd54
3 changed files with 36 additions and 22 deletions

View File

@ -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

View File

@ -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 );

View File

@ -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 );