]> git.sur5r.net Git - openldap/commitdiff
Add config keyword for DN cache size (aka EntryInfoSize)
authorHoward Chu <hyc@openldap.org>
Sat, 11 Aug 2007 19:29:14 +0000 (19:29 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 11 Aug 2007 19:29:14 +0000 (19:29 +0000)
default is 2x entry cache size

servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/config.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/monitor.c

index 721096fa9b5de8529e63d7422d52eb315fd7ab11..f0dc8000079d721cb2babd1efa905c6cc8756601 100644 (file)
@@ -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
index 3a4618a041645fdaba12d5e4118440816859c9e9..db5429382ba444b25deb275f188fe92e6c8aa457 100644 (file)
@@ -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 ) {
index 7105c1762b44cf919993cce076f264b5a03f80bf..39d1116cd3389d4ba8fbdeae3526b2ae5e25f900 100644 (file)
@@ -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 }
 };
index 521dc26b472c7bf8752c42ef721d4f4da5f25e69..24cedde31a7c85241423af27a3c62356f06fa675 100644 (file)
@@ -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;
index afc173e62d5808a4ae719e50d484c60048cf74b1..ffde364a270893baae2427d8c1705e33066fcd10 100644 (file)
@@ -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;