MDEV-36759: Huge performance drop

In commit b6923420f3 (MDEV-29445)
some hash tables were accidentally created with the minimum size
(101 entries) instead of correctly deriving the size from the
initial innodb_buffer_pool_size. This led to very long hash bucket
chains, which are very slow to traverse.

ut_find_prime(): Assert that the size is nonzero in order to catch
this type of regression in the future.

innodb_init_params(): Do not bother reading buf_pool.curr_size()
when it is known to be 0,

srv_start(): Correctly initialize srv_lock_table_size to 5 times
buf_pool.curr_size(), that is, the buffer pool size in pages,
between invoking buf_pool.create() and lock_sys.create().

btr_search_enable(), dict_sys_t::create(), dict_sys_t::resize():
Correctly refer to buf_pool.curr_pool_size(), that is,
innodb_buffer_pool_size in bytes, when calculating the hash table size.
In MDEV-29445 the expressions buf_pool_get_curr_size() were
accidentally replaced with buf_pool.curr_size().
This commit is contained in:
Marko Mäkelä 2025-05-13 12:27:50 +03:00
commit 8fb09426b9
5 changed files with 6 additions and 5 deletions

View file

@ -276,7 +276,7 @@ ATTRIBUTE_COLD void btr_search_enable(bool resize)
}
btr_search_x_lock_all();
ulint hash_size = buf_pool.curr_size() / sizeof(void *) / 64;
ulint hash_size = buf_pool.curr_pool_size() / sizeof(void *) / 64;
if (btr_search_sys.parts[0].heap) {
ut_ad(btr_search_enabled);

View file

@ -933,7 +933,7 @@ void dict_sys_t::create() noexcept
UT_LIST_INIT(table_LRU, &dict_table_t::table_LRU);
UT_LIST_INIT(table_non_LRU, &dict_table_t::table_LRU);
const ulint hash_size = buf_pool.curr_size()
const ulint hash_size = buf_pool.curr_pool_size()
/ (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
table_hash.create(hash_size);
@ -4399,7 +4399,7 @@ void dict_sys_t::resize() noexcept
table_id_hash.free();
temp_id_hash.free();
const ulint hash_size = buf_pool.curr_size()
const ulint hash_size = buf_pool.curr_pool_size()
/ (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
table_hash.create(hash_size);
table_id_hash.create(hash_size);

View file

@ -4075,7 +4075,6 @@ static int innodb_init_params()
#else
ut_ad(srv_file_flush_method <= SRV_O_DIRECT_NO_FSYNC);
#endif
srv_lock_table_size = 5 * buf_pool.curr_size();
DBUG_RETURN(0);
}

View file

@ -1311,7 +1311,7 @@ dberr_t srv_start(bool create_new_db)
log_sys.create();
recv_sys.create();
lock_sys.create(srv_lock_table_size);
lock_sys.create(srv_lock_table_size = 5 * buf_pool.curr_size());
srv_startup_is_before_trx_rollback_phase = true;

View file

@ -48,6 +48,8 @@ ut_find_prime(
ulint pow2;
ulint i;
ut_ad(n);
n += 100;
pow2 = 1;