mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
ITS#5860 - free 10*minfree DN cache entries instead of just 1 per pass
This commit is contained in:
parent
288e99cb08
commit
8ba8500ff1
@ -658,6 +658,7 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
||||
DB_LOCK lock, *lockp;
|
||||
EntryInfo *elru, *elnext = NULL;
|
||||
int count, islocked, eimax;
|
||||
int efree = 0, eifree = 0, eicount;
|
||||
|
||||
/* Wait for the mutex; we're the only one trying to purge. */
|
||||
ldap_pvt_thread_mutex_lock( &bdb->bi_cache.c_lru_mutex );
|
||||
@ -670,8 +671,12 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
||||
else
|
||||
eimax = bdb->bi_cache.c_eimax;
|
||||
|
||||
if ( bdb->bi_cache.c_cursize <= bdb->bi_cache.c_maxsize &&
|
||||
bdb->bi_cache.c_leaves <= eimax ) {
|
||||
if ( bdb->bi_cache.c_cursize > bdb->bi_cache.c_maxsize )
|
||||
efree = bdb->bi_cache.c_minfree;
|
||||
if ( bdb->bi_cache.c_leaves > eimax )
|
||||
eifree = bdb->bi_cache.c_minfree * 10;
|
||||
|
||||
if ( !efree && !eifree ) {
|
||||
ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.c_lru_mutex );
|
||||
bdb->bi_cache.c_purging = 0;
|
||||
return;
|
||||
@ -684,6 +689,7 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
||||
}
|
||||
|
||||
count = 0;
|
||||
eicount = 0;
|
||||
|
||||
/* Look for an unused entry to remove */
|
||||
for ( elru = bdb->bi_cache.c_lruhead; elru; elru = elnext ) {
|
||||
@ -720,8 +726,7 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
||||
|
||||
/* Free entry for this node if it's present */
|
||||
if ( elru->bei_e ) {
|
||||
if ( bdb->bi_cache.c_cursize > bdb->bi_cache.c_maxsize &&
|
||||
count < bdb->bi_cache.c_minfree ) {
|
||||
if ( count < efree ) {
|
||||
elru->bei_e->e_private = NULL;
|
||||
#ifdef SLAP_ZONE_ALLOC
|
||||
bdb_entry_return( bdb, elru->bei_e, elru->bei_zseq );
|
||||
@ -744,11 +749,12 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
||||
if ( elru->bei_kids ) {
|
||||
/* Drop from list, we ignore it... */
|
||||
LRU_DEL( &bdb->bi_cache, elru );
|
||||
} else if ( bdb->bi_cache.c_leaves > eimax ) {
|
||||
} else if ( eicount < eifree ) {
|
||||
/* Too many leaf nodes, free this one */
|
||||
bdb_cache_delete_internal( &bdb->bi_cache, elru, 0 );
|
||||
bdb_cache_delete_cleanup( &bdb->bi_cache, elru );
|
||||
islocked = 0;
|
||||
eicount++;
|
||||
} /* Leave on list until we need to free it */
|
||||
}
|
||||
|
||||
@ -756,8 +762,7 @@ next:
|
||||
if ( islocked )
|
||||
bdb_cache_entryinfo_unlock( elru );
|
||||
|
||||
if (( bdb->bi_cache.c_cursize <= bdb->bi_cache.c_maxsize ||
|
||||
(unsigned) count >= bdb->bi_cache.c_minfree ) && bdb->bi_cache.c_leaves <= eimax ) {
|
||||
if ( count >= efree && eicount >= eifree ) {
|
||||
if ( count ) {
|
||||
ldap_pvt_thread_mutex_lock( &bdb->bi_cache.c_count_mutex );
|
||||
bdb->bi_cache.c_cursize -= count;
|
||||
|
Loading…
Reference in New Issue
Block a user