Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Analysis
Under high throughput, a hotspot caused by
rw_lock_s_lock_func
can be observed in MySQL, originating fromBuf_fetch_normal::get
. The key call path is:buf_page_get_gen → Buf_fetch::single_page → Buf_fetch_normal::get
.The function of

Buf_fetch_normal::get
is to retrieve the pointer to a data block (i.e.,buf_block_t*
) in the buffer pool for a target data page, which involves querying the buffer pool using (space_id, page_no) to read or write page content. This mapping relationship is maintained by a hash table called page_hash, protected byhash_table_locks
. Therw_lock_s_lock_func
hotspot arises from the read-lock operation on thesehash_table_locks
.On the other hand, sharding the lock objects with fierce competition is a common optimization method. In MySQL source code,

hash_table_locks
has been optimized through sharding. The number of shards is controlled bysrv_n_page_hash_locks
, but it is hard-coded to 16.Optimization