Commit 852771ba authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-23719: Remove buf_block_t::lock_hash_val

The InnoDB buffer block page descriptor is caching a value
buf_block_t::lock_hash_val that should be quick to compute
in the first place, as suggested by
commit 14be8143.

lock_rec_fold(): Define as page_id_t::fold() instead of
ut_fold_ulint_pair().
parent 2bac9782
...@@ -1763,10 +1763,6 @@ inline bool buf_pool_t::realloc(buf_block_t *block) ...@@ -1763,10 +1763,6 @@ inline bool buf_pool_t::realloc(buf_block_t *block)
new_block->left_side = TRUE; new_block->left_side = TRUE;
#endif /* BTR_CUR_HASH_ADAPT */ #endif /* BTR_CUR_HASH_ADAPT */
new_block->lock_hash_val = block->lock_hash_val;
ut_ad(new_block->lock_hash_val == lock_rec_hash(
id.space(), id.page_no()));
hash_lock->write_unlock(); hash_lock->write_unlock();
/* free block */ /* free block */
...@@ -3368,9 +3364,6 @@ buf_page_get_low( ...@@ -3368,9 +3364,6 @@ buf_page_get_low(
/* Set after buf_relocate(). */ /* Set after buf_relocate(). */
block->page.set_buf_fix_count(1); block->page.set_buf_fix_count(1);
block->lock_hash_val = lock_rec_hash(page_id.space(),
page_id.page_no());
if (!block->page.oldest_modification()) { if (!block->page.oldest_modification()) {
ut_d(UT_LIST_REMOVE(buf_pool.zip_clean, &block->page)); ut_d(UT_LIST_REMOVE(buf_pool.zip_clean, &block->page));
} else { } else {
...@@ -3800,7 +3793,6 @@ void buf_block_t::initialise(const page_id_t page_id, ulint zip_size, ...@@ -3800,7 +3793,6 @@ void buf_block_t::initialise(const page_id_t page_id, ulint zip_size,
{ {
ut_ad(page.state() != BUF_BLOCK_FILE_PAGE); ut_ad(page.state() != BUF_BLOCK_FILE_PAGE);
buf_block_init_low(this); buf_block_init_low(this);
lock_hash_val= lock_rec_hash(page_id.space(), page_id.page_no());
page.init(page_id, fix); page.init(page_id, fix);
page_zip_set_size(&page.zip, zip_size); page_zip_set_size(&page.zip, zip_size);
} }
...@@ -3884,8 +3876,6 @@ buf_page_create(fil_space_t *space, uint32_t offset, ...@@ -3884,8 +3876,6 @@ buf_page_create(fil_space_t *space, uint32_t offset,
#endif #endif
free_block->page.set_state(BUF_BLOCK_FILE_PAGE); free_block->page.set_state(BUF_BLOCK_FILE_PAGE);
free_block->lock_hash_val= lock_rec_hash(
page_id.space(), page_id.page_no());
buf_unzip_LRU_add_block(free_block, FALSE); buf_unzip_LRU_add_block(free_block, FALSE);
hash_lock->write_unlock(); hash_lock->write_unlock();
buf_page_free_descriptor(&block->page); buf_page_free_descriptor(&block->page);
......
...@@ -1528,7 +1528,6 @@ rtr_copy_buf( ...@@ -1528,7 +1528,6 @@ rtr_copy_buf(
ut_d(matches->block.in_withdraw_list = block->in_withdraw_list); ut_d(matches->block.in_withdraw_list = block->in_withdraw_list);
/* Skip buf_block_t::lock */ /* Skip buf_block_t::lock */
matches->block.lock_hash_val = block->lock_hash_val;
matches->block.modify_clock = block->modify_clock; matches->block.modify_clock = block->modify_clock;
#ifdef BTR_CUR_HASH_ADAPT #ifdef BTR_CUR_HASH_ADAPT
matches->block.n_hash_helps = block->n_hash_helps; matches->block.n_hash_helps = block->n_hash_helps;
......
...@@ -596,16 +596,6 @@ inline uint buf_page_full_crc32_size(const byte* buf, bool* comp, bool* cr) ...@@ -596,16 +596,6 @@ inline uint buf_page_full_crc32_size(const byte* buf, bool* comp, bool* cr)
} }
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
Gets the hash value of a block. This can be used in searches in the
lock hash table.
@return lock hash value */
UNIV_INLINE
unsigned
buf_block_get_lock_hash_val(
/*========================*/
const buf_block_t* block) /*!< in: block */
MY_ATTRIBUTE((warn_unused_result));
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** Find a block in the buffer pool that points to a given compressed page. /** Find a block in the buffer pool that points to a given compressed page.
@param[in] data pointer to compressed page @param[in] data pointer to compressed page
...@@ -1070,13 +1060,6 @@ struct buf_block_t{ ...@@ -1070,13 +1060,6 @@ struct buf_block_t{
a block is in the unzip_LRU list a block is in the unzip_LRU list
if page.state() == BUF_BLOCK_FILE_PAGE if page.state() == BUF_BLOCK_FILE_PAGE
and page.zip.data != NULL */ and page.zip.data != NULL */
uint32_t lock_hash_val; /*!< hashed value of the page address
in the record lock hash table;
protected by buf_block_t::lock
(or buf_pool.mutex
in buf_page_get_gen(),
buf_page_init_for_read()
and buf_page_create()) */
/* @} */ /* @} */
/** @name Optimistic search field */ /** @name Optimistic search field */
/* @{ */ /* @{ */
......
...@@ -154,24 +154,6 @@ ok: ...@@ -154,24 +154,6 @@ ok:
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/**********************************************************************//**
Gets the hash value of the page the pointer is pointing to. This can be used
in searches in the lock hash table.
@return lock hash value */
UNIV_INLINE
unsigned
buf_block_get_lock_hash_val(
/*========================*/
const buf_block_t* block) /*!< in: block */
{
ut_ad(block);
ut_ad(block->page.in_file());
ut_ad(rw_lock_own(&(((buf_block_t*) block)->lock), RW_LOCK_X)
|| rw_lock_own(&(((buf_block_t*) block)->lock), RW_LOCK_S));
return(block->lock_hash_val);
}
/********************************************************************//** /********************************************************************//**
Allocates a buf_page_t descriptor. This function must succeed. In case Allocates a buf_page_t descriptor. This function must succeed. In case
of failure we assert in this function. of failure we assert in this function.
......
...@@ -39,7 +39,7 @@ lock_rec_fold( ...@@ -39,7 +39,7 @@ lock_rec_fold(
ulint space, /*!< in: space */ ulint space, /*!< in: space */
ulint page_no)/*!< in: page number */ ulint page_no)/*!< in: page number */
{ {
return(ut_fold_ulint_pair(space, page_no)); return page_id_t(space, page_no).fold();
} }
/*********************************************************************//** /*********************************************************************//**
......
...@@ -164,12 +164,14 @@ lock_rec_get_first_on_page( ...@@ -164,12 +164,14 @@ lock_rec_get_first_on_page(
{ {
ut_ad(lock_mutex_own()); ut_ad(lock_mutex_own());
ulint space = block->page.id().space(); const page_id_t page_id(block->page.id());
ulint page_no = block->page.id().page_no();
ulint hash = buf_block_get_lock_hash_val(block); ulint space = page_id.space();
ulint page_no = page_id.page_no();
for (lock_t* lock = static_cast<lock_t*>( for (lock_t* lock = static_cast<lock_t*>(
HASH_GET_FIRST(lock_hash, hash)); HASH_GET_FIRST(lock_hash,
lock_rec_hash(space, page_no)));
lock != NULL; lock != NULL;
lock = static_cast<lock_t*>(HASH_GET_NEXT(hash, lock))) { lock = static_cast<lock_t*>(HASH_GET_NEXT(hash, lock))) {
......
...@@ -515,18 +515,6 @@ void lock_sys_t::resize(ulint n_cells) ...@@ -515,18 +515,6 @@ void lock_sys_t::resize(ulint n_cells)
HASH_MIGRATE(&old_hash, &prdt_page_hash, lock_t, hash, HASH_MIGRATE(&old_hash, &prdt_page_hash, lock_t, hash,
lock_rec_lock_fold); lock_rec_lock_fold);
old_hash.free(); old_hash.free();
/* need to update block->lock_hash_val */
mutex_enter(&buf_pool.mutex);
for (buf_page_t* bpage = UT_LIST_GET_FIRST(buf_pool.LRU);
bpage; bpage = UT_LIST_GET_NEXT(LRU, bpage)) {
if (bpage->state() == BUF_BLOCK_FILE_PAGE) {
const page_id_t id(bpage->id());
reinterpret_cast<buf_block_t*>(bpage)->lock_hash_val
= lock_rec_hash(id.space(), id.page_no());
}
}
mutex_exit(&buf_pool.mutex);
mutex_exit(&mutex); mutex_exit(&mutex);
} }
......
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