Skip to content

Commit

Permalink
speed up fil_validate() in debug builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kevgs committed Jun 30, 2020
1 parent 97f7d4a commit 1710900
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1710900

Please sign in to comment.