summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <eugene.kosov@mariadb.com>2020-06-30 12:00:54 +0300
committerEugene Kosov <eugene.kosov@mariadb.com>2020-06-30 12:17:53 +0300
commit17109001d6db712187ff2ccb43f6c18b01458318 (patch)
treed3130b3889ab7e0c424dbe794a4d3fb7f516dc61
parent97f7d4a9b4da77cb79699a0ea873e4a0e628e8a3 (diff)
downloadmariadb-git-17109001d6db712187ff2ccb43f6c18b01458318.tar.gz
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.
-rw-r--r--storage/innobase/fil/fil0fil.cc17
1 files changed, 4 insertions, 13 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 69790c44617..42f7a7fc3c9 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -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);