Commit 65b4b903 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-22871 follow-up: Align buf_pool.page_hash.array

buf_pool_t::page_hash_table::create(): Use aligned_malloc()
for the hash array, to get the page_hash_latch aligned on the
same L1 data cache line as the data that it is protecting.
parent 9b8bc713
......@@ -1488,8 +1488,10 @@ static void buf_block_free_mutexes(buf_block_t* block)
void buf_pool_t::page_hash_table::create(ulint n)
{
n_cells= ut_find_prime(n);
array= static_cast<hash_cell_t*>
(ut_zalloc_nokey(pad(n_cells) * sizeof *array));
const size_t size= pad(n_cells) * sizeof *array;
void* v= aligned_malloc(size, CPU_LEVEL1_DCACHE_LINESIZE);
memset(v, 0, size);
array= static_cast<hash_cell_t*>(v);
}
/** Create the buffer pool.
......
......@@ -1832,7 +1832,7 @@ class buf_pool_t
/** number of payload elements in array[] */
Atomic_relaxed<ulint> n_cells;
/** the hash array, with pad(n_cells) elements */
/** the hash table, with pad(n_cells) elements, aligned to L1 cache size */
hash_cell_t *array;
/** Create the hash table.
......@@ -1840,7 +1840,7 @@ class buf_pool_t
void create(ulint n);
/** Free the hash table. */
void free() { ut_free(array); array= nullptr; }
void free() { aligned_free(array); array= nullptr; }
/** @return the index of an array element */
ulint calc_hash(ulint fold) const { return calc_hash(fold, n_cells); }
......
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