From ITS#2183, use a long-lived IDL stack per thread.

This commit is contained in:
Howard Chu 2002-12-10 17:59:21 +00:00
parent 32f6c9ec6d
commit d4a422329b
2 changed files with 43 additions and 2 deletions

View File

@ -99,6 +99,7 @@ struct bdb_info {
slap_mask_t bi_defaultmask;
Cache bi_cache;
Avlnode *bi_attrs;
void *bi_search_stack;
#ifdef BDB_HIER
Avlnode *bi_tree;
ldap_pvt_thread_rdwr_t bi_tree_rdwr;

View File

@ -957,6 +957,40 @@ static int oc_filter(
return rc;
}
#define SRCH_STACK_SIZE 16
static void search_stack_free( void *key, void *data)
{
ch_free(data);
}
static void *search_stack(
BackendDB *be,
Operation *op
)
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
void *ret = NULL;
if ( op->o_threadctx ) {
ldap_pvt_thread_pool_getkey( op->o_threadctx, search_stack,
&ret, NULL );
} else {
ret = bdb->bi_search_stack;
}
if ( !ret ) {
ret = ch_malloc( SRCH_STACK_SIZE * BDB_IDL_UM_SIZE * sizeof( ID ) );
if ( op->o_threadctx ) {
ldap_pvt_thread_pool_setkey( op->o_threadctx, search_stack,
ret, search_stack_free );
} else {
bdb->bi_search_stack = ret;
}
}
return ret;
}
static int search_candidates(
BackendDB *be,
Operation *op,
@ -1053,11 +1087,17 @@ static int search_candidates(
#endif
/* Allocate IDL stack, plus 1 more for former tmp */
stack = ch_malloc( (depth + 1) * BDB_IDL_UM_SIZE * sizeof( ID ) );
if ( depth+1 > SRCH_STACK_SIZE ) {
stack = ch_malloc( (depth + 1) * BDB_IDL_UM_SIZE * sizeof( ID ) );
} else {
stack = search_stack( be, op );
}
rc = bdb_filter_candidates( be, &f, ids, stack, stack+BDB_IDL_UM_SIZE );
ch_free( stack );
if ( depth+1 > SRCH_STACK_SIZE ) {
ch_free( stack );
}
if( rc ) {
#ifdef NEW_LOGGING