[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: slapadd performance degradation from 2.3.43 to 2.4.12



Did I send this?  Trying again -  I wrote:

> ...unless the doc is inaccurate.

which in any case would be no reason to make bdb_tool_entry_put()
wait for env->memp_trickle().  If you keep the mutex lock,
set a flag while locked and move memp_trickle() out of the lock.

diff -u -2 -r1.130 servers/slapd/back-bdb/tools.c
--- servers/slapd/back-bdb/tools.c	13 Oct 2008 06:35:31 -0000	1.130
+++ servers/slapd/back-bdb/tools.c	25 Nov 2008 14:05:57 -0000
@@ -78,4 +78,5 @@
 static ldap_pvt_thread_mutex_t bdb_tool_trickle_mutex;
 static ldap_pvt_thread_cond_t bdb_tool_trickle_cond;
+static int bdb_tool_trickle_flag;
 
 static void * bdb_tool_index_task( void *ctx, void *ptr );
@@ -139,4 +140,5 @@
 		slapd_shutdown = 1;
 		ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex );
+		bdb_tool_trickle_flag = 1;
 		ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond );
 		ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );
@@ -524,4 +526,5 @@
 	if (( slapMode & SLAP_TOOL_QUICK ) && (( e->e_id & 0xfff ) == 0xfff )) {
 		ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex );
+		bdb_tool_trickle_flag = 1;
 		ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond );
 		ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );
@@ -1105,13 +1108,16 @@
 	int wrote;
 
-	ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex );
 	while ( 1 ) {
-		ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond,
-			&bdb_tool_trickle_mutex );
+		ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex );
+		while ( !bdb_tool_trickle_flag )
+			ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond,
+				&bdb_tool_trickle_mutex );
+		bdb_tool_trickle_flag = 0;
+		ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );
+
 		if ( slapd_shutdown )
 			break;
 		env->memp_trickle( env, 30, &wrote );
 	}
-	ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );
 
 	return NULL;

-- 
Hallvard