Skip to content

Commit 8fb0942

Browse files
committed
MDEV-36759: Huge performance drop
In commit b692342 (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().
1 parent bb48d7b commit 8fb0942

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

storage/innobase/btr/btr0sea.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ ATTRIBUTE_COLD void btr_search_enable(bool resize)
276276
}
277277

278278
btr_search_x_lock_all();
279-
ulint hash_size = buf_pool.curr_size() / sizeof(void *) / 64;
279+
ulint hash_size = buf_pool.curr_pool_size() / sizeof(void *) / 64;
280280

281281
if (btr_search_sys.parts[0].heap) {
282282
ut_ad(btr_search_enabled);

storage/innobase/dict/dict0dict.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ void dict_sys_t::create() noexcept
933933
UT_LIST_INIT(table_LRU, &dict_table_t::table_LRU);
934934
UT_LIST_INIT(table_non_LRU, &dict_table_t::table_LRU);
935935

936-
const ulint hash_size = buf_pool.curr_size()
936+
const ulint hash_size = buf_pool.curr_pool_size()
937937
/ (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
938938

939939
table_hash.create(hash_size);
@@ -4399,7 +4399,7 @@ void dict_sys_t::resize() noexcept
43994399
table_id_hash.free();
44004400
temp_id_hash.free();
44014401

4402-
const ulint hash_size = buf_pool.curr_size()
4402+
const ulint hash_size = buf_pool.curr_pool_size()
44034403
/ (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
44044404
table_hash.create(hash_size);
44054405
table_id_hash.create(hash_size);

storage/innobase/handler/ha_innodb.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4075,7 +4075,6 @@ static int innodb_init_params()
40754075
#else
40764076
ut_ad(srv_file_flush_method <= SRV_O_DIRECT_NO_FSYNC);
40774077
#endif
4078-
srv_lock_table_size = 5 * buf_pool.curr_size();
40794078
DBUG_RETURN(0);
40804079
}
40814080

storage/innobase/srv/srv0start.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ dberr_t srv_start(bool create_new_db)
13111311

13121312
log_sys.create();
13131313
recv_sys.create();
1314-
lock_sys.create(srv_lock_table_size);
1314+
lock_sys.create(srv_lock_table_size = 5 * buf_pool.curr_size());
13151315

13161316
srv_startup_is_before_trx_rollback_phase = true;
13171317

storage/innobase/ut/ut0rnd.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ ut_find_prime(
4848
ulint pow2;
4949
ulint i;
5050

51+
ut_ad(n);
52+
5153
n += 100;
5254

5355
pow2 = 1;

0 commit comments

Comments
 (0)