From: Howard Chu Date: Sat, 11 Aug 2007 19:29:14 +0000 (+0000) Subject: Add config keyword for DN cache size (aka EntryInfoSize) X-Git-Tag: OPENLDAP_REL_ENG_2_4_MP~234 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8b27523e4cfbd3f2e6f4b262821fd4736cba160c;p=openldap Add config keyword for DN cache size (aka EntryInfoSize) default is 2x entry cache size --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 721096fa9b..f0dc800007 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -131,6 +131,7 @@ typedef struct bdb_cache { int c_maxsize; int c_cursize; int c_minfree; + int c_eimax; int c_eiused; /* EntryInfo's in use */ int c_leaves; /* EntryInfo leaf nodes */ int c_purging; @@ -288,6 +289,8 @@ struct __db_locker { u_int32_t id; }; +extern int __lock_getlocker(DB_LOCKTAB *lt, u_int32_t locker, int create, DB_LOCKER **ret); + #define CURSOR_SETLOCKER(cursor, id) \ __lock_getlocker(cursor->dbp->dbenv->lk_handle, id, 0, &cursor->locker) #define CURSOR_GETLOCKER(cursor) cursor->locker->id diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 3a4618a041..db5429382b 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -631,7 +631,7 @@ bdb_cache_lru_purge( struct bdb_info *bdb ) if ( slapMode & SLAP_TOOL_READONLY ) eimax = 0; else - eimax = bdb->bi_cache.c_maxsize * 4; + eimax = bdb->bi_cache.c_eimax; /* Look for an unused entry to remove */ for ( elru = bdb->bi_cache.c_lruhead; elru; elru = elnext ) { diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 7105c1762b..39d1116cd3 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -86,6 +86,11 @@ static ConfigTable bdbcfg[] = { "( OLcfgDbAt:1.5 NAME 'olcDbDirtyRead' " "DESC 'Allow reads of uncommitted data' " "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, + { "dncachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, + (void *)offsetof(struct bdb_info, bi_cache.c_eimax), + "( OLcfgDbAt:1.12 NAME 'olcDbDNcacheSize' " + "DESC 'DN cache size' " + "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, { "idlcachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, (void *)offsetof(struct bdb_info,bi_idl_cache_max_size), "( OLcfgDbAt:1.6 NAME 'olcDbIDLcacheSize' " @@ -140,7 +145,7 @@ static ConfigOCs bdbocs[] = { "olcDbNoSync $ olcDbDirtyRead $ olcDbIDLcacheSize $ " "olcDbIndex $ olcDbLinearIndex $ olcDbLockDetect $ " "olcDbMode $ olcDbSearchStack $ olcDbShmKey $ " - "olcDbCacheFree ) )", + "olcDbCacheFree $ olcDbDNcacheSize ) )", Cft_Database, bdbcfg }, { NULL, 0, NULL } }; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 521dc26b47..24cedde31a 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -301,7 +301,7 @@ shm_retry: flags | do_recover, bdb->bi_dbenv_mode ); if ( rc ) { - /* Regular open faied, probably a missing shm environment. + /* Regular open failed, probably a missing shm environment. * Start over, do a recovery. */ if ( !do_recover && bdb->bi_shm_key ) { @@ -337,6 +337,11 @@ shm_retry: } #endif + /* Default dncache to 2x entrycache */ + if ( bdb->bi_cache.c_maxsize && !bdb->bi_cache.c_eimax ) { + bdb->bi_cache.c_eimax = bdb->bi_cache.c_maxsize * 2; + } + if ( bdb->bi_idl_cache_max_size ) { bdb->bi_idl_tree = NULL; bdb->bi_idl_cache_size = 0; diff --git a/servers/slapd/back-bdb/monitor.c b/servers/slapd/back-bdb/monitor.c index afc173e62d..ffde364a27 100644 --- a/servers/slapd/back-bdb/monitor.c +++ b/servers/slapd/back-bdb/monitor.c @@ -32,7 +32,7 @@ static ObjectClass *oc_olmBDBDatabase; static AttributeDescription *ad_olmBDBEntryCache, - *ad_olmBDBEntryInfo, *ad_olmBDBIDLCache, + *ad_olmBDBDNCache, *ad_olmBDBIDLCache, *ad_olmDbDirectory; #ifdef BDB_MONITOR_IDX @@ -80,12 +80,12 @@ static struct { &ad_olmBDBEntryCache }, { "( olmBDBAttributes:2 " - "NAME ( 'olmBDBEntryInfo' ) " - "DESC 'Number of items in EntryInfo Cache' " + "NAME ( 'olmBDBDNCache' ) " + "DESC 'Number of items in DN Cache' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE dSAOperation )", - &ad_olmBDBEntryInfo }, + &ad_olmBDBDNCache }, { "( olmBDBAttributes:3 " "NAME ( 'olmBDBIDLCache' ) " @@ -128,7 +128,7 @@ static struct { "SUP top AUXILIARY " "MAY ( " "olmBDBEntryCache " - "$ olmBDBEntryInfo " + "$ olmBDBDNCache " "$ olmBDBIDLCache " "$ olmDbDirectory " #ifdef BDB_MONITOR_IDX @@ -161,7 +161,7 @@ bdb_monitor_update( bv.bv_len = snprintf( buf, sizeof( buf ), "%d", bdb->bi_cache.c_cursize ); ber_bvreplace( &a->a_vals[ 0 ], &bv ); - a = attr_find( e->e_attrs, ad_olmBDBEntryInfo ); + a = attr_find( e->e_attrs, ad_olmBDBDNCache ); assert( a != NULL ); bv.bv_len = snprintf( buf, sizeof( buf ), "%d", bdb->bi_cache.c_eiused ); ber_bvreplace( &a->a_vals[ 0 ], &bv ); @@ -425,7 +425,7 @@ bdb_monitor_db_open( BackendDB *be ) next->a_nvals = next->a_vals; next = next->a_next; - next->a_desc = ad_olmBDBEntryInfo; + next->a_desc = ad_olmBDBDNCache; value_add_one( &next->a_vals, &bv ); next->a_nvals = next->a_vals; next = next->a_next;