Skip to content
Snippets Groups Projects
Commit d4a42232 authored by Howard Chu's avatar Howard Chu
Browse files

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

parent 32f6c9ec
No related branches found
No related tags found
No related merge requests found
...@@ -99,6 +99,7 @@ struct bdb_info { ...@@ -99,6 +99,7 @@ struct bdb_info {
slap_mask_t bi_defaultmask; slap_mask_t bi_defaultmask;
Cache bi_cache; Cache bi_cache;
Avlnode *bi_attrs; Avlnode *bi_attrs;
void *bi_search_stack;
#ifdef BDB_HIER #ifdef BDB_HIER
Avlnode *bi_tree; Avlnode *bi_tree;
ldap_pvt_thread_rdwr_t bi_tree_rdwr; ldap_pvt_thread_rdwr_t bi_tree_rdwr;
......
...@@ -957,6 +957,40 @@ static int oc_filter( ...@@ -957,6 +957,40 @@ static int oc_filter(
return rc; 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( static int search_candidates(
BackendDB *be, BackendDB *be,
Operation *op, Operation *op,
...@@ -1053,11 +1087,17 @@ static int search_candidates( ...@@ -1053,11 +1087,17 @@ static int search_candidates(
#endif #endif
/* Allocate IDL stack, plus 1 more for former tmp */ /* 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 ); 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 ) { if( rc ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment