Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
ad922dc8
Commit
ad922dc8
authored
Dec 12, 2002
by
Kurt Zeilenga
Browse files
Add IDL caching codes (only slab enabled)
parent
01937058
Changes
4
Hide whitespace changes
Inline
Side-by-side
servers/slapd/back-bdb/back-bdb.h
View file @
ad922dc8
...
...
@@ -60,6 +60,21 @@ LDAP_BEGIN_DECL
#define DEFAULT_CACHE_SIZE 1000
/* The default search IDL stack cache depth */
#define DEFAULT_SEARCH_STACK_DEPTH 16
/* for the (expermental) IDL cache */
#ifdef SLAP_IDL_CACHE
typedef
struct
bdb_idl_cache_entry_s
{
struct
berval
kstr
;
ldap_pvt_thread_rdwr_t
idl_entry_rwlock
;
ID
*
idl
;
DB
*
db
;
struct
bdb_idl_cache_entry_s
*
idl_lru_prev
;
struct
bdb_idl_cache_entry_s
*
idl_lru_next
;
}
bdb_idl_cache_entry_t
;
#endif
/* for the in-core cache of entries */
typedef
struct
bdb_cache
{
int
c_maxsize
;
...
...
@@ -99,6 +114,8 @@ struct bdb_info {
slap_mask_t
bi_defaultmask
;
Cache
bi_cache
;
Avlnode
*
bi_attrs
;
void
*
bi_search_stack
;
int
bi_search_stack_depth
;
#ifdef BDB_HIER
Avlnode
*
bi_tree
;
ldap_pvt_thread_rdwr_t
bi_tree_rdwr
;
...
...
@@ -116,6 +133,14 @@ struct bdb_info {
#ifdef LDAP_CLIENT_UPDATE
LDAP_LIST_HEAD
(
pl
,
slap_op
)
psearch_list
;
#endif
#ifdef SLAP_IDL_CACHE
int
bi_idl_cache_max_size
;
int
bi_idl_cache_size
;
Avlnode
*
bi_idl_tree
;
bdb_idl_cache_entry_t
*
bi_idl_lru_head
;
bdb_idl_cache_entry_t
*
bi_idl_lru_tail
;
ldap_pvt_thread_mutex_t
bi_idl_tree_mutex
;
#endif
};
#define bi_id2entry bi_databases[BDB_ID2ENTRY]
...
...
servers/slapd/back-bdb/config.c
View file @
ad922dc8
...
...
@@ -135,6 +135,28 @@ bdb_db_config(
}
bdb
->
bi_cache
.
c_maxsize
=
atoi
(
argv
[
1
]
);
/* depth of search stack cache in units of (IDL)s */
}
else
if
(
strcasecmp
(
argv
[
0
],
"searchstack"
)
==
0
)
{
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"%s: line %d: missing depth in
\"
searchstack <depth>
\"
line
\n
"
,
fname
,
lineno
);
return
(
1
);
}
bdb
->
bi_search_stack_depth
=
atoi
(
argv
[
1
]
);
#ifdef SLAP_IDL_CACHE
/* size of the IDL cache in entries */
}
else
if
(
strcasecmp
(
argv
[
0
],
"idlcachesize"
)
==
0
)
{
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"%s: line %d: missing size in
\"
idlcachesize <size>
\"
line
\n
"
,
fname
,
lineno
);
return
(
1
);
}
bdb
->
bi_idl_cache_max_size
=
atoi
(
argv
[
1
]
);
#endif
/* anything else */
}
else
{
fprintf
(
stderr
,
"%s: line %d: "
...
...
servers/slapd/back-bdb/init.c
View file @
ad922dc8
...
...
@@ -92,6 +92,8 @@ bdb_db_init( BackendDB *be )
bdb
->
bi_cache
.
c_maxsize
=
DEFAULT_CACHE_SIZE
;
bdb
->
bi_lock_detect
=
DB_LOCK_DEFAULT
;
bdb
->
bi_search_stack_depth
=
DEFAULT_SEARCH_STACK_DEPTH
;
bdb
->
bi_search_stack
=
NULL
;
#ifdef LDAP_CLIENT_UPDATE
LDAP_LIST_INIT
(
&
bdb
->
psearch_list
);
...
...
@@ -106,6 +108,7 @@ bdb_db_init( BackendDB *be )
#endif
be
->
be_private
=
bdb
;
return
0
;
}
...
...
@@ -184,6 +187,13 @@ bdb_db_open( BackendDB *be )
bdb
->
bi_dbenv
->
set_errcall
(
bdb
->
bi_dbenv
,
bdb_errcall
);
bdb
->
bi_dbenv
->
set_lk_detect
(
bdb
->
bi_dbenv
,
bdb
->
bi_lock_detect
);
#ifdef SLAP_IDL_CACHE
if
(
bdb
->
bi_idl_cache_max_size
)
{
ldap_pvt_thread_mutex_init
(
&
bdb
->
bi_idl_tree_mutex
);
bdb
->
bi_idl_cache_size
=
0
;
}
#endif
#ifdef BDB_SUBDIRS
{
char
dir
[
MAXPATHLEN
];
...
...
@@ -402,6 +412,9 @@ bdb_db_close( BackendDB *be )
int
rc
;
struct
bdb_info
*
bdb
=
(
struct
bdb_info
*
)
be
->
be_private
;
struct
bdb_db_info
*
db
;
#ifdef SLAP_IDL_CACHE
bdb_idl_cache_entry_t
*
entry
,
*
next_entry
;
#endif
while
(
bdb
->
bi_ndatabases
--
)
{
db
=
bdb
->
bi_databases
[
bdb
->
bi_ndatabases
];
...
...
@@ -416,6 +429,19 @@ bdb_db_close( BackendDB *be )
bdb_cache_release_all
(
&
bdb
->
bi_cache
);
#ifdef SLAP_IDL_CACHE
ldap_pvt_thread_mutex_lock
(
&
bdb
->
bi_idl_tree_mutex
);
entry
=
bdb
->
bi_idl_lru_head
;
while
(
entry
!=
NULL
)
{
next_entry
=
entry
->
idl_lru_next
;
free
(
entry
->
idl
);
free
(
entry
->
kstr
.
bv_val
);
free
(
entry
);
entry
=
next_entry
;
}
ldap_pvt_thread_mutex_unlock
(
&
bdb
->
bi_idl_tree_mutex
);
#endif
return
0
;
}
...
...
servers/slapd/back-bdb/search.c
View file @
ad922dc8
...
...
@@ -897,6 +897,38 @@ static int oc_filter(
return
rc
;
}
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
(
bdb
->
bi_search_stack_depth
*
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
,
...
...
@@ -906,6 +938,7 @@ static int search_candidates(
int
deref
,
ID
*
ids
)
{
struct
bdb_info
*
bdb
=
(
struct
bdb_info
*
)
be
->
be_private
;
int
rc
,
depth
=
1
;
Filter
f
,
scopef
,
rf
,
xf
;
ID
*
stack
;
...
...
@@ -993,11 +1026,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
>
bdb
->
bi_search_stack_depth
)
{
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
>
bdb
->
bi_search_stack_depth
)
{
ch_free
(
stack
);
}
if
(
rc
)
{
#ifdef NEW_LOGGING
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment