Commit 17109001 authored by Eugene Kosov's avatar Eugene Kosov

speed up fil_validate() in debug builds

This function is very common in a debug build. I can even see it in
profiler.

This patch reduces execution time of fil_validate() from
8948ns
8367ns
8650ns
8906ns
8448ns

to
260ns
232ns
403ns
275ns
169ns
in my environment.

The trick is a faster fil_space_t iteration. Hash table
is typically initialized with a size of 50,000. And looping through
it is slow. Slower, than iterating an exact amount of fil_space_t
which is typically less than ten.

Only debug builds are affected.
parent 97f7d4a9
......@@ -5314,24 +5314,15 @@ bool
fil_validate(void)
/*==============*/
{
fil_space_t* space;
fil_node_t* fil_node;
ulint n_open = 0;
mutex_enter(&fil_system->mutex);
/* Look for spaces in the hash table */
for (ulint i = 0; i < hash_get_n_cells(fil_system->spaces); i++) {
for (space = static_cast<fil_space_t*>(
HASH_GET_FIRST(fil_system->spaces, i));
space != 0;
space = static_cast<fil_space_t*>(
HASH_GET_NEXT(hash, space))) {
n_open += Check::validate(space);
}
for (fil_space_t *space = UT_LIST_GET_FIRST(fil_system->space_list);
space != NULL;
space = UT_LIST_GET_NEXT(space_list, space)) {
n_open += Check::validate(space);
}
ut_a(fil_system->n_open == n_open);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment